[llvm] Support big endian in llvm-symbolizer's data location dwarf info parser (PR #67284)

Chen Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 02:06:09 PDT 2023


https://github.com/chenzheng1030 updated https://github.com/llvm/llvm-project/pull/67284

>From ef8c5d72c7b3be098f5cb2734da5a32474f629c4 Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Mon, 25 Sep 2023 01:06:28 -0400
Subject: [PATCH 1/7] base case, nfc

---
 .../llvm-symbolizer/Inputs/xcoff-dwarf.o      | Bin 0 -> 2256 bytes
 llvm/test/tools/llvm-symbolizer/xcoff.test    |  63 ++++++++++++++++++
 2 files changed, 63 insertions(+)
 create mode 100644 llvm/test/tools/llvm-symbolizer/Inputs/xcoff-dwarf.o
 create mode 100644 llvm/test/tools/llvm-symbolizer/xcoff.test

diff --git a/llvm/test/tools/llvm-symbolizer/Inputs/xcoff-dwarf.o b/llvm/test/tools/llvm-symbolizer/Inputs/xcoff-dwarf.o
new file mode 100644
index 0000000000000000000000000000000000000000..04326b6ccedd0462394ebaafb3fe4d6eda50e0c1
GIT binary patch
literal 2256
zcmah~&u<$=6n?YzChK2KTnj;4AX`LAXp at cCWbLGtLQ0fFsz6JVLz|1UYp-L2V_S}s
z=FmeVklI5JIpmNN2gI=l4oKYi6SyEw94c|>-+)8}eDCer-b9Uf(#(AG%{TAO?@_O4
zgv9h;P<+JD>iGvf;Re|jk%|+=e-tJrxoK71o*PKePMq at 4RiXP8n8=WP$?|r01rZ&g
z<dhEU(c;jmK5 at OSzaJrA!rw`xP8jVtbd6T69ig=xk at kp4e_zNk<VtkSM$3=rsEDy0
zK=+f73b{t(haS-vhhz$uFqcqri$QvM)2{6k+T(}clX3VB(G*tUX=UoWvwFpPws(R)
z9@&LY=A2?_KA<JnkZ*+bZ^P0=*~h#t$4D|?l~t2QPLCPmBiD?qx{LtY9L0>)+^6Z=
zsXHkxNfi4K#9}Iy!ldSCHP`2LrB<;ZBiF%|&^USn0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test b/llvm/test/tools/llvm-symbolizer/xcoff.test
new file mode 100644
index 000000000000000..c6b65ac9b789361
--- /dev/null
+++ b/llvm/test/tools/llvm-symbolizer/xcoff.test
@@ -0,0 +1,63 @@
+
+RUN: llvm-symbolizer --obj=%p/Inputs/xcoff-dwarf.o 'DATA 0x60' \
+RUN:    'DATA 0x61' 'DATA 0x64' 'DATA 0X68' 'DATA 0x90' 'DATA 0x94' \
+RUN:    'DATA 0X98' | FileCheck %s
+
+CHECK: bss_global
+CHECK-NEXT: 96 4
+CHECK-NEXT: ??:?
+CHECK-EMPTY:
+
+CHECK: bss_global
+CHECK-NEXT: 96 4
+CHECK-NEXT: ??:?
+CHECK-EMPTY:
+
+CHECK: data_global
+CHECK-NEXT: 100 4
+CHECK-NEXT: ??:?
+CHECK-EMPTY:
+
+CHECK: str
+CHECK-NEXT: 104 4
+CHECK-NEXT: ??:?
+CHECK-EMPTY:
+
+FIXME: fix the wrong size 152
+CHECK: f()::function_global
+CHECK-NEXT: 144 152
+CHECK-NEXT: ??:?
+CHECK-EMPTY:
+
+FIXME: fix the wrong size 152
+CHECK: beta
+CHECK-NEXT: 148 152
+CHECK-NEXT: ??:?
+CHECK-EMPTY:
+
+FIXME: fix the wrong size 152
+CHECK: alpha
+CHECK-NEXT: 152 152
+CHECK-NEXT: ??:?
+CHECK-EMPTY:
+
+The case is from `test/tools/llvm-symbolizer/data-location.yaml`, compiled with:
+ clang++ -g -gdwarf-3 -O3 t.cpp  -nostdlib  -target powerpc-aix-ibm-xcoff \
+   -mllvm -ppc-global-merge=false
+
+     cat t.cpp
+     1	int bss_global;
+     2	int data_global = 2;
+     3
+     4	const char* str =
+     5	  "12345678";
+     6
+     7	int* f() {
+     8	  static int function_global;
+     9	  return &function_global;
+    10	}
+    11
+    12	static int alpha;
+    13	static int beta;
+    14	int *f(bool b) { return beta ? &alpha : β }
+    15

>From ba1dc6efed306c31cdbef3800144a8b8ffc1b67b Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Mon, 25 Sep 2023 01:21:28 -0400
Subject: [PATCH 2/7] support big endian while processing data location

---
 llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp     |  2 +-
 llvm/test/tools/llvm-symbolizer/xcoff.test | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 387345a4ac2d601..0cd45bde3e25349 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -784,7 +784,7 @@ void DWARFUnit::updateVariableDieMap(DWARFDie Die) {
 
   for (const DWARFLocationExpression &Location : *Locations) {
     uint8_t AddressSize = getAddressByteSize();
-    DataExtractor Data(Location.Expr, /*IsLittleEndian=*/true, AddressSize);
+    DataExtractor Data(Location.Expr, isLittleEndian(), AddressSize);
     DWARFExpression Expr(Data, AddressSize);
     auto It = Expr.begin();
     if (It == Expr.end())
diff --git a/llvm/test/tools/llvm-symbolizer/xcoff.test b/llvm/test/tools/llvm-symbolizer/xcoff.test
index c6b65ac9b789361..a4c6f89a230af5a 100644
--- a/llvm/test/tools/llvm-symbolizer/xcoff.test
+++ b/llvm/test/tools/llvm-symbolizer/xcoff.test
@@ -5,40 +5,40 @@ RUN:    'DATA 0X98' | FileCheck %s
 
 CHECK: bss_global
 CHECK-NEXT: 96 4
-CHECK-NEXT: ??:?
+CHECK-NEXT: /t.cpp:1
 CHECK-EMPTY:
 
 CHECK: bss_global
 CHECK-NEXT: 96 4
-CHECK-NEXT: ??:?
+CHECK-NEXT: /t.cpp:1
 CHECK-EMPTY:
 
 CHECK: data_global
 CHECK-NEXT: 100 4
-CHECK-NEXT: ??:?
+CHECK-NEXT: /t.cpp:2
 CHECK-EMPTY:
 
 CHECK: str
 CHECK-NEXT: 104 4
-CHECK-NEXT: ??:?
+CHECK-NEXT: /t.cpp:4
 CHECK-EMPTY:
 
 FIXME: fix the wrong size 152
 CHECK: f()::function_global
 CHECK-NEXT: 144 152
-CHECK-NEXT: ??:?
+CHECK-NEXT: /t.cpp:8
 CHECK-EMPTY:
 
 FIXME: fix the wrong size 152
 CHECK: beta
 CHECK-NEXT: 148 152
-CHECK-NEXT: ??:?
+CHECK-NEXT: /t.cpp:13
 CHECK-EMPTY:
 
 FIXME: fix the wrong size 152
 CHECK: alpha
 CHECK-NEXT: 152 152
-CHECK-NEXT: ??:?
+CHECK-NEXT: /t.cpp:12
 CHECK-EMPTY:
 
 The case is from `test/tools/llvm-symbolizer/data-location.yaml`, compiled with:

>From a93cc5272d8c6f151103ac6e67e66a3d36a0dd4b Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Mon, 25 Sep 2023 05:39:47 -0400
Subject: [PATCH 3/7] change the location of the case

---
 .../Symbolize/XCOFF}/Inputs/xcoff-dwarf.o           | Bin
 .../Symbolize/XCOFF}/xcoff.test                     |   0
 2 files changed, 0 insertions(+), 0 deletions(-)
 rename llvm/test/{tools/llvm-symbolizer => DebugInfo/Symbolize/XCOFF}/Inputs/xcoff-dwarf.o (100%)
 rename llvm/test/{tools/llvm-symbolizer => DebugInfo/Symbolize/XCOFF}/xcoff.test (100%)

diff --git a/llvm/test/tools/llvm-symbolizer/Inputs/xcoff-dwarf.o b/llvm/test/DebugInfo/Symbolize/XCOFF/Inputs/xcoff-dwarf.o
similarity index 100%
rename from llvm/test/tools/llvm-symbolizer/Inputs/xcoff-dwarf.o
rename to llvm/test/DebugInfo/Symbolize/XCOFF/Inputs/xcoff-dwarf.o
diff --git a/llvm/test/tools/llvm-symbolizer/xcoff.test b/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff.test
similarity index 100%
rename from llvm/test/tools/llvm-symbolizer/xcoff.test
rename to llvm/test/DebugInfo/Symbolize/XCOFF/xcoff.test

>From 336530353674e0036604f138d0ea27c7d521b5b6 Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Tue, 26 Sep 2023 03:35:19 -0400
Subject: [PATCH 4/7] use ir input to generate the xcoff object

---
 .../Symbolize/XCOFF/Inputs/xcoff-dwarf.o      | Bin 2256 -> 0 bytes
 llvm/test/DebugInfo/Symbolize/XCOFF/xcoff.ll  | 149 ++++++++++++++++++
 .../test/DebugInfo/Symbolize/XCOFF/xcoff.test |  63 --------
 3 files changed, 149 insertions(+), 63 deletions(-)
 delete mode 100644 llvm/test/DebugInfo/Symbolize/XCOFF/Inputs/xcoff-dwarf.o
 create mode 100644 llvm/test/DebugInfo/Symbolize/XCOFF/xcoff.ll
 delete mode 100644 llvm/test/DebugInfo/Symbolize/XCOFF/xcoff.test

diff --git a/llvm/test/DebugInfo/Symbolize/XCOFF/Inputs/xcoff-dwarf.o b/llvm/test/DebugInfo/Symbolize/XCOFF/Inputs/xcoff-dwarf.o
deleted file mode 100644
index 04326b6ccedd0462394ebaafb3fe4d6eda50e0c1..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 2256
zcmah~&u<$=6n?YzChK2KTnj;4AX`LAXp at cCWbLGtLQ0fFsz6JVLz|1UYp-L2V_S}s
z=FmeVklI5JIpmNN2gI=l4oKYi6SyEw94c|>-+)8}eDCer-b9Uf(#(AG%{TAO?@_O4
zgv9h;P<+JD>iGvf;Re|jk%|+=e-tJrxoK71o*PKePMq at 4RiXP8n8=WP$?|r01rZ&g
z<dhEU(c;jmK5 at OSzaJrA!rw`xP8jVtbd6T69ig=xk at kp4e_zNk<VtkSM$3=rsEDy0
zK=+f73b{t(haS-vhhz$uFqcqri$QvM)2{6k+T(}clX3VB(G*tUX=UoWvwFpPws(R)
z9@&LY=A2?_KA<JnkZ*+bZ^P0=*~h#t$4D|?l~t2QPLCPmBiD?qx{LtY9L0>)+^6Z=
zsXHkxNfi4K#9}Iy!ldSCHP`2LrB<;ZBiF%|&^USn0P|saDzykEF(ypXLYT{HDfw*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xcoff.ll
new file mode 100644
index 000000000000000..c50238d838080b1
--- /dev/null
+++ b/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff.ll
@@ -0,0 +1,149 @@
+; RUN: llc -filetype=obj -o %t -mtriple=powerpc-aix-ibm-xcoff < %s
+; RUN: llvm-symbolizer --obj=%t 'DATA 0x60' 'DATA 0x61' 'DATA 0x64' 'DATA 0X68' \
+; RUN:   'DATA 0x90' 'DATA 0x94' 'DATA 0X98' | FileCheck %s
+
+; CHECK: bss_global
+; CHECK-NEXT: 96 4
+; CHECK-NEXT: /t.cpp:1
+; CHECK-EMPTY:
+
+; CHECK: bss_global
+; CHECK-NEXT: 96 4
+; CHECK-NEXT: /t.cpp:1
+; CHECK-EMPTY:
+
+; CHECK: data_global
+; CHECK-NEXT: 100 4
+; CHECK-NEXT: /t.cpp:2
+; CHECK-EMPTY:
+
+; CHECK: str
+; CHECK-NEXT: 104 4
+; CHECK-NEXT: /t.cpp:4
+; CHECK-EMPTY:
+
+; FIXME: fix the wrong size 152
+; CHECK: f()::function_global
+; CHECK-NEXT: 144 152
+; CHECK-NEXT: /t.cpp:8
+; CHECK-EMPTY:
+
+; FIXME: fix the wrong size 152
+; CHECK: beta
+; CHECK-NEXT: 148 152
+; CHECK-NEXT: /t.cpp:13
+; CHECK-EMPTY:
+
+; FIXME: fix the wrong size 152
+; CHECK: alpha
+; CHECK-NEXT: 152 152
+; CHECK-NEXT: /t.cpp:12
+; CHECK-EMPTY:
+
+; The case is from `test/tools/llvm-symbolizer/data-location.yaml`, compiled with:
+; clang++ -g -gdwarf-3 -O3 t.cpp  -nostdlib  -target powerpc-aix-ibm-xcoff -S -emit-llvm
+
+;     cat t.cpp
+;     1	int bss_global;
+;     2	int data_global = 2;
+;     3
+;     4	const char* str =
+;     5	  "12345678";
+;     6
+;     7	int* f() {
+;     8	  static int function_global;
+;     9	  return &function_global;
+;    10	}
+;    11
+;    12	static int alpha;
+;    13	static int beta;
+;    14	int *f(bool b) { return beta ? &alpha : β }
+;    15
+
+; ModuleID = 't.cpp'
+source_filename = "t.cpp"
+target datalayout = "E-m:a-p:32:32-Fi32-i64:64-n32"
+target triple = "powerpc-ibm-aix-xcoff"
+
+ at bss_global = local_unnamed_addr global i32 0, align 4, !dbg !0
+ at data_global = local_unnamed_addr global i32 2, align 4, !dbg !5
+ at .str = private unnamed_addr constant [9 x i8] c"12345678\00", align 1, !dbg !8
+ at str = local_unnamed_addr global ptr @.str, align 4, !dbg !15
+ at _ZZ1fvE15function_global = internal global i32 0, align 4, !dbg !18
+ at _ZL4beta = internal global i32 0, align 4, !dbg !24
+ at _ZL5alpha = internal global i32 0, align 4, !dbg !26
+
+; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
+define noundef nonnull ptr @_Z1fv() local_unnamed_addr #0 !dbg !20 {
+entry:
+  ret ptr @_ZZ1fvE15function_global, !dbg !34
+}
+
+; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none)
+define noundef nonnull ptr @_Z1fb(i1 noundef zeroext %b) local_unnamed_addr #1 !dbg !35 {
+entry:
+  call void @llvm.dbg.value(metadata i1 %b, metadata !40, metadata !DIExpression(DW_OP_LLVM_convert, 1, DW_ATE_unsigned, DW_OP_LLVM_convert, 8, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !41
+  %0 = load i32, ptr @_ZL4beta, align 4, !dbg !42, !tbaa !43
+  %tobool.not = icmp eq i32 %0, 0, !dbg !42
+  %cond = select i1 %tobool.not, ptr @_ZL4beta, ptr @_ZL5alpha, !dbg !42
+  ret ptr %cond, !dbg !42
+}
+
+; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
+declare void @llvm.dbg.value(metadata, metadata, metadata) #2
+
+attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pwr7" "target-features"="+altivec,+bpermd,+extdiv,+isa-v206-instructions,+vsx,-aix-small-local-exec-tls,-crbits,-crypto,-direct-move,-htm,-isa-v207-instructions,-isa-v30-instructions,-power8-vector,-power9-vector,-privileged,-quadword-atomics,-rop-protect,-spe" }
+attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pwr7" "target-features"="+altivec,+bpermd,+extdiv,+isa-v206-instructions,+vsx,-aix-small-local-exec-tls,-crbits,-crypto,-direct-move,-htm,-isa-v207-instructions,-isa-v30-instructions,-power8-vector,-power9-vector,-privileged,-quadword-atomics,-rop-protect,-spe" }
+attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!28, !29, !30, !31, !32}
+!llvm.ident = !{!33}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "bss_global", scope: !2, file: !3, line: 1, type: !7, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 18.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "t.cpp", directory: "/")
+!4 = !{!0, !5, !8, !15, !18, !24, !26}
+!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
+!6 = distinct !DIGlobalVariable(name: "data_global", scope: !2, file: !3, line: 2, type: !7, isLocal: false, isDefinition: true)
+!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!8 = !DIGlobalVariableExpression(var: !9, expr: !DIExpression())
+!9 = distinct !DIGlobalVariable(scope: null, file: !3, line: 5, type: !10, isLocal: true, isDefinition: true)
+!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, size: 72, elements: !13)
+!11 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !12)
+!12 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_unsigned_char)
+!13 = !{!14}
+!14 = !DISubrange(count: 9)
+!15 = !DIGlobalVariableExpression(var: !16, expr: !DIExpression())
+!16 = distinct !DIGlobalVariable(name: "str", scope: !2, file: !3, line: 4, type: !17, isLocal: false, isDefinition: true)
+!17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32)
+!18 = !DIGlobalVariableExpression(var: !19, expr: !DIExpression())
+!19 = distinct !DIGlobalVariable(name: "function_global", scope: !20, file: !3, line: 8, type: !7, isLocal: true, isDefinition: true)
+!20 = distinct !DISubprogram(name: "f", linkageName: "_Z1fv", scope: !3, file: !3, line: 7, type: !21, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2)
+!21 = !DISubroutineType(types: !22)
+!22 = !{!23}
+!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32)
+!24 = !DIGlobalVariableExpression(var: !25, expr: !DIExpression())
+!25 = distinct !DIGlobalVariable(name: "beta", linkageName: "_ZL4beta", scope: !2, file: !3, line: 13, type: !7, isLocal: true, isDefinition: true)
+!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression())
+!27 = distinct !DIGlobalVariable(name: "alpha", linkageName: "_ZL5alpha", scope: !2, file: !3, line: 12, type: !7, isLocal: true, isDefinition: true)
+!28 = !{i32 7, !"Dwarf Version", i32 3}
+!29 = !{i32 2, !"Debug Info Version", i32 3}
+!30 = !{i32 1, !"wchar_size", i32 2}
+!31 = !{i32 8, !"PIC Level", i32 2}
+!32 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
+!33 = !{!"clang version 18.0.0"}
+!34 = !DILocation(line: 9, scope: !20)
+!35 = distinct !DISubprogram(name: "f", linkageName: "_Z1fb", scope: !3, file: !3, line: 14, type: !36, scopeLine: 14, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !39)
+!36 = !DISubroutineType(types: !37)
+!37 = !{!23, !38}
+!38 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean)
+!39 = !{!40}
+!40 = !DILocalVariable(name: "b", arg: 1, scope: !35, file: !3, line: 14, type: !38)
+!41 = !DILocation(line: 0, scope: !35)
+!42 = !DILocation(line: 14, scope: !35)
+!43 = !{!44, !44, i64 0}
+!44 = !{!"int", !45, i64 0}
+!45 = !{!"omnipotent char", !46, i64 0}
+!46 = !{!"Simple C++ TBAA"}
diff --git a/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff.test b/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff.test
deleted file mode 100644
index a4c6f89a230af5a..000000000000000
--- a/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff.test
+++ /dev/null
@@ -1,63 +0,0 @@
-
-RUN: llvm-symbolizer --obj=%p/Inputs/xcoff-dwarf.o 'DATA 0x60' \
-RUN:    'DATA 0x61' 'DATA 0x64' 'DATA 0X68' 'DATA 0x90' 'DATA 0x94' \
-RUN:    'DATA 0X98' | FileCheck %s
-
-CHECK: bss_global
-CHECK-NEXT: 96 4
-CHECK-NEXT: /t.cpp:1
-CHECK-EMPTY:
-
-CHECK: bss_global
-CHECK-NEXT: 96 4
-CHECK-NEXT: /t.cpp:1
-CHECK-EMPTY:
-
-CHECK: data_global
-CHECK-NEXT: 100 4
-CHECK-NEXT: /t.cpp:2
-CHECK-EMPTY:
-
-CHECK: str
-CHECK-NEXT: 104 4
-CHECK-NEXT: /t.cpp:4
-CHECK-EMPTY:
-
-FIXME: fix the wrong size 152
-CHECK: f()::function_global
-CHECK-NEXT: 144 152
-CHECK-NEXT: /t.cpp:8
-CHECK-EMPTY:
-
-FIXME: fix the wrong size 152
-CHECK: beta
-CHECK-NEXT: 148 152
-CHECK-NEXT: /t.cpp:13
-CHECK-EMPTY:
-
-FIXME: fix the wrong size 152
-CHECK: alpha
-CHECK-NEXT: 152 152
-CHECK-NEXT: /t.cpp:12
-CHECK-EMPTY:
-
-The case is from `test/tools/llvm-symbolizer/data-location.yaml`, compiled with:
- clang++ -g -gdwarf-3 -O3 t.cpp  -nostdlib  -target powerpc-aix-ibm-xcoff \
-   -mllvm -ppc-global-merge=false
-
-     cat t.cpp
-     1	int bss_global;
-     2	int data_global = 2;
-     3
-     4	const char* str =
-     5	  "12345678";
-     6
-     7	int* f() {
-     8	  static int function_global;
-     9	  return &function_global;
-    10	}
-    11
-    12	static int alpha;
-    13	static int beta;
-    14	int *f(bool b) { return beta ? &alpha : β }
-    15

