[LLVMdev] Problem with InsertPointGuard ABI? (original) (raw)

Paweł Bylica chfast at gmail.com
Mon Jul 13 06:39:53 PDT 2015


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<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter >) $4 = { llvm::IRBuilderBase = { CurDbgLocation = { Loc = { Ref = { MD = 0x0000000000000000 } } } BB = 0x000000010642ecf0 InsertPt = { NodePtr = 0x000000010642ed00 } Context = 0x000000010642d170 DefaultFPMathTag = 0x0000000000000000 FMF = (Flags = 0) } Folder = {} } (lldb) p guard (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

It's hard to create a small executable where the problem can be reproduced.

Cheers,



More information about the llvm-dev mailing list