(original) (raw)
Hi,
I have problem with IRBuilderBase::InsertPointGuard class that simply does not work in the release build of my project. The class does not restore the IRBuilder's insert point correctly when NDEBUG macro is set. It happens on OSX system only, trunk version of the LLVM built with brew.
I suspect it is the ABI problem. InsertPointGuard uses AssertingVT for debug builds.
LLDB gets confused also. The first listing shows that the instance of InsertPointGuard is messed up:
96 auto check = \_builder.GetInsertBlock();
97 {
98 llvm::IRBuilderBase::InsertPointGuard guard{\_builder};
-> 99 \_builder.SetInsertPoint(checkBB);
100 }
101
102 if (\_builder.GetInsertBlock() != check)
(lldb) p \_builder
(llvm::IRBuilder >) 4=</font></div><div><fontface="monospace,monospace">llvm::IRBuilderBase=</font></div><div><fontface="monospace,monospace">CurDbgLocation=</font></div><div><fontface="monospace,monospace">Loc=</font></div><div><fontface="monospace,monospace">Ref=</font></div><div><fontface="monospace,monospace">MD=0x0000000000000000</font></div><div><fontface="monospace,monospace"></font></div><div><fontface="monospace,monospace"></font></div><div><fontface="monospace,monospace"></font></div><div><fontface="monospace,monospace">BB=0x000000010642ecf0</font></div><div><fontface="monospace,monospace">InsertPt=</font></div><div><fontface="monospace,monospace">NodePtr=0x000000010642ed00</font></div><div><fontface="monospace,monospace"></font></div><div><fontface="monospace,monospace">Context=0x000000010642d170</font></div><div><fontface="monospace,monospace">DefaultFPMathTag=0x0000000000000000</font></div><div><fontface="monospace,monospace">FMF=(Flags=0)</font></div><div><fontface="monospace,monospace"></font></div><div><fontface="monospace,monospace">Folder=</font></div><div><fontface="monospace,monospace"></font></div><div><fontface="monospace,monospace">(lldb)pguard</font></div><div><fontface="monospace,monospace">(llvm::IRBuilderBase::InsertPointGuard)4 = {</font></div><div><font face="monospace, monospace"> llvm::IRBuilderBase = {</font></div><div><font face="monospace, monospace"> CurDbgLocation = {</font></div><div><font face="monospace, monospace"> Loc = {</font></div><div><font face="monospace, monospace"> Ref = {</font></div><div><font face="monospace, monospace"> MD = 0x0000000000000000</font></div><div><font face="monospace, monospace"> }</font></div><div><font face="monospace, monospace"> }</font></div><div><font face="monospace, monospace"> }</font></div><div><font face="monospace, monospace"> BB = 0x000000010642ecf0</font></div><div><font face="monospace, monospace"> InsertPt = {</font></div><div><font face="monospace, monospace"> NodePtr = 0x000000010642ed00</font></div><div><font face="monospace, monospace"> }</font></div><div><font face="monospace, monospace"> Context = 0x000000010642d170</font></div><div><font face="monospace, monospace"> DefaultFPMathTag = 0x0000000000000000</font></div><div><font face="monospace, monospace"> FMF = (Flags = 0)</font></div><div><font face="monospace, monospace"> }</font></div><div><font face="monospace, monospace"> Folder = {}</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace">(lldb) p guard</font></div><div><font face="monospace, monospace">(llvm::IRBuilderBase::InsertPointGuard) 4=</font></div><div><fontface="monospace,monospace">llvm::IRBuilderBase=</font></div><div><fontface="monospace,monospace">CurDbgLocation=</font></div><div><fontface="monospace,monospace">Loc=</font></div><div><fontface="monospace,monospace">Ref=</font></div><div><fontface="monospace,monospace">MD=0x0000000000000000</font></div><div><fontface="monospace,monospace"></font></div><div><fontface="monospace,monospace"></font></div><div><fontface="monospace,monospace"></font></div><div><fontface="monospace,monospace">BB=0x000000010642ecf0</font></div><div><fontface="monospace,monospace">InsertPt=</font></div><div><fontface="monospace,monospace">NodePtr=0x000000010642ed00</font></div><div><fontface="monospace,monospace"></font></div><div><fontface="monospace,monospace">Context=0x000000010642d170</font></div><div><fontface="monospace,monospace">DefaultFPMathTag=0x0000000000000000</font></div><div><fontface="monospace,monospace">FMF=(Flags=0)</font></div><div><fontface="monospace,monospace"></font></div><div><fontface="monospace,monospace">Folder=</font></div><div><fontface="monospace,monospace"></font></div><div><fontface="monospace,monospace">(lldb)pguard</font></div><div><fontface="monospace,monospace">(llvm::IRBuilderBase::InsertPointGuard)5 = {
Builder = 0x00007fff5fbf46d8
Block = {
ThePtr = 0x0000000107800398
}
Point = {
NodePtr = 0x0000000000000000
}
DbgLoc = {
Loc = {
Ref = {
MD = 0x000000010642ecf0
}
}
}
}
Moreover, if I start printing the guard from InsertPointGuard constructor it shows different data layout. LLDB also crashes after step out and printing the guard again.
195 public:
196 InsertPointGuard(IRBuilderBase &B)
197 : Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()),
-> 198 DbgLoc(B.getCurrentDebugLocation()) {}
199
200 \~InsertPointGuard() {
201 Builder.restoreIP(InsertPoint(Block, Point));
(lldb) p \*this
(llvm::IRBuilderBase::InsertPointGuard) $6 = {
Builder = 0x00007fff5fbf4440
Block = {
llvm::ValueHandleBase = {
PrevPair = (Value = 4337803886)
Next = 0x000000010615b0a8
V = 0x000000010615b170
}
}
Point = {
NodePtr = 0x000000010615b140
}
DbgLoc = {
Loc = {
Ref = {
MD = 0x000000010324444b
}
}
}
}
(lldb) n
Process 1498 stopped
\* thread #1: tid = 0x493aa8, 0x0000000102920b22 libevmjit.0.0.dylib\`dev::eth::jit::test(\_builder=0x00007fff5fbf46d8) + 258 at RuntimeManager.cpp:99, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x0000000102920b22 libevmjit.0.0.dylib\`dev::eth::jit::test(\_builder=0x00007fff5fbf46d8) + 258 at RuntimeManager.cpp:99
96 auto check = \_builder.GetInsertBlock();
97 {
98 llvm::IRBuilderBase::InsertPointGuard guard{\_builder};
-> 99 \_builder.SetInsertPoint(checkBB);
100 }
101
102 if (\_builder.GetInsertBlock() != check)
(lldb) p guard
Assertion failed: (field\_idx < record\_layout.getFieldCount()), function GetChildClangTypeAtIndex, file /SourceCache/lldb/lldb-320.4.156/source/Symbol/ClangASTType.cpp, line 6615.
Abort trap: 6
It's hard to create a small executable where the problem can be reproduced.
Cheers,
- Paweł Bylica