<div dir="ltr">This assertion has found many bugs in LLVM, and many of them have been fixed since LLVM 3.6. I don't know of any good way to work around this assertion without getting a new compiler. You could try building 3.6.2 without assertions. LLVM will not crash immediately if you bypass this particular assertion, it will just generate bogus debug info somewhere.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 31, 2016 at 9:57 AM, Shehbaz Jaffer via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Short version --> adding debug flags leads to clang++ error (shown<br>
below). without adding debug flags, compilation is successful.<br>
<br>
Longer version--><br>
<br>
I am doing the follwing things in my project in order to debug it:<br>
<br>
1. Compiling an llvm code pass.cpp with clang++ -ggdb that consists of<br>
some optimization passes on my test.c file - I create an so file from<br>
this - called pass.so.<br>
<br>
2. I create a .bc file of the optimization pass - using clang++<br>
-emit-llvm. lets call it pass.bc.<br>
<br>
3. Compiling and creating an executable of my my test.c file, with -g<br>
flag - lets call it test<br>
<br>
4. Creating a .bc of my test.c file - lets call it test.bc<br>
<br>
5. running some optimization passes on my test.bc file, with the<br>
test.so file created in step 1. let us call the output file<br>
test.inst.bc<br>
<br>
6. linking the optimized test.inst.bc file in step 4 with the llvm .bc<br>
file generated in step 1. Let us call it  test.inst2.bc<br>
<br>
7. finally compiling the linked file using clang++ -c test.inst2.bc.<br>
<br>
I get the following error :<br>
<br>
clang-3.6: /home/shehbaz/courses/ece1781/project/fslice/llvm/lib/CodeGen/LexicalScopes.cpp:179:<br>
llvm::LexicalScope*<br>
llvm::LexicalScopes::getOrCreateRegularScope(llvm::MDNode*): Assertion<br>
`DISubprogram(Scope).describes(MF->getFunction())' failed.<br>
0  clang-3.6       0x00000000024cb8c4 llvm::sys::PrintStackTrace(_IO_FILE*) + 53<br>
1  clang-3.6       0x00000000024cbb6e<br>
2  clang-3.6       0x00000000024ca661<br>
3  libpthread.so.0 0x00007fa7bd39ad10<br>
4  libc.so.6       0x00007fa7bc5ad267 gsignal + 55<br>
5  libc.so.6       0x00007fa7bc5aeeca abort + 362<br>
6  libc.so.6       0x00007fa7bc5a603d<br>
7  libc.so.6       0x00007fa7bc5a60f2<br>
8  clang-3.6       0x0000000001f89b97<br>
llvm::LexicalScopes::getOrCreateRegularScope(llvm::MDNode*) + 703<br>
9  clang-3.6       0x0000000001f890e9<br>
llvm::LexicalScopes::getOrCreateLexicalScope(llvm::DebugLoc) + 191<br>
10 clang-3.6       0x0000000001f88adf<br>
llvm::LexicalScopes::extractLexicalScopes(llvm::SmallVectorImpl<std::pair<llvm::MachineInstr<br>
const*, llvm::MachineInstr const*> >&,<br>
llvm::DenseMap<llvm::MachineInstr const*, llvm::LexicalScope*,<br>
llvm::DenseMapInfo<llvm::MachineInstr const*>,<br>
llvm::detail::DenseMapPair<llvm::MachineInstr const*,<br>
llvm::LexicalScope*> >&) + 459<br>
11 clang-3.6       0x0000000001f88899<br>
llvm::LexicalScopes::initialize(llvm::MachineFunction const&) + 127<br>
12 clang-3.6       0x000000000282c753<br>
llvm::DwarfDebug::beginFunction(llvm::MachineFunction const*) + 257<br>
13 clang-3.6       0x0000000002812cf3<br>
llvm::AsmPrinter::EmitFunctionHeader() + 1099<br>
14 clang-3.6       0x00000000019b5123<br>
15 clang-3.6       0x0000000001dd0473<br>
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 95<br>
16 clang-3.6       0x00000000020e0def<br>
llvm::FPPassManager::runOnFunction(llvm::Function&) + 305<br>
17 clang-3.6       0x00000000020e0f81<br>
llvm::FPPassManager::runOnModule(llvm::Module&) + 99<br>
18 clang-3.6       0x00000000020e12c3<br>
19 clang-3.6       0x00000000020e1986<br>
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 250<br>
20 clang-3.6       0x00000000020e1ba7<br>
llvm::legacy::PassManager::run(llvm::Module&) + 39<br>
21 clang-3.6       0x0000000002a6da1c<br>
22 clang-3.6       0x0000000002a6db2d<br>
clang::EmitBackendOutput(clang::DiagnosticsEngine&,<br>
clang::CodeGenOptions const&, clang::TargetOptions const&,<br>
clang::LangOptions const&, llvm::StringRef, llvm::Module*,<br>
clang::BackendAction, llvm::raw_ostream*) + 173<br>
23 clang-3.6       0x0000000002a541a4<br>
clang::CodeGenAction::ExecuteAction() + 1408<br>
24 clang-3.6       0x00000000026e4be4 clang::FrontendAction::Execute() + 154<br>
25 clang-3.6       0x00000000026ab864<br>
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 788<br>
26 clang-3.6       0x000000000280a257<br>
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1072<br>
27 clang-3.6       0x000000000125833e cc1_main(llvm::ArrayRef<char<br>
const*>, char const*, void*) + 776<br>
28 clang-3.6       0x000000000125022f<br>
29 clang-3.6       0x0000000001250852 main + 1082<br>
30 libc.so.6       0x00007fa7bc598a40 __libc_start_main + 240<br>
31 clang-3.6       0x000000000124cec9 _start + 41<br>
Stack dump:<br>
0. Program arguments:<br>
/home/shehbaz/courses/ece1781/project/fslice/llvm/build/bin/clang-3.6<br>
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all<br>
-disable-free -main-file-name testfs.opt.bc -mrelocation-model static<br>
-mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose<br>
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu<br>
x86-64 -dwarf-column-info -coverage-file<br>
/home/shehbaz/courses/ece1781/project/fslice/./testfs/testfs.opt.o<br>
-resource-dir /home/shehbaz/courses/ece1781/project/fslice/llvm/build/bin/../lib/clang/3.6.2<br>
-fdebug-compilation-dir /home/shehbaz/courses/ece1781/project/fslice<br>
-ferror-limit 19 -fmessage-length 181 -mstackrealign<br>
-fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o<br>
./testfs/testfs.opt.o -x ir ./testfs/testfs.opt.bc<br>
1. Code generation<br>
2. Running pass 'Function Pass Manager' on module './testfs/testfs.opt.bc'.<br>
3. Running pass 'X86 Assembly / Object Emitter' on function '@main'<br>
clang-3.6: error: unable to execute command: Aborted (core dumped)<br>
clang-3.6: error: clang frontend command failed due to signal (use -v<br>
to see invocation)<br>
clang version 3.6.2 (tags/RELEASE_362/final)<br>
Target: x86_64-unknown-linux-gnu<br>
Thread model: posix<br>
clang-3.6: note: diagnostic msg: PLEASE submit a bug report to<br>
<a href="http://llvm.org/bugs/" rel="noreferrer" target="_blank">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed<br>
source, and associated run script.<br>
clang-3.6: note: diagnostic msg: Error generating preprocessed<br>
source(s) - no preprocessable inputs.<br>
<br>
<br>
Note that the program runs perfectly fine, if I do not add the debug symbols in<br>
<br>
step 1 (-ggdb)<br>
step 3 ( -g) <--- having this or running program without it does not<br>
cause issues<br>
step 7 (-ggdb)<br>
<br>
Please let me know if there is another way to debug the code. I wish<br>
to use gdb, not lldb, hence the -ggdb flag. If I use -g flag, that<br>
also reports the same error while compiling the code. I looked up the<br>
error message and it seems there is some other cause for the same<br>
error trace:<br>
<br>
<a href="https://llvm.org/bugs/show_bug.cgi?id=22051" rel="noreferrer" target="_blank">https://llvm.org/bugs/show_bug.cgi?id=22051</a><br>
<br>
Thank you,<br>
Shehbaz<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div>