[llvm] r267370 - Verifier: Verify that each inlinable callsite of a debug-info-bearing function

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 10:53:11 PDT 2016


On Mon, Apr 25, 2016 at 10:39 AM, Adrian Prantl <aprantl at apple.com> wrote:

>
> On Apr 25, 2016, at 10:33 AM, David Blaikie <dblaikie at gmail.com> wrote:
>
>
>
> On Sun, Apr 24, 2016 at 3:23 PM, Adrian Prantl via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Sun Apr 24 17:23:13 2016
>> New Revision: 267370
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=267370&view=rev
>> Log:
>> Verifier: Verify that each inlinable callsite of a debug-info-bearing
>> function
>> in a debug-info-bearing function has a debug location attached to it.
>> Failure to
>> do so causes an "!dbg attachment points at wrong subprogram for function"
>> assertion failure when the inliner sets up inline scope info.
>>
>
> Great to have this check - though, as an FYI: This doesn't catch all the
> cases of the downstream assertion. The downstream assertion can be
> triggered through indirect scenarios:
>
>   void f1();
>   inline __attribute__((alwaysinline)) void f2() { f1(); }
>   inline __attribute__((alwaysinline)) void f3() { f2(); } // make this
> nodebug or equivalent
>   void f4() { f3(); } // if f3 has no debugloc
>
> Now you'll end up with the same problem if f2 is inlined into f3 (maybe
> even in the other order), producing instructions with debug locations - and
> then that's inlined into f4 at a callsite with no debugloc, leaving the
> instructions having debug locations that don't chain up to the f4
> subprogram scope - but still chain up to the f2 subprogram scope.
>
>
> Thanks for pointing this out! I hope that the (cheaper) check from this
> patch will be enough to diagnose the most obvious bugs in frontends though.
>

Yeah, for sure/here's hoping!


>
>
> - Dave
>
>
>> rdar://problem/25878916
>>
>> This reaplies r267320 without changes after fixing an issue in the OpenMP
>> IR
>> generator in clang.
>>
>> Added:
>>     llvm/trunk/test/Verifier/callsite-dbgloc.ll
>> Modified:
>>     llvm/trunk/lib/IR/Verifier.cpp
>>     llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll
>>     llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll
>>
>> Modified: llvm/trunk/lib/IR/Verifier.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=267370&r1=267369&r2=267370&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/IR/Verifier.cpp (original)
>> +++ llvm/trunk/lib/IR/Verifier.cpp Sun Apr 24 17:23:13 2016
>> @@ -2579,6 +2579,15 @@ void Verifier::verifyCallSite(CallSite C
>>      }
>>    }
>>
>> +  // Verify that each inlinable callsite of a debug-info-bearing
>> function in a
>> +  // debug-info-bearing function has a debug location attached to it.
>> Failure to
>> +  // do so causes assertion failures when the inliner sets up inline
>> scope info.
>> +  if (I->getFunction()->getSubprogram() && CS.getCalledFunction() &&
>> +      CS.getCalledFunction()->getSubprogram())
>> +    Assert(I->getDebugLoc(), "inlinable function call in a function with
>> debug "
>> +                             "info must have a !dbg location",
>> +           I);
>> +
>>    visitInstruction(*I);
>>  }
>>
>>
>> Modified: llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll?rev=267370&r1=267369&r2=267370&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll (original)
>> +++ llvm/trunk/test/DebugInfo/X86/arange-and-stub.ll Sun Apr 24 17:23:13
>> 2016
>> @@ -18,7 +18,7 @@ define void @foo() !dbg !4 {
>>
>>  define void @bar() personality i8* bitcast (void ()* @foo to i8*) !dbg
>> !9 {
>>    invoke void @foo()
>> -          to label %invoke.cont unwind label %lpad
>> +          to label %invoke.cont unwind label %lpad, !dbg !19
>>
>>  invoke.cont:                                      ; preds = %0
>>    ret void
>> @@ -50,3 +50,4 @@ lpad:
>>  !16 = !DISubrange(count: 1)
>>  !17 = !{i32 2, !"Dwarf Version", i32 4}
>>  !18 = !{i32 2, !"Debug Info Version", i32 3}
>> +!19 = !DILocation(line: 0, scope: !9)
>>
>> Modified: llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll?rev=267370&r1=267369&r2=267370&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll (original)
>> +++ llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll Sun Apr 24 17:23:13
>> 2016
>> @@ -54,7 +54,7 @@ entry:
>>    store %class.A* %this, %class.A** %this.addr, align 8
>>    call void @llvm.dbg.declare(metadata %class.A** %this.addr, metadata
>> !43, metadata !DIExpression()), !dbg !44
>>    %this1 = load %class.A*, %class.A** %this.addr
>> -  call void @_ZN1AD2Ev(%class.A* %this1)
>> +  call void @_ZN1AD2Ev(%class.A* %this1), !dbg !53
>>    ret void, !dbg !45
>>  }
>>
>> @@ -124,3 +124,4 @@ entry:
>>  !49 = distinct !DILexicalBlock(line: 2, column: 52, file: !51, scope:
>> !25)
>>  !51 = !DIFile(filename: "a.cc", directory: "/private/tmp")
>>  !52 = !{i32 1, !"Debug Info Version", i32 3}
>> +!53 = !DILocation(line: 0, scope: !22)
>>
>> Added: llvm/trunk/test/Verifier/callsite-dbgloc.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/callsite-dbgloc.ll?rev=267370&view=auto
>>
>> ==============================================================================
>> --- llvm/trunk/test/Verifier/callsite-dbgloc.ll (added)
>> +++ llvm/trunk/test/Verifier/callsite-dbgloc.ll Sun Apr 24 17:23:13 2016
>> @@ -0,0 +1,62 @@
>> +; RUN: not llvm-as %s -o %t 2>&1 | FileCheck %s
>> +; Created and then edited from
>>
>
> It'd be good to describe the required edits here? (so that if someone is
> trying to regenerate or otherwise understand this test they know what to
> look for)
>
>
> I did, next to the CHECK :-)
>

Ah, thanks for pointing it out - not sure if many of the debug info test
cases interleave the CHECK lines inside the IR, generally, so I didn't spot
it there.


>
> +; Function Attrs: nounwind ssp uwtable
>> +define void @g() #0 !dbg !11 {
>> +entry:
>> +; Manually removed !dbg.
>> +; CHECK: inlinable function call in a function with debug info must have
>> a !dbg location
>> +  call void @h()
>> +  ret void, !dbg !13
>> +}
>> +
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160425/bc73ef2a/attachment.html>


More information about the llvm-commits mailing list