[llvm] 9c8b28a - [llvm-reduce] Remove unwanted module inline asm

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 6 09:35:44 PDT 2021


Author: Arthur Eubanks
Date: 2021-04-06T09:35:37-07:00
New Revision: 9c8b28a69b95db539f5da5ee5af6e273504bf869

URL: https://github.com/llvm/llvm-project/commit/9c8b28a69b95db539f5da5ee5af6e273504bf869
DIFF: https://github.com/llvm/llvm-project/commit/9c8b28a69b95db539f5da5ee5af6e273504bf869.diff

LOG: [llvm-reduce] Remove unwanted module inline asm

We can clear line by line, but that's likely not very important.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D99921

Added: 
    llvm/test/tools/llvm-reduce/remove-module-inline-asm.ll
    llvm/tools/llvm-reduce/deltas/ReduceModuleInlineAsm.cpp
    llvm/tools/llvm-reduce/deltas/ReduceModuleInlineAsm.h

Modified: 
    llvm/tools/llvm-reduce/CMakeLists.txt
    llvm/tools/llvm-reduce/DeltaManager.cpp
    llvm/utils/gn/secondary/llvm/tools/llvm-reduce/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-reduce/remove-module-inline-asm.ll b/llvm/test/tools/llvm-reduce/remove-module-inline-asm.ll
new file mode 100644
index 0000000000000..fa4dba8551f10
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/remove-module-inline-asm.ll
@@ -0,0 +1,11 @@
+; RUN: llvm-reduce --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
+; RUN: FileCheck --check-prefix=CHECK-FINAL %s < %t
+
+; CHECK-INTERESTINGNESS: declare
+
+; CHECK-FINAL-NOT: module asm
+; CHECK-FINAL: declare void @g
+
+module asm "foo"
+
+declare void @g()

diff  --git a/llvm/tools/llvm-reduce/CMakeLists.txt b/llvm/tools/llvm-reduce/CMakeLists.txt
index 4b37ff622bbfe..44818edc728ad 100644
--- a/llvm/tools/llvm-reduce/CMakeLists.txt
+++ b/llvm/tools/llvm-reduce/CMakeLists.txt
@@ -25,6 +25,7 @@ add_llvm_tool(llvm-reduce
   deltas/ReduceGlobalVars.cpp
   deltas/ReduceInstructions.cpp
   deltas/ReduceMetadata.cpp
+  deltas/ReduceModuleInlineAsm.cpp
   deltas/ReduceOperandBundles.cpp
   deltas/ReduceSpecialGlobals.cpp
   llvm-reduce.cpp

diff  --git a/llvm/tools/llvm-reduce/DeltaManager.cpp b/llvm/tools/llvm-reduce/DeltaManager.cpp
index 797b6802d0e79..c336e3dd0e61b 100644
--- a/llvm/tools/llvm-reduce/DeltaManager.cpp
+++ b/llvm/tools/llvm-reduce/DeltaManager.cpp
@@ -25,6 +25,7 @@
 #include "deltas/ReduceGlobalVars.h"
 #include "deltas/ReduceInstructions.h"
 #include "deltas/ReduceMetadata.h"
+#include "deltas/ReduceModuleInlineAsm.h"
 #include "deltas/ReduceOperandBundles.h"
 #include "deltas/ReduceSpecialGlobals.h"
 
@@ -45,6 +46,7 @@ void runDeltaPasses(TestRunner &Tester) {
   reduceInstructionsDeltaPass(Tester);
   reduceOperandBundesDeltaPass(Tester);
   reduceAttributesDeltaPass(Tester);
+  reduceModuleInlineAsmDeltaPass(Tester);
   // TODO: Implement the remaining Delta Passes
 }
-} // namespace llvm
\ No newline at end of file
+} // namespace llvm

diff  --git a/llvm/tools/llvm-reduce/deltas/ReduceModuleInlineAsm.cpp b/llvm/tools/llvm-reduce/deltas/ReduceModuleInlineAsm.cpp
new file mode 100644
index 0000000000000..b74bd0ae08dbd
--- /dev/null
+++ b/llvm/tools/llvm-reduce/deltas/ReduceModuleInlineAsm.cpp
@@ -0,0 +1,32 @@
+//===- ReduceModuleInlineAsm.cpp ------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements a function which calls the Generic Delta pass to reduce
+// module inline asm.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ReduceModuleInlineAsm.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/GlobalValue.h"
+
+using namespace llvm;
+
+static void clearModuleInlineAsm(std::vector<Chunk> ChunksToKeep,
+                                 Module *Program) {
+  Oracle O(ChunksToKeep);
+
+  // TODO: clear line by line rather than all at once
+  if (!O.shouldKeep())
+    Program->setModuleInlineAsm("");
+}
+
+void llvm::reduceModuleInlineAsmDeltaPass(TestRunner &Test) {
+  outs() << "*** Reducing Module Inline Asm...\n";
+  runDeltaPass(Test, 1, clearModuleInlineAsm);
+}

diff  --git a/llvm/tools/llvm-reduce/deltas/ReduceModuleInlineAsm.h b/llvm/tools/llvm-reduce/deltas/ReduceModuleInlineAsm.h
new file mode 100644
index 0000000000000..6d31c8f008d21
--- /dev/null
+++ b/llvm/tools/llvm-reduce/deltas/ReduceModuleInlineAsm.h
@@ -0,0 +1,18 @@
+//===- ReduceModuleInlineAsm.h --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_LLVM_REDUCE_DELTAS_REDUCE_MODULEINLINEASM_H
+#define LLVM_TOOLS_LLVM_REDUCE_DELTAS_REDUCE_MODULEINLINEASM_H
+
+#include "Delta.h"
+
+namespace llvm {
+void reduceModuleInlineAsmDeltaPass(TestRunner &Test);
+} // namespace llvm
+
+#endif

diff  --git a/llvm/utils/gn/secondary/llvm/tools/llvm-reduce/BUILD.gn b/llvm/utils/gn/secondary/llvm/tools/llvm-reduce/BUILD.gn
index eb1492b6f03d1..018d2acbeb93a 100644
--- a/llvm/utils/gn/secondary/llvm/tools/llvm-reduce/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/tools/llvm-reduce/BUILD.gn
@@ -23,6 +23,7 @@ executable("llvm-reduce") {
     "deltas/ReduceGlobalVars.cpp",
     "deltas/ReduceInstructions.cpp",
     "deltas/ReduceMetadata.cpp",
+    "deltas/ReduceModuleInlineAsm.cpp",
     "deltas/ReduceOperandBundles.cpp",
     "deltas/ReduceSpecialGlobals.cpp",
     "llvm-reduce.cpp",


        


More information about the llvm-commits mailing list