[llvm] r205357 - DwarfDebug: Prevent DebugLocEntry merging from coalescing two different

Eric Christopher echristo at gmail.com
Tue Apr 1 14:29:31 PDT 2014


Please :)

Also a comment.

-eric

On Tue, Apr 1, 2014 at 2:24 PM, David Blaikie <dblaikie at gmail.com> wrote:
> On Tue, Apr 1, 2014 at 2:04 PM, Adrian Prantl <aprantl at apple.com> wrote:
>> Author: adrian
>> Date: Tue Apr  1 16:04:18 2014
>> New Revision: 205357
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=205357&view=rev
>> Log:
>> DwarfDebug: Prevent DebugLocEntry merging from coalescing two different
>> constants into only the first one.
>>
>> rdar://14874886.
>>
>> Added:
>>     llvm/trunk/test/DebugInfo/X86/dbg-value-const-byref.ll
>> Modified:
>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=205357&r1=205356&r2=205357&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue Apr  1 16:04:18 2014
>> @@ -117,11 +117,18 @@ public:
>>    /// labels are referenced is used to find debug_loc offset for a given DIE.
>>    bool isEmpty() const { return Begin == 0 && End == 0; }
>>    bool Merge(const DebugLocEntry &Next) {
>> -    if (!(Begin && Loc == Next.Loc && End == Next.Begin))
>> -      return false;
>> +    if (Begin &&
>> +       Loc == Next.Loc &&
>> +       EntryKind == Next.EntryKind &&
>> +       (!isInt() || getInt() == Next.getInt()) &&
>> +       (!isConstantInt() || getConstantInt() == Next.getConstantInt()) &&
>> +       (!isConstantFP() || getConstantFP() == Next.getConstantFP()) &&
>> +       End == Next.Begin) {
>
> With all of these conditions mounting up, it might be easier to phrase
> this as a series of early-returns:
>
> if (!Begin)
>   return false;
>
> if (EntryKind != Next.EntryKind)
>   return false;
>
> // at this point a switch over EntryKind might be appropriate (since
> you know they're matching)
>
> switch (EntryKind) {
> case E_Location:
>  if (Loc != Next.Loc) return false;
> case E_Integer:
>  if (Int != Next.Int) return false;
> case E_ConstantFP:
>  if (CFP != Next.CFP) return false;
> case E_ConstantInt:
>  if (CIP != Next.CIP) return false;
> }
>
> return true;
>
>>      End = Next.End;
>>      return true;
>>    }
>> +  return false;
>> +  }
>>    bool isLocation() const { return EntryKind == E_Location; }
>>    bool isInt() const { return EntryKind == E_Integer; }
>>    bool isConstantFP() const { return EntryKind == E_ConstantFP; }
>>
>> Added: llvm/trunk/test/DebugInfo/X86/dbg-value-const-byref.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dbg-value-const-byref.ll?rev=205357&view=auto
>> ==============================================================================
>> --- llvm/trunk/test/DebugInfo/X86/dbg-value-const-byref.ll (added)
>> +++ llvm/trunk/test/DebugInfo/X86/dbg-value-const-byref.ll Tue Apr  1 16:04:18 2014
>> @@ -0,0 +1,100 @@
>> +; RUN: llc -O1 -filetype=obj -o - %s | llvm-dwarfdump -debug-dump=all - | FileCheck %s
>> +; Generated with -O1 from:
>> +; int f1();
>> +; void f2(int*);
>> +; int f3(int);
>> +;
>> +; int foo() {
>> +;   int i = 3;
>> +;   f3(i);
>> +;   i = 7;
>> +;   i = f1();
>> +;   f2(&i);
>> +;   return 0;
>> +; }
>> +;
>> +; Test that we generate valid debug info for optimized code,
>> +; particularily variables that are described as constants and passed
>> +; by reference.
>> +; rdar://problem/14874886
>> +;
>> +; CHECK: .debug_info contents:
>> +; CHECK: DW_TAG_variable
>> +; CHECK-NEXT: DW_AT_name{{.*}}"i"
>> +; CHECK-NOT: DW_TAG
>> +; CHECK:     DW_AT_location [DW_FORM_data4]    ([[LOC:.*]])
>> +; CHECK: .debug_loc contents:
>> +; CHECK: [[LOC]]:
>> +;        constu 0x00000003
>> +; CHECK: Beginning address offset: 0x0000000000000{{.*}}
>> +; CHECK:    Ending address offset: [[C1:.*]]
>> +; CHECK:     Location description: 10 03
>> +;        constu 0x00000007
>> +; CHECK: Beginning address offset: [[C1]]
>> +; CHECK:    Ending address offset: [[C2:.*]]
>> +; CHECK:     Location description: 10 07
>> +;        rax, piece 0x00000004
>> +; CHECK: Beginning address offset: [[C2]]
>> +; CHECK:    Ending address offset: [[R1:.*]]
>> +; CHECK:     Location description: 50 93 04
>> +;
>> +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
>> +target triple = "x86_64-apple-macosx10.9.0"
>> +
>> +; Function Attrs: nounwind ssp uwtable
>> +define i32 @foo() #0 {
>> +entry:
>> +  %i = alloca i32, align 4
>> +  call void @llvm.dbg.value(metadata !14, i64 0, metadata !10), !dbg !15
>> +  %call = call i32 @f3(i32 3) #3, !dbg !16
>> +  call void @llvm.dbg.value(metadata !17, i64 0, metadata !10), !dbg !18
>> +  %call1 = call i32 (...)* @f1() #3, !dbg !19
>> +  call void @llvm.dbg.value(metadata !{i32 %call1}, i64 0, metadata !10), !dbg !19
>> +  store i32 %call1, i32* %i, align 4, !dbg !19, !tbaa !20
>> +  call void @f2(i32* %i) #3, !dbg !24
>> +  ret i32 0, !dbg !25
>> +}
>> +
>> +declare i32 @f3(i32)
>> +
>> +declare i32 @f1(...)
>> +
>> +declare void @f2(i32*)
>> +
>> +; Function Attrs: nounwind readnone
>> +declare void @llvm.dbg.value(metadata, i64, metadata) #2
>> +
>> +attributes #0 = { nounwind ssp uwtable }
>> +attributes #2 = { nounwind readnone }
>> +attributes #3 = { nounwind }
>> +
>> +!llvm.dbg.cu = !{!0}
>> +!llvm.module.flags = !{!11, !12}
>> +!llvm.ident = !{!13}
>> +
>> +!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.5.0 ", i1 true, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !"", i32 1} ; [ DW_TAG_compile_unit ] [dbg-value-const-byref.c] [DW_LANG_C99]
>> +!1 = metadata !{metadata !"dbg-value-const-byref.c", metadata !""}
>> +!2 = metadata !{}
>> +!3 = metadata !{metadata !4}
>> +!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"foo", metadata !"foo", metadata !"", i32 5, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 true, i32 ()* @foo, null, null, metadata !9, i32 5} ; [ DW_TAG_subprogram ] [line 5] [def] [foo]
>> +!5 = metadata !{i32 786473, metadata !1}          ; [ DW_TAG_file_type ] [dbg-value-const-byref.c]
>> +!6 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
>> +!7 = metadata !{metadata !8}
>> +!8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
>> +!9 = metadata !{metadata !10}
>> +!10 = metadata !{i32 786688, metadata !4, metadata !"i", metadata !5, i32 6, metadata !8, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [i] [line 6]
>> +!11 = metadata !{i32 2, metadata !"Dwarf Version", i32 2}
>> +!12 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
>> +!13 = metadata !{metadata !"clang version 3.5.0 "}
>> +!14 = metadata !{i32 3}
>> +!15 = metadata !{i32 6, i32 0, metadata !4, null}
>> +!16 = metadata !{i32 7, i32 0, metadata !4, null}
>> +!17 = metadata !{i32 7}
>> +!18 = metadata !{i32 8, i32 0, metadata !4, null} ; [ DW_TAG_imported_declaration ]
>> +!19 = metadata !{i32 9, i32 0, metadata !4, null}
>> +!20 = metadata !{metadata !21, metadata !21, i64 0}
>> +!21 = metadata !{metadata !"int", metadata !22, i64 0}
>> +!22 = metadata !{metadata !"omnipotent char", metadata !23, i64 0}
>> +!23 = metadata !{metadata !"Simple C/C++ TBAA"}
>> +!24 = metadata !{i32 10, i32 0, metadata !4, null}
>> +!25 = metadata !{i32 11, i32 0, metadata !4, null}
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list