Skip to content

Commit 055aeb5

Browse files
committed
[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
1 parent 69fcc6e commit 055aeb5

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

llvm/test/BugPoint/attr-crash.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; RUN: bugpoint -load %llvmshlibdir/BugpointPasses%shlibext %s -output-prefix %t -bugpoint-crashfuncattr 2>&1 | FileCheck %s
2+
; REQUIRES: plugins
3+
;
4+
; ModuleID = 'attr-crash.ll'
5+
source_filename = "test.c"
6+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
7+
target triple = "x86_64-unknown-linux-gnu"
8+
9+
10+
; Function Attrs: noinline nounwind optnone uwtable
11+
define dso_local i32 @main(i32 %argc, i8** %argv) local_unnamed_addr #0 {
12+
ret i32 0
13+
}
14+
15+
; CHECK-NOT: Attribute 'optnone' requires 'noinline'!
16+
attributes #0 = { noinline nounwind optnone uwtable "bugpoint-crash" }

llvm/tools/bugpoint/CrashDebugger.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,11 @@ bool ReduceCrashingFunctionAttributes::TestFuncAttrs(
364364
// Set this new list of attributes on the function.
365365
F->setAttributes(NewAttrs);
366366

367+
// If the attribute list includes "optnone" we need to make sure it also
368+
// includes "noinline" otherwise we will get a verifier failure.
369+
if (F->hasFnAttribute(Attribute::OptimizeNone))
370+
F->addFnAttr(Attribute::NoInline);
371+
367372
// Try running on the hacked up program...
368373
if (TestFn(BD, M.get())) {
369374
BD.setNewProgram(std::move(M)); // It crashed, keep the trimmed version...

0 commit comments

Comments
 (0)