llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Compiler crash with -fprofile-instr-use at -O0

Open rlougher opened this issue 10 years ago • 4 comments

Bugzilla Link 31209
Resolution FIXED
Resolved on Dec 02, 2016 16:56
Version trunk
OS Linux
Attachments crashdump
CC @gregbedwell,@hfinkel,@vedantk

Extended Description

$ clang --version clang version 4.0.0 (trunk 288143)

Reduced test-case:

$ cat foo.cpp void fn1(void) attribute((noreturn)); void foo(void) {fn1(); }

Text-based IR profile:

$ cat profile.txt

IR level Instrumentation Flag

:ir _Z3foov

Func Hash:

12884901887

Num Counters:

1

Counter Values:

0

Steps to reproduce crash:

$ llvm-profdata merge profile.txt --output=out.profdata $ clang foo.cpp -O0 -c -fprofile-instr-use=out.profdata

#​0 0x000000000367cfc7 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /llvm/lib/Support/Unix/Signals.inc:402:0 ...

(crash dump attached)

The crash does not occur at -O1 or -O2.

rlougher avatar Nov 29 '16 20:11 rlougher

Fix was committed as of r288528.

llvmbot avatar Dec 03 '16 00:12 llvmbot

https://reviews.llvm.org/D27280

llvmbot avatar Nov 30 '16 23:11 llvmbot

This is caused by the dead BB in the function. We use a spanning tree to find the BB (reachable from entry) to set the auxiliary data structure. But we use Function iterator to when setting the BB count. and we null pointer deference for the unreachable BB.

Someone has reported similiar issue before. I will work on a fix for this.

@​vsk, changing hash will result in a hash mismatch and we will reject the profile.

thanks,

-Rong

llvmbot avatar Nov 30 '16 20:11 llvmbot

This is interesting. The crash is suppressed when I use alternate hash values (e.g 0, 1, or 0x2ffffffe). I wonder why it needs to be 0x2fffffff.

Rong, it seems that you added this assert in r255132 (getBBInfo, file ../lib/Transforms/Instrumentation/CFGMST.h, line 77). Mind taking a look?

vedantk avatar Nov 30 '16 02:11 vedantk