>From f8390485fd8859e03d06c0612a69fa43bbc62c1a Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Tue, 26 Sep 2023 03:42:04 -0400
Subject: [PATCH 5/7] rename the test file

---
 .../Symbolize/XCOFF/{xcoff.ll => xcoff-symbolize-data.ll}         | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename llvm/test/DebugInfo/Symbolize/XCOFF/{xcoff.ll => xcoff-symbolize-data.ll} (100%)

diff --git a/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff.ll b/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff-symbolize-data.ll
similarity index 100%
rename from llvm/test/DebugInfo/Symbolize/XCOFF/xcoff.ll
rename to llvm/test/DebugInfo/Symbolize/XCOFF/xcoff-symbolize-data.ll

>From d90635c5528aef5a1f96249c60fecd52ba236d82 Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Wed, 27 Sep 2023 04:37:58 -0400
Subject: [PATCH 6/7] address comments

---
 .../Symbolize/XCOFF/xcoff-symbolize-data.ll   | 51 ++++++++++---------
 1 file changed, 28 insertions(+), 23 deletions(-)

diff --git a/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff-symbolize-data.ll b/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff-symbolize-data.ll
index c50238d838080b1..4403f20d8a505b7 100644
--- a/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff-symbolize-data.ll
+++ b/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff-symbolize-data.ll
@@ -1,6 +1,11 @@
+; REQUIRES: powerpc-registered-target
 ; RUN: llc -filetype=obj -o %t -mtriple=powerpc-aix-ibm-xcoff < %s
 ; RUN: llvm-symbolizer --obj=%t 'DATA 0x60' 'DATA 0x61' 'DATA 0x64' 'DATA 0X68' \
