[PATCH] D69522: [Bugpoint] Do not create illegal function attribute combos
David Greene via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 28 11:42:29 PDT 2019
greened created this revision.
greened added reviewers: chandlerc, modocache, dblaikie, espindola, vsk, spatel, RKSimon, milseman, aprantl, mehdi_amini, bogner, majnemer, sebpop, reames, jlebar, dexonsmith, MatzeB, hfinkel.
greened added a project: LLVM.
Herald added a subscriber: llvm-commits.
If a function requires optnone to trigger a crash, it must also have noline,
otherwise it will fail a verifier check.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D69522
Files:
llvm/test/BugPoint/attr-crash.ll
llvm/tools/bugpoint/CrashDebugger.cpp
Index: llvm/tools/bugpoint/CrashDebugger.cpp
===================================================================
--- llvm/tools/bugpoint/CrashDebugger.cpp
+++ llvm/tools/bugpoint/CrashDebugger.cpp
@@ -359,6 +359,11 @@
// 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...
Index: llvm/test/BugPoint/attr-crash.ll
===================================================================
--- /dev/null
+++ 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" }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69522.226722.patch
Type: text/x-patch
Size: 1498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191028/552697a9/attachment.bin>
More information about the llvm-commits
mailing list