[llvm] r235050 - DebugInfo: Remove 'inlinedAt:' field from MDLocalVariable

Adrian Prantl aprantl at apple.com
Thu Apr 16 17:56:22 PDT 2015


> On Apr 16, 2015, at 5:55 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
> 
> 
>> On 2015-Apr-16, at 15:50, David Blaikie <dblaikie at gmail.com> wrote:
>> 
>> 
>> 
>> On Thu, Apr 16, 2015 at 3:37 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
>> 
>>> On 2015-Apr-16, at 14:21, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
>>> 
>>>> 
>>>> On 2015-Apr-16, at 11:41, David Blaikie <dblaikie at gmail.com> wrote:
>>>> 
>>>> (from IRC discussion)
>>>> 
>>>> Looks like this might've caused the GDB buildbot regression seen here: http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/21390
>>>> 
>>>> Specifically, in the below program
>>>> 
>>>> int *g;
>>>> 
>>>> static __attribute__((always_inline)) int f(int a) {
>>>> int l;
>>>> g = &l;
>>>> return a;
>>>> }
>>>> 
>>>> int main(void) {
>>>> f(0);
>>>> f(0);
>>>> return 0;
>>>> }
>>>> 
>>>> The inlined_subroutine for 'f' in 'main' has no DW_TAG_formal_parameter (for 'a')
>>> 
>>> I've tracked this down -- UserValue::match() needed to be updated.
>> 
>> r235140
>> 
>>> 
>>> I fixed what might be an unrelated bug in DebugLocEntry.  I'll have
>>> to separate out the two changes to see if this testcase provides any
>>> coverage for `DebugLocEntry`; if not I'll maybe need some help from
>>> you or Adrian coming up with a good testcase for that one.
>> 
>> This turned out to be unrelated.
>> 
>> Looking at the code, I'm not even sure what the variables are doing in
>> `DebugLocEntry` -- they're only used to prevent adjacent locations from
>> coalescing.  I guess the main problem is I don't know what this table is
>> for (well, `.debug_loc`, but I don't know what that is either).
>> 
>> .debug_loc is for variables that don't reside in just a single location for their entire lifetime (much like debug_ranges discussed earlier) - if a variable resides in a single place for its entire scope, then DW_AT_location will have a dwarf expression describing that location, otherwise it'll have a sec_offset/data4 giving the offset in debug_loc that describes the various locations and ranges for the variable.
>> 
>> You might look for existing test cases that produce debug_loc sections? But I don't have a canonical way to produce one off-hand. I imagine if one is produced for two distinct inlined variables (from distinct inlined calls to the same function) then their location lists might end up accidentally shared (they'd end up with the same location list (possibly combining both variable location lists), rather than distinct ones)?
>> 
> 
> I tried a variation on your simplified testcase for the original bug,
> hoping that the variables would somehow be coalesced badly:
> 
>    void sink(void);
>    static __attribute__((always_inline)) void bar(int a) { sink(); }
>    void foo(void) {
>      bar(0);
>      bar(1);
>    }
> 
> Unfortunately, the dwarfdump output doesn't change with my fix to
> DebugLocEntry.  But I did get something weird:
> 
> 0x00000068:     DW_TAG_inlined_subroutine [6] *
>                  DW_AT_abstract_origin [DW_FORM_ref4]	(cu + 0x002f => {0x0000002f} "bar")
>                  DW_AT_low_pc [DW_FORM_addr]	(0x0000000000000004)
>                  DW_AT_high_pc [DW_FORM_addr]	(0x0000000000000009)
>                  DW_AT_call_file [DW_FORM_data1]	("/Users/dexonsmith/data/llvm/staging/play/inlined-at/t.c")
>                  DW_AT_call_line [DW_FORM_data1]	(4)
> 
> 0x0000007f:       DW_TAG_formal_parameter [7]  
>                    DW_AT_const_value [DW_FORM_sdata]	(0)
>                    DW_AT_abstract_origin [DW_FORM_ref4]	(cu + 0x0039 => {0x00000039} "a")
> 
> 0x00000085:       NULL
> 
> 0x00000086:     DW_TAG_inlined_subroutine [6] *
>                  DW_AT_abstract_origin [DW_FORM_ref4]	(cu + 0x002f => {0x0000002f} "bar")
>                  DW_AT_low_pc [DW_FORM_addr]	(0x0000000000000009)
>                  DW_AT_high_pc [DW_FORM_addr]	(0x000000000000000f)
>                  DW_AT_call_file [DW_FORM_data1]	("/Users/dexonsmith/data/llvm/staging/play/inlined-at/t.c")
>                  DW_AT_call_line [DW_FORM_data1]	(5)
> 
> 0x0000009d:       DW_TAG_formal_parameter [7]  
>                    DW_AT_const_value [DW_FORM_sdata]	(0)
>                    DW_AT_abstract_origin [DW_FORM_ref4]	(cu + 0x0039 => {0x00000039} "a")
> 
> 0x000000a3:       NULL
> 
> 0x000000a4:     NULL
> 
> 
> Notice that "a" has the same value (0) in both inlined subroutines.
> 
> This is *not* a regression from r235050 -- older clangs give me the
> same thing here.
> 
> Is this a known bug?  (Or am I confused, and it's not a bug?)

If the IR shows two different dbg.value intrinsics (and it should!) this is definitely a bug.

-- adrian

> 
>> 
>> By inspection, r235050 caused a behaviour change here (and the attached
>> patch would revert the behaviour change), but I honestly have no idea
>> what to test.
>> 
>> Adrian, you seem to have touched this code most recently.  Any ideas?
> 





More information about the llvm-commits mailing list