-; RUN:   'DATA 0x90' 'DATA 0x94' 'DATA 0X98' | FileCheck %s
+; RUN:   'DATA 0x90' 'DATA 0x94' 'DATA 0X98' | \
+; RUN:   FileCheck %s
+
+;; This files tests llvm-symbolizer can successfully symbolize the data symbol
+;; from the DWARF info on AIX. Note that AIX is big endian.
 
 ; CHECK: bss_global
 ; CHECK-NEXT: 96 4
@@ -22,43 +27,43 @@
 ; CHECK-NEXT: /t.cpp:4
 ; CHECK-EMPTY:
 
-; FIXME: fix the wrong size 152
+;; FIXME: fix the wrong size 152
 ; CHECK: f()::function_global
 ; CHECK-NEXT: 144 152
 ; CHECK-NEXT: /t.cpp:8
 ; CHECK-EMPTY:
 
-; FIXME: fix the wrong size 152
+;; FIXME: fix the wrong size 152
 ; CHECK: beta
 ; CHECK-NEXT: 148 152
 ; CHECK-NEXT: /t.cpp:13
 ; CHECK-EMPTY:
 
-; FIXME: fix the wrong size 152
+;; FIXME: fix the wrong size 152
 ; CHECK: alpha
 ; CHECK-NEXT: 152 152
 ; CHECK-NEXT: /t.cpp:12
 ; CHECK-EMPTY:
 
