[llvm] 6f06eda - bugpoint: Add option to disable attribute removal

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 18 21:41:35 PST 2019


Author: Matt Arsenault
Date: 2019-11-19T11:11:00+05:30
New Revision: 6f06eda070eb574ad3ad6612f037e1fab7a1f0db

URL: https://github.com/llvm/llvm-project/commit/6f06eda070eb574ad3ad6612f037e1fab7a1f0db
DIFF: https://github.com/llvm/llvm-project/commit/6f06eda070eb574ad3ad6612f037e1fab7a1f0db.diff

LOG: bugpoint: Add option to disable attribute removal

This takes a long time and never reduces anything useful for me
(e.g. I've been waiting for 3 hours on a testcase and it hasn't found
any attributes to remove yet). This should probably start by assuming
no attributes matter, and adding back.

Added: 
    

Modified: 
    llvm/test/BugPoint/func-attrs.ll
    llvm/tools/bugpoint/CrashDebugger.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/BugPoint/func-attrs.ll b/llvm/test/BugPoint/func-attrs.ll
index 8f742ee93d5f..e471ff2ae14c 100644
--- a/llvm/test/BugPoint/func-attrs.ll
+++ b/llvm/test/BugPoint/func-attrs.ll
@@ -1,11 +1,15 @@
 ; RUN: bugpoint -load %llvmshlibdir/BugpointPasses%shlibext %s -output-prefix %t -bugpoint-crashfuncattr -silence-passes
-; RUN: llvm-dis %t-reduced-simplified.bc -o - | FileCheck %s
+; RUN: llvm-dis %t-reduced-simplified.bc -o - | FileCheck -check-prefixes=ALL,ENABLED %s
+; RUN: bugpoint -disable-attribute-remove -load %llvmshlibdir/BugpointPasses%shlibext %s -output-prefix %t -bugpoint-crashfuncattr -silence-passes
+; RUN: llvm-dis %t-reduced-simplified.bc -o - | FileCheck -check-prefixes=ALL,DISABLED %s
+
 ; REQUIRES: plugins
 
-; CHECK: f() #[[ATTRS:[0-9]+]]
+; ALL: f() #[[ATTRS:[0-9]+]]
 define void @f() #0 {
   ret void
 }
 
-; CHECK: attributes #[[ATTRS]] = { "bugpoint-crash" }
-attributes #0 = { noinline "bugpoint-crash" "no-frame-pointer-elim-non-leaf" }
+; ENABLED: attributes #[[ATTRS]] = { "bugpoint-crash" }
+; DISABLED: attributes #[[ATTRS]] = { noinline "bugpoint-crash" "no-frame-pointer-elim-non-leaf" }
+attributes #0 = { noinline "bugpoint-crash" "no-frame-pointer-elim-non-leaf" }
\ No newline at end of file

diff  --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp
index 6e9563044365..167b6a2ffc0f 100644
--- a/llvm/tools/bugpoint/CrashDebugger.cpp
+++ b/llvm/tools/bugpoint/CrashDebugger.cpp
@@ -44,6 +44,10 @@ cl::opt<bool> NoGlobalRM("disable-global-remove",
                          cl::desc("Do not remove global variables"),
                          cl::init(false));
 
+cl::opt<bool> NoAttributeRM("disable-attribute-remove",
+                         cl::desc("Do not remove function attributes"),
+                         cl::init(false));
+
 cl::opt<bool> ReplaceFuncsWithNull(
     "replace-funcs-with-null",
     cl::desc("When stubbing functions, replace all uses will null"),
@@ -1203,36 +1207,38 @@ static Error DebugACrash(BugDriver &BD, BugTester TestFn) {
       BD.EmitProgressBitcode(BD.getProgram(), "reduced-function");
   }
 
-  // For each remaining function, try to reduce that function's attributes.
-  std::vector<std::string> FunctionNames;
-  for (Function &F : BD.getProgram())
-    FunctionNames.push_back(F.getName());
+  if (!NoAttributeRM) {
+    // For each remaining function, try to reduce that function's attributes.
+    std::vector<std::string> FunctionNames;
+    for (Function &F : BD.getProgram())
+      FunctionNames.push_back(F.getName());
 
-  if (!FunctionNames.empty() && !BugpointIsInterrupted) {
-    outs() << "\n*** Attempting to reduce the number of function attributes in "
-              "the testcase\n";
+    if (!FunctionNames.empty() && !BugpointIsInterrupted) {
+      outs() << "\n*** Attempting to reduce the number of function attributes"
+                " in the testcase\n";
 
-    unsigned OldSize = 0;
-    unsigned NewSize = 0;
-    for (std::string &Name : FunctionNames) {
-      Function *Fn = BD.getProgram().getFunction(Name);
-      assert(Fn && "Could not find funcion?");
+      unsigned OldSize = 0;
+      unsigned NewSize = 0;
+      for (std::string &Name : FunctionNames) {
+        Function *Fn = BD.getProgram().getFunction(Name);
+        assert(Fn && "Could not find funcion?");
 
-      std::vector<Attribute> Attrs;
-      for (Attribute A : Fn->getAttributes().getFnAttributes())
-        Attrs.push_back(A);
+        std::vector<Attribute> Attrs;
+        for (Attribute A : Fn->getAttributes().getFnAttributes())
+          Attrs.push_back(A);
 
-      OldSize += Attrs.size();
-      Expected<bool> Result =
+        OldSize += Attrs.size();
+        Expected<bool> Result =
           ReduceCrashingFunctionAttributes(BD, Name, TestFn).reduceList(Attrs);
-      if (Error E = Result.takeError())
-        return E;
+        if (Error E = Result.takeError())
+          return E;
 
-      NewSize += Attrs.size();
-    }
+        NewSize += Attrs.size();
+      }
 
-    if (OldSize < NewSize)
-      BD.EmitProgressBitcode(BD.getProgram(), "reduced-function-attributes");
+      if (OldSize < NewSize)
+        BD.EmitProgressBitcode(BD.getProgram(), "reduced-function-attributes");
+    }
   }
 
   // Attempt to change conditional branches into unconditional branches to


        


More information about the llvm-commits mailing list