Created attachment 12039
An example of a problematic file
We've added some new pragmas to Clang. They are represented as a call to
llvm.var.annotation function in the IR. However, this sometimes leads to a
segfault in the "Global Variable Optimizer" pass. Weird thing is, that this
doesn't happen if you create the IR file using Clang with -O0 and then run it
through opt manually. After some experiments I'm almost certain the problem is
caused by Global Variable Optimizer's problem with the use of
llvm.var.annotation calls (or more specifically, it's global variable
parameters).
The attached file "getblk.c" is just an example, it won't work unless you have
implemented support for our pragmas.
0 clang 0x0000000002478e92 llvm::sys::PrintStackTrace(_IO_FILE*) + 34
1 clang 0x0000000002478a79
2 libpthread.so.0 0x00007fd54c0a5bd0
3 clang 0x000000000213745d
4 clang 0x0000000002137413
5 clang 0x00000000021378ee
llvm::GlobalStatus::analyzeGlobal(llvm::Value const*, llvm::GlobalStatus&) + 126
6 clang 0x00000000015a7a2f
7 clang 0x00000000015a8b15
8 clang 0x0000000002407e4f
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 863
9 clang 0x00000000009d7e0a
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions
const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::Module*,
clang::BackendAction, llvm::raw_ostream*) + 3546
10 clang 0x00000000009d55ff
11 clang 0x0000000000b617c2 clang::ParseAST(clang::Sema&, bool, bool)
+ 514
12 clang 0x00000000009d4501 clang::CodeGenAction::ExecuteAction() + 97
13 clang 0x0000000000842469 clang::FrontendAction::Execute() + 265
14 clang 0x000000000081fd15
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 357
15 clang 0x00000000008067ee
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1886
16 clang 0x0000000000800508 cc1_main(char const**, char const**, char
const*, void*) + 1208
17 clang 0x00000000007eb578 main + 712
18 libc.so.6 0x00007fd54b0a4ea5 __libc_start_main + 245
19 clang 0x00000000007ff39d
Stack dump:
0. Program arguments: /usr/local/bin/clang -cc1 -triple x86_64-unknown-linux-
gnu -emit-llvm -disable-free -main-file-name getblk.c -mrelocation-model static
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-
array -target-cpu x86-64 -target-linker-version 2.23.2 -momit-leaf-frame-
pointer -g -coverage-file /home/pavel/Plocha/Modely v Codalu a
MPEG2/testsuitedata/compiler/llvm-testsuite/test-suite/IntBenchmarks/mediabench-
mpeg2/mpeg2dec/reports-3.4 fixed/getblk.ll -resource-dir
/usr/local/bin/../lib/clang/3.4 -internal-isystem /usr/local/include -internal-
isystem /usr/local/bin/../lib/clang/3.4/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-
externc-isystem /usr/include -O3 -fdebug-compilation-dir
/home/pavel/Plocha/Modely v Codalu a MPEG2/testsuitedata/compiler/llvm-
testsuite/test-suite/IntBenchmarks/mediabench-mpeg2/mpeg2dec/reports-3.4 fixed -
ferror-limit 19 -fmessage-length 186 -mstackrealign -fobjc-runtime=gcc -
fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o
getblk.ll -x c ../getblk.c
1. <eof> parser at end of file
2. Per-module optimization passes
3. Running pass 'Global Variable Optimizer' on module '../getblk.c'.
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.4 (tags/RELEASE_34/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/getblk-05bee3.c
clang: note: diagnostic msg: /tmp/getblk-05bee3.sh
clang: note: diagnostic msg:
********************
getblk.rar
(58622 bytes, application/octet-stream)