-; The case is from `test/tools/llvm-symbolizer/data-location.yaml`, compiled with:
-; clang++ -g -gdwarf-3 -O3 t.cpp  -nostdlib  -target powerpc-aix-ibm-xcoff -S -emit-llvm
-
-;     cat t.cpp
-;     1	int bss_global;
-;     2	int data_global = 2;
-;     3
-;     4	const char* str =
-;     5	  "12345678";
-;     6
-;     7	int* f() {
-;     8	  static int function_global;
-;     9	  return &function_global;
-;    10	}
-;    11
-;    12	static int alpha;
-;    13	static int beta;
-;    14	int *f(bool b) { return beta ? &alpha : β }
-;    15
+;; The case is from `test/tools/llvm-symbolizer/data-location.yaml`, compiled with:
+;; clang++ -g -gdwarf-3 -O3 t.cpp -nostdlib -target powerpc-aix-ibm-xcoff -S -emit-llvm
+
+;;     cat t.cpp
+;;     1	int bss_global;
+;;     2	int data_global = 2;
+;;     3
+;;     4	const char* str =
+;;     5	  "12345678";
+;;     6
+;;     7	int* f() {
+;;     8	  static int function_global;
+;;     9	  return &function_global;
+;;    10	}
+;;    11
+;;    12	static int alpha;
+;;    13	static int beta;
+;;    14	int *f(bool b) { return beta ? &alpha : β }
+;;    15
 
 ; ModuleID = 't.cpp'
 source_filename = "t.cpp"

