llvm.org GIT mirror llvm / b0c3c28
[DebugInfo] Handle endianness when moving debug info for split integer values (reapplied) Summary: Take the target's endianness into account when splitting the debug information in DAGTypeLegalizer::SetExpandedInteger. This patch fixes so that, for big-endian targets, the fragment expression corresponding to the high part of a split integer value is placed at offset 0, in order to correctly represent the memory address order. I have attached a PPC32 reproducer where the resulting DWARF pieces for a 64-bit integer were incorrectly reversed. Original patch was reverted due to using -stop-after=isel in the test case (but that is only working when AMDGPU target is included in the llc build). The test case has now been updated to use -stop-before=expand-isel-pseudos instead. Patch by: dstenb Reviewers: JDevlieghere, aprantl, dblaikie Reviewed By: JDevlieghere, aprantl, dblaikie Subscribers: nemanjai Differential Revision: https://reviews.llvm.org/D38172 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314781 91177308-0d34-0410-b5e6-96231b3b80d8 Bjorn Pettersson 2 years ago
2 changed file(s) with 73 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
863863 AnalyzeNewValue(Hi);
864864
865865 // Transfer debug values.
866 transferDbgValues(DAG, Op, Lo, 0);
867 transferDbgValues(DAG, Op, Hi, Lo.getValueSizeInBits());
866 if (DAG.getDataLayout().isBigEndian()) {
867 transferDbgValues(DAG, Op, Hi, 0);
868 transferDbgValues(DAG, Op, Lo, Hi.getValueSizeInBits());
869 } else {
870 transferDbgValues(DAG, Op, Lo, 0);
871 transferDbgValues(DAG, Op, Hi, Lo.getValueSizeInBits());
872 }
868873
869874 // Remember that this is the result of the node.
870875 std::pair &Entry = ExpandedIntegers[Op];
0 ; RUN: llc < %s -stop-before=expand-isel-pseudos -o - | FileCheck %s
1
2 source_filename = "foo.c"
3 target datalayout = "E-m:e-p:32:32-i64:64-n32"
4 target triple = "ppc32"
5
6 ; Verify that, when handling split-up integers, the
7 ; transferring of debug info takes the endianness
8 ; into consideration.
9 ;
10 ; The fragment expression at offset 0 should correspond
11 ; to the high part of the value on big-endian targets.
12
13 ; This basis of this ll file was created by running:
14 ; clang --target=powerpc -O1 -S -g -emit-llvm foo.c
15 ;
16 ; with foo.c being the program:
17 ; unsigned long long foo(void);
18 ; void bar() {
19 ; volatile unsigned long long result = foo();
20 ; }
21 ;
22 ; This file is a slight tweak of that output, with irrelevant
23 ; lifetime intrinsics, metadata, and debug info being removed.
24
25 ; CHECK: [[DL:![0-9]+]] = !DILocalVariable(name: "result"
26 ;
27 ; High 32 bits in R3, low 32 bits in R4
28 ; CHECK: %0 = COPY %r3
29 ; CHECK: DBG_VALUE debug-use %0, debug-use _, [[DL]], !DIExpression(DW_OP_LLVM_fragment, 0, 32)
30 ; CHECK: %1 = COPY %r4
31 ; CHECK: DBG_VALUE debug-use %1, debug-use _, [[DL]], !DIExpression(DW_OP_LLVM_fragment, 32, 32)
32 define void @bar() local_unnamed_addr #0 !dbg !6 {
33 %1 = alloca i64, align 8
34 %2 = tail call i64 @foo()
35 tail call void @llvm.dbg.value(metadata i64 %2, metadata !10, metadata !DIExpression()), !dbg !13
36 store volatile i64 %2, i64* %1, align 8
37 ret void
38 }
39
40 declare i64 @foo() local_unnamed_addr
41
42 ; Function Attrs: nounwind readnone speculatable
43 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
44
45 attributes #0 = { nounwind }
46 attributes #1 = { nounwind readnone speculatable }
47
48 !llvm.dbg.cu = !{!0}
49 !llvm.module.flags = !{!3, !4}
50 !llvm.ident = !{!5}
51
52 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
53 !1 = !DIFile(filename: "foo.c", directory: "/")
54 !2 = !{}
55 !3 = !{i32 2, !"Dwarf Version", i32 4}
56 !4 = !{i32 2, !"Debug Info Version", i32 3}
57 !5 = !{!"clang version 6.0.0"}
58 !6 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: !0, variables: !9)
59 !7 = !DISubroutineType(types: !8)
60 !8 = !{null}
61 !9 = !{!10}
62 !10 = !DILocalVariable(name: "result", scope: !6, file: !1, line: 3, type: !11)
63 !11 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !12)
64 !12 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned)
65 !13 = !DILocation(line: 3, column: 31, scope: !6)