[llvm] 055aeb5 - [Bugpoint] Do not create illegal function attribute combos
David Greene via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 16 08:35:49 PST 2019
Author: David Greene
Date: 2019-12-16T10:32:35-06:00
New Revision: 055aeb5275153ee61ccd59cab2987fdcaca73756
URL: https://github.com/llvm/llvm-project/commit/055aeb5275153ee61ccd59cab2987fdcaca73756
DIFF: https://github.com/llvm/llvm-project/commit/055aeb5275153ee61ccd59cab2987fdcaca73756.diff
LOG: [Bugpoint] Do not create illegal function attribute combos
If a function requires optnone to trigger a crash, it must also have noline,
otherwise it will fail a verifier check.
Differential revision: https://reviews.llvm.org/D69522
Added:
llvm/test/BugPoint/attr-crash.ll
Modified:
llvm/tools/bugpoint/CrashDebugger.cpp
Removed:
################################################################################
diff --git a/llvm/test/BugPoint/attr-crash.ll b/llvm/test/BugPoint/attr-crash.ll
new file mode 100644
index 000000000000..7032e86a5cf3
--- /dev/null
+++ b/llvm/test/BugPoint/attr-crash.ll
@@ -0,0 +1,16 @@
+; RUN: bugpoint -load %llvmshlibdir/BugpointPasses%shlibext %s -output-prefix %t -bugpoint-crashfuncattr 2>&1 | FileCheck %s
+; REQUIRES: plugins
+;
+; ModuleID = 'attr-crash.ll'
+source_filename = "test.c"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local i32 @main(i32 %argc, i8** %argv) local_unnamed_addr #0 {
+ ret i32 0
+}
+
+; CHECK-NOT: Attribute 'optnone' requires 'noinline'!
+attributes #0 = { noinline nounwind optnone uwtable "bugpoint-crash" }
diff --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp
index 167b6a2ffc0f..aa88a06a6df0 100644
--- a/llvm/tools/bugpoint/CrashDebugger.cpp
+++ b/llvm/tools/bugpoint/CrashDebugger.cpp
@@ -364,6 +364,11 @@ bool ReduceCrashingFunctionAttributes::TestFuncAttrs(
// Set this new list of attributes on the function.
F->setAttributes(NewAttrs);
+ // If the attribute list includes "optnone" we need to make sure it also
+ // includes "noinline" otherwise we will get a verifier failure.
+ if (F->hasFnAttribute(Attribute::OptimizeNone))
+ F->addFnAttr(Attribute::NoInline);
+
// Try running on the hacked up program...
if (TestFn(BD, M.get())) {
BD.setNewProgram(std::move(M)); // It crashed, keep the trimmed version...
More information about the llvm-commits
mailing list