<div dir="ltr">The layout of AssertingVH has depended on NDEBUG since 2009, which predates any of our efforts to make LLVM's ABI resilient to mismatched NDEBUG definitions between LLVM and its users.<div><br></div><div>For now, make sure your definition of NDEBUG matches LLVM's. In the long run, we could conceivably do something with LLVM_ENABLE_ABI_BREAKING_CHECKS to allow this mismatch.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 13, 2015 at 6:39 AM, Paweł Bylica <span dir="ltr"><<a href="mailto:chfast@gmail.com" target="_blank">chfast@gmail.com</a>></span> wrote:<br><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 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.</div><div><br></div><div>I suspect it is the ABI problem. InsertPointGuard uses AssertingVT for debug builds.</div><div><br></div><div>LLDB gets confused also. The first listing shows that the instance of InsertPointGuard is messed up:</div><div><br></div><div><div><font face="monospace, monospace">   96  <span style="white-space:pre-wrap">                </span>auto check = _builder.GetInsertBlock();</font></div><div><font face="monospace, monospace">   97  <span style="white-space:pre-wrap">         </span>{</font></div><div><font face="monospace, monospace">   98  <span style="white-space:pre-wrap">                       </span>llvm::IRBuilderBase::InsertPointGuard guard{_builder};</font></div><div><font face="monospace, monospace">-> 99  <span style="white-space:pre-wrap">                 </span>_builder.SetInsertPoint(checkBB);</font></div><div><font face="monospace, monospace">   100 <span style="white-space:pre-wrap">                </span>}</font></div><div><font face="monospace, monospace">   101 <span style="white-space:pre-wrap">        </span></font></div><div><font face="monospace, monospace">   102 <span style="white-space:pre-wrap">         </span>if (_builder.GetInsertBlock() != check)</font></div><div><font face="monospace, monospace">(lldb) p _builder</font></div><div><font face="monospace, monospace">(llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter<true> >) $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) $5 = {</font></div><div><font face="monospace, monospace">  Builder = 0x00007fff5fbf46d8</font></div><div><font face="monospace, monospace">  Block = {</font></div><div><font face="monospace, monospace">    ThePtr = 0x0000000107800398</font></div><div><font face="monospace, monospace">  }</font></div><div><font face="monospace, monospace">  Point = {</font></div><div><font face="monospace, monospace">    NodePtr = 0x0000000000000000</font></div><div><font face="monospace, monospace">  }</font></div><div><font face="monospace, monospace">  DbgLoc = {</font></div><div><font face="monospace, monospace">    Loc = {</font></div><div><font face="monospace, monospace">      Ref = {</font></div><div><font face="monospace, monospace">        MD = 0x000000010642ecf0</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">}</font></div></div><div><br></div><div>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.</div><div><br></div><div><div><font face="monospace, monospace">   195 <span style="white-space:pre-wrap">        </span>  public:</font></div><div><font face="monospace, monospace">   196 <span style="white-space:pre-wrap">       </span>    InsertPointGuard(IRBuilderBase &B)</font></div><div><font face="monospace, monospace">   197 <span style="white-space:pre-wrap">     </span>        : Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()),</font></div><div><font face="monospace, monospace">-> 198 <span style="white-space:pre-wrap"> </span>          DbgLoc(B.getCurrentDebugLocation()) {}</font></div><div><font face="monospace, monospace">   199 <span style="white-space:pre-wrap">    </span></font></div><div><font face="monospace, monospace">   200 <span style="white-space:pre-wrap"> </span>    ~InsertPointGuard() {</font></div><div><font face="monospace, monospace">   201 <span style="white-space:pre-wrap">      </span>      Builder.restoreIP(InsertPoint(Block, Point));</font></div><div><font face="monospace, monospace">(lldb) p *this</font></div><div><font face="monospace, monospace">(llvm::IRBuilderBase::InsertPointGuard) $6 = {</font></div><div><font face="monospace, monospace">  Builder = 0x00007fff5fbf4440</font></div><div><font face="monospace, monospace">  Block = {</font></div><div><font face="monospace, monospace">    llvm::ValueHandleBase = {</font></div><div><font face="monospace, monospace">      PrevPair = (Value = 4337803886)</font></div><div><font face="monospace, monospace">      Next = 0x000000010615b0a8</font></div><div><font face="monospace, monospace">      V = 0x000000010615b170</font></div><div><font face="monospace, monospace">    }</font></div><div><font face="monospace, monospace">  }</font></div><div><font face="monospace, monospace">  Point = {</font></div><div><font face="monospace, monospace">    NodePtr = 0x000000010615b140</font></div><div><font face="monospace, monospace">  }</font></div><div><font face="monospace, monospace">  DbgLoc = {</font></div><div><font face="monospace, monospace">    Loc = {</font></div><div><font face="monospace, monospace">      Ref = {</font></div><div><font face="monospace, monospace">        MD = 0x000000010324444b</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">}</font></div><div><font face="monospace, monospace">(lldb) n</font></div><div><font face="monospace, monospace">Process 1498 stopped</font></div><div><font face="monospace, monospace">* 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</font></div><div><font face="monospace, monospace">    frame #0: 0x0000000102920b22 libevmjit.0.0.dylib`dev::eth::jit::test(_builder=0x00007fff5fbf46d8) + 258 at RuntimeManager.cpp:99</font></div><div><font face="monospace, monospace">   96  <span style="white-space:pre-wrap">              </span>auto check = _builder.GetInsertBlock();</font></div><div><font face="monospace, monospace">   97  <span style="white-space:pre-wrap">         </span>{</font></div><div><font face="monospace, monospace">   98  <span style="white-space:pre-wrap">                       </span>llvm::IRBuilderBase::InsertPointGuard guard{_builder};</font></div><div><font face="monospace, monospace">-> 99  <span style="white-space:pre-wrap">                 </span>_builder.SetInsertPoint(checkBB);</font></div><div><font face="monospace, monospace">   100 <span style="white-space:pre-wrap">                </span>}</font></div><div><font face="monospace, monospace">   101 <span style="white-space:pre-wrap">        </span></font></div><div><font face="monospace, monospace">   102 <span style="white-space:pre-wrap">         </span>if (_builder.GetInsertBlock() != check)</font></div><div><font face="monospace, monospace">(lldb) p guard</font></div><div><font face="monospace, monospace">Assertion failed: (field_idx < record_layout.getFieldCount()), function GetChildClangTypeAtIndex, file /SourceCache/lldb/lldb-320.4.156/source/Symbol/ClangASTType.cpp, line 6615.</font></div><div><font face="monospace, monospace">Abort trap: 6</font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif">It's hard to create a small executable where the problem can be reproduced.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Cheers,</font></div><div><font face="arial, helvetica, sans-serif">- Paweł Bylica</font></div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>