<div dir="ltr">Thanks David. I will try using an asserts build.<br>I injected the call instruction before an instruction which has metadata. This fixes the issue.<br><br>- Pankaj<br><br><br></div><br><div class="gmail_quote">On Wed, May 20, 2015 at 2:43 AM David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Have you tried an asserts build of clang/llvm? If you're doing LLVM development you should probably be using an asserts build.<br><br>I would guess you're hitting the issue where, if you have debug info for a function, any call instructions inside that function must themselves have a debug location (that !dbg thing). Otherwise bad debug info (and assertions to ensure that badness doesn't happen) happens.<br><br>- David<br><div class="gmail_extra"><br><div class="gmail_quote"></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, May 19, 2015 at 1:15 AM, Pankaj Kohli <span dir="ltr"><<a href="mailto:pankaj208@gmail.com" target="_blank">pankaj208@gmail.com</a>></span> wrote:<br></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I am learning to write LLVM modules. I am using IRBuilder to insert calls to an existing function. The call is to be inserted at a random location in every function in the code. The call does get inserted, however, the module crashes later (after doFinalization()). The crash happens only sometimes, not always. </div><div><br></div><div>These are the kind of instructions that I see in the generated code.</div><div> %callins = call void @myfunc(), !dbg !285</div><div> %callins = call void @myfunc()<br></div><div><br></div><div>The stack trace shows the crash has something to do with debug information. Do I need to add metadata or debug info to the newly added call instruction? Any pointers on how I can do that?<br></div><div><br></div><div>Here is the code snippet and the stack trace:</div><div><br></div><div><div>IRBuilder<> Builder(ins); // to be inserted before ins</div><div>CallInst *call = Builder.CreateCall(func, "callins"); // call to func</div></div><div><br></div><div><br></div><div><div>0 clang 0x0000000001492ec2 llvm::sys::PrintStackTrace(_IO_FILE*) + 34</div><div>1 clang 0x0000000001490f61</div><div>2 libpthread.so.0 0x00002b33bd0ee340</div><div>3 clang 0x00000000016a43a6 llvm::DwarfUnit::addString(llvm::DIE&, llvm::dwarf::Attribute, llvm::StringRef) + 22</div><div>4 clang 0x00000000016c2003 llvm::DwarfCompileUnit::applyVariableAttributes(llvm::DbgVariable const&, llvm::DIE&) + 915</div><div>5 clang 0x000000000168bdfe llvm::DwarfDebug::finishVariableDefinitions() + 270</div><div>6 clang 0x0000000001690424 llvm::DwarfDebug::finalizeModuleInfo() + 52</div><div>7 clang 0x000000000169c4a8 llvm::DwarfDebug::endModule() + 40</div><div>8 clang 0x00000000016850f7 llvm::AsmPrinter::doFinalization(llvm::Module&) + 551</div><div>9 clang 0x00000000011befe5 llvm::FPPassManager::doFinalization(llvm::Module&) + 69</div><div>10 clang 0x00000000011ca40d llvm::legacy::PassManagerImpl::run(llvm::Module&) + 813</div><div>11 clang 0x0000000001837fad clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) + 1629</div><div>12 clang 0x000000000182a47f</div><div>13 clang 0x0000000001bdf043 clang::ParseAST(clang::Sema&, bool, bool) + 483</div><div>14 clang 0x0000000001603ba6 clang::FrontendAction::Execute() + 118</div><div>15 clang 0x00000000015e47b8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 280</div><div>16 clang 0x0000000001673b41 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1921</div><div>17 clang 0x0000000000820358 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 1320</div><div>18 clang 0x00000000007fceaa main + 8298</div><div>19 libc.so.6 0x00002b33bdd56ec5 __libc_start_main + 245</div><div>20 clang 0x000000000081e5d9</div></div><div><br></div><div>Any help is appreciated.</div><div><br></div><div>Thanks,</div><div>Pankaj</div><div><br></div><div><br></div></div>
<br></blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div>