>From c5e54b273e5f6f9e349f20fac6ab7b8d97a058a6 Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Thu, 28 Sep 2023 05:04:31 -0400
Subject: [PATCH 7/7] address comments related to LIT case

---
 .../Symbolize/XCOFF/xcoff-symbolize-data.ll         | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff-symbolize-data.ll b/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff-symbolize-data.ll
index 4403f20d8a505b7..2202b7e2ec02d80 100644
--- a/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff-symbolize-data.ll
+++ b/llvm/test/DebugInfo/Symbolize/XCOFF/xcoff-symbolize-data.ll
@@ -1,44 +1,51 @@
+;; This file shows that llvm-symbolizer can symbolize data symbols
+;; from the DWARF info on AIX. Note that AIX is big endian.
+
 ; REQUIRES: powerpc-registered-target
 ; RUN: llc -filetype=obj -o %t -mtriple=powerpc-aix-ibm-xcoff < %s
 ; RUN: llvm-symbolizer --obj=%t 'DATA 0x60' 'DATA 0x61' 'DATA 0x64' 'DATA 0X68' \
 ; RUN:   'DATA 0x90' 'DATA 0x94' 'DATA 0X98' | \
 ; RUN:   FileCheck %s
 
-;; This files tests llvm-symbolizer can successfully symbolize the data symbol
-;; from the DWARF info on AIX. Note that AIX is big endian.
-
+;; Test an uninitialized global variable from offset 0.
 ; CHECK: bss_global
 ; CHECK-NEXT: 96 4
 ; CHECK-NEXT: /t.cpp:1
 ; CHECK-EMPTY:
 
