[LLVMdev] DebugIR pass fails with an assert

Konstantin Olkhovskiy lupus at oxnull.net
Sun Sep 22 06:47:36 PDT 2013


The following patch seems to fix the problem for me. Gdb is able
to see and traverse the IR.

diff --git a/lib/IR/Type.cpp b/lib/IR/Type.cpp
index 46c61fc..ec9b1a0 100644
--- a/lib/IR/Type.cpp
+++ b/lib/IR/Type.cpp
@@ -578,7 +578,7 @@ bool StructType::isSized() const {
 }

 StringRef StructType::getName() const {
-  assert(!isLiteral() && "Literal structs never have names");
+  if(isLiteral()) return StringRef();
   if (SymbolTableEntry == 0) return StringRef();

   return ((StringMapEntry<StructType*> *)SymbolTableEntry)->getKey();


Not sure if this workaround is generic enough for all use cases though.


2013/9/22 Konstantin Olkhovskiy <lupus at oxnull.net>

> Hi List,
>
> My IR compiles fine and runs. I've tried to add DebugIR pass so
> as to be able to debug and profile it (since source is an SQL query
> all that I can debug and profile is IR itself).
>
> When I tried to add it to pass manager I got the following assert:
>
> Program received signal SIGABRT, Aborted.
> 0x00007ffff3fe4425 in __GI_raise (sig=<optimized out>) at
> ../nptl/sysdeps/unix/sysv/linux/raise.c:64
> 64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
> (gdb) bt
> #0  0x00007ffff3fe4425 in __GI_raise (sig=<optimized out>)
>     at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
> #1  0x00007ffff3fe7b8b in __GI_abort () at abort.c:91
> #2  0x00007ffff3fdd0ee in __assert_fail_base (fmt=<optimized out>,
>     assertion=0x7fffef586208 "!isLiteral() && \"Literal structs never have
> names\"",
>     file=0x7fffef585fb0 "/home/kolkhovskiy/3rdparty/llvm/lib/IR/Type.cpp",
> line=<optimized out>,
>     function=<optimized out>) at assert.c:94
> #3  0x00007ffff3fdd192 in __GI___assert_fail (
>     assertion=0x7fffef586208 "!isLiteral() && \"Literal structs never have
> names\"",
>     file=0x7fffef585fb0 "/home/kolkhovskiy/3rdparty/llvm/lib/IR/Type.cpp",
> line=581,
>     function=0x7fffef589380 "llvm::StringRef llvm::StructType::getName()
> const") at assert.c:103
> #4  0x00007fffef4e1755 in llvm::StructType::getName (this=0x6562c0)
>     at /home/kolkhovskiy/3rdparty/llvm/lib/IR/Type.cpp:581
> #5  0x00007fffef4e0030 in llvm::Type::getStructName (this=0x6562c0)
>     at /home/kolkhovskiy/3rdparty/llvm/lib/IR/Type.cpp:195
> #6  0x00007ffff2ec85b9 in (anonymous
> namespace)::DIUpdater::getOrCreateType (this=0x7fffffffd530,
>     T=0x6562c0) at
> /home/kolkhovskiy/3rdparty/llvm/lib/Transforms/Instrumentation/DebugIR.cpp:387
> #7  0x00007ffff2ec8a1d in (anonymous
> namespace)::DIUpdater::getOrCreateType (this=0x7fffffffd530,
>     T=0x6565e0) at
> /home/kolkhovskiy/3rdparty/llvm/lib/Transforms/Instrumentation/DebugIR.cpp:415
> #8  0x00007ffff2ec88db in (anonymous
> namespace)::DIUpdater::getOrCreateType (this=0x7fffffffd530,
>     T=0x656630) at
> /home/kolkhovskiy/3rdparty/llvm/lib/Transforms/Instrumentation/DebugIR.cpp:406
> #9  0x00007ffff2ec8cf0 in (anonymous
> namespace)::DIUpdater::createFunctionSignature (
>     this=0x7fffffffd530, Func=0x672a10)
>     at
> /home/kolkhovskiy/3rdparty/llvm/lib/Transforms/Instrumentation/DebugIR.cpp:441
> #10 0x00007ffff2ec729f in (anonymous namespace)::DIUpdater::visitFunction
> (this=0x7fffffffd530, F=...)
>     at
> /home/kolkhovskiy/3rdparty/llvm/lib/Transforms/Instrumentation/DebugIR.cpp:196
> #11 0x00007ffff2eca2cc in llvm::InstVisitor<{anonymous}::DIUpdater,
> void>::visit(llvm::Function &) (
>     this=0x7fffffffd530, F=...) at
> /home/kolkhovskiy/3rdparty/llvm/include/llvm/InstVisitor.h:102
> #12 0x00007ffff2eca1d7 in llvm::InstVisitor<{anonymous}::DIUpdater,
> void>::visit<llvm::ilist_iterator<llvm::Function>
> >(llvm::ilist_iterator<llvm::Function>,
> llvm::ilist_iterator<llvm::Function>) (
>     this=0x7fffffffd530, Start=..., End=...)
>     at /home/kolkhovskiy/3rdparty/llvm/include/llvm/InstVisitor.h:92
> #13 0x00007ffff2eca0a6 in llvm::InstVisitor<{anonymous}::DIUpdater,
> void>::visit(llvm::Module &) (
>     this=0x7fffffffd530, M=...) at
> /home/kolkhovskiy/3rdparty/llvm/include/llvm/InstVisitor.h:99
> #14 0x00007ffff2ec9f97 in llvm::InstVisitor<{anonymous}::DIUpdater,
> void>::visit(llvm::Module *) (
>     this=0x7fffffffd530, M=0x626360) at
> /home/kolkhovskiy/3rdparty/llvm/include/llvm/InstVisitor.h:111
> #15 0x00007ffff2ec70dc in (anonymous namespace)::DIUpdater::DIUpdater
> (this=0x7fffffffd530, M=...,
>     Filename=..., Directory=..., DisplayM=0x0, VMap=0x0)
>     at
> /home/kolkhovskiy/3rdparty/llvm/lib/Transforms/Instrumentation/DebugIR.cpp:178
> #16 0x00007ffff2ec9a96 in llvm::DebugIR::createDebugInfo (this=0x67e0e0,
> M=..., DisplayM=...)
>     at
> /home/kolkhovskiy/3rdparty/llvm/lib/Transforms/Instrumentation/DebugIR.cpp:564
> #17 0x00007ffff2ec9c32 in llvm::DebugIR::runOnModule (this=0x67e0e0, M=...)
>     at
> /home/kolkhovskiy/3rdparty/llvm/lib/Transforms/Instrumentation/DebugIR.cpp:590
> #18 0x00007fffef4cb5e7 in llvm::MPPassManager::runOnModule (this=0x67cc60,
> M=...)
>     at /home/kolkhovskiy/3rdparty/llvm/lib/IR/PassManager.cpp:1608
> #19 0x00007fffef4cbbfc in llvm::PassManagerImpl::run (this=0x67c970, M=...)
>     at /home/kolkhovskiy/3rdparty/llvm/lib/IR/PassManager.cpp:1703
> #20 0x00007fffef4cbe0f in llvm::PassManager::run (this=0x67e0c0, M=...)
>     at /home/kolkhovskiy/3rdparty/llvm/lib/IR/PassManager.cpp:1738
> #21 0x00007fffef3d73b8 in LLVMRunPassManager (PM=0x67e0c0, M=0x626360)
>     at /home/kolkhovskiy/3rdparty/llvm/lib/IR/Core.cpp:2535
> <more frames follow, but belong to my own software>
>
> What does "Literal structs never have names" mean? Do i have a problem
> somewhere in the IR?
>
> --
> Regards,
> Konstantin
>



-- 
Regards,
Konstantin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130922/407dd531/attachment.html>


More information about the llvm-dev mailing list