+;; Test an uninitialized global variable from offset 1.
 ; CHECK: bss_global
 ; CHECK-NEXT: 96 4
 ; CHECK-NEXT: /t.cpp:1
 ; CHECK-EMPTY:
 
+;; Test an initialized global variable.
 ; CHECK: data_global
 ; CHECK-NEXT: 100 4
 ; CHECK-NEXT: /t.cpp:2
 ; CHECK-EMPTY:
 
+;; Test a pointer type global variable.
 ; CHECK: str
 ; CHECK-NEXT: 104 4
 ; CHECK-NEXT: /t.cpp:4
 ; CHECK-EMPTY:
 
+;; Test a function scope static variable.
 ;; FIXME: fix the wrong size 152
 ; CHECK: f()::function_global
 ; CHECK-NEXT: 144 152
 ; CHECK-NEXT: /t.cpp:8
 ; CHECK-EMPTY:
 
+;; Test a global scope static variable that is used in current compilation unit.
 ;; FIXME: fix the wrong size 152
 ; CHECK: beta
 ; CHECK-NEXT: 148 152
 ; CHECK-NEXT: /t.cpp:13
 ; CHECK-EMPTY:
 
+;; Test another global scope static variable that is used in current compilation unit.
 ;; FIXME: fix the wrong size 152
 ; CHECK: alpha
 ; CHECK-NEXT: 152 152



More information about the llvm-commits mailing list