|
| 1 | +;; This file shows that llvm-symbolizer can symbolize data symbols |
| 2 | +;; from the DWARF info on AIX. Note that AIX is big endian. |
| 3 | + |
| 4 | +;; FIXME: use assembly rather than LLVM IR once integrated assembler supports |
| 5 | +;; AIX assembly syntax. |
| 6 | + |
| 7 | +; REQUIRES: powerpc-registered-target |
| 8 | +; RUN: llc -filetype=obj -o %t -mtriple=powerpc-aix-ibm-xcoff < %s |
| 9 | +; RUN: llvm-symbolizer --obj=%t 'DATA 0x60' 'DATA 0x61' 'DATA 0x64' 'DATA 0X68' \ |
| 10 | +; RUN: 'DATA 0x90' 'DATA 0x94' 'DATA 0X98' | \ |
| 11 | +; RUN: FileCheck %s |
| 12 | + |
| 13 | +;; Test an uninitialized global variable from offset 0. |
| 14 | +; CHECK: bss_global |
| 15 | +; CHECK-NEXT: 96 4 |
| 16 | +; CHECK-NEXT: /t.cpp:1 |
| 17 | +; CHECK-EMPTY: |
| 18 | + |
| 19 | +;; Test an uninitialized global variable from offset 1. |
| 20 | +; CHECK: bss_global |
| 21 | +; CHECK-NEXT: 96 4 |
| 22 | +; CHECK-NEXT: /t.cpp:1 |
| 23 | +; CHECK-EMPTY: |
| 24 | + |
| 25 | +;; Test an initialized global variable. |
| 26 | +; CHECK: data_global |
| 27 | +; CHECK-NEXT: 100 4 |
| 28 | +; CHECK-NEXT: /t.cpp:2 |
| 29 | +; CHECK-EMPTY: |
| 30 | + |
| 31 | +;; Test a pointer type global variable. |
| 32 | +; CHECK: str |
| 33 | +; CHECK-NEXT: 104 4 |
| 34 | +; CHECK-NEXT: /t.cpp:4 |
| 35 | +; CHECK-EMPTY: |
| 36 | + |
| 37 | +;; Test a function scope static variable. |
| 38 | +;; FIXME: fix the wrong size 152 |
| 39 | +; CHECK: f()::function_global |
| 40 | +; CHECK-NEXT: 144 152 |
| 41 | +; CHECK-NEXT: /t.cpp:8 |
| 42 | +; CHECK-EMPTY: |
| 43 | + |
| 44 | +;; Test a global scope static variable that is used in current compilation unit. |
| 45 | +;; FIXME: fix the wrong size 152 |
| 46 | +; CHECK: beta |
| 47 | +; CHECK-NEXT: 148 152 |
| 48 | +; CHECK-NEXT: /t.cpp:13 |
| 49 | +; CHECK-EMPTY: |
| 50 | + |
| 51 | +;; Test another global scope static variable that is used in current compilation unit. |
| 52 | +;; FIXME: fix the wrong size 152 |
| 53 | +; CHECK: alpha |
| 54 | +; CHECK-NEXT: 152 152 |
| 55 | +; CHECK-NEXT: /t.cpp:12 |
| 56 | +; CHECK-EMPTY: |
| 57 | + |
| 58 | +;; The case is from `test/tools/llvm-symbolizer/data-location.yaml`, compiled with: |
| 59 | +;; clang++ -g -gdwarf-3 -O3 t.cpp -nostdlib -target powerpc-aix-ibm-xcoff -S -emit-llvm |
| 60 | + |
| 61 | +;; cat t.cpp |
| 62 | +;; 1 int bss_global; |
| 63 | +;; 2 int data_global = 2; |
| 64 | +;; 3 |
| 65 | +;; 4 const char* str = |
| 66 | +;; 5 "12345678"; |
| 67 | +;; 6 |
| 68 | +;; 7 int* f() { |
| 69 | +;; 8 static int function_global; |
| 70 | +;; 9 return &function_global; |
| 71 | +;; 10 } |
| 72 | +;; 11 |
| 73 | +;; 12 static int alpha; |
| 74 | +;; 13 static int beta; |
| 75 | +;; 14 int *f(bool b) { return beta ? &alpha : β } |
| 76 | +;; 15 |
| 77 | + |
| 78 | +; ModuleID = 't.cpp' |
| 79 | +source_filename = "t.cpp" |
| 80 | +target datalayout = "E-m:a-p:32:32-Fi32-i64:64-n32" |
| 81 | +target triple = "powerpc-ibm-aix-xcoff" |
| 82 | + |
| 83 | +@bss_global = local_unnamed_addr global i32 0, align 4, !dbg !0 |
| 84 | +@data_global = local_unnamed_addr global i32 2, align 4, !dbg !5 |
| 85 | +@.str = private unnamed_addr constant [9 x i8] c"12345678\00", align 1, !dbg !8 |
| 86 | +@str = local_unnamed_addr global ptr @.str, align 4, !dbg !15 |
| 87 | +@_ZZ1fvE15function_global = internal global i32 0, align 4, !dbg !18 |
| 88 | +@_ZL4beta = internal global i32 0, align 4, !dbg !24 |
| 89 | +@_ZL5alpha = internal global i32 0, align 4, !dbg !26 |
| 90 | + |
| 91 | +; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) |
| 92 | +define noundef nonnull ptr @_Z1fv() local_unnamed_addr #0 !dbg !20 { |
| 93 | +entry: |
| 94 | + ret ptr @_ZZ1fvE15function_global, !dbg !34 |
| 95 | +} |
| 96 | + |
| 97 | +; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) |
| 98 | +define noundef nonnull ptr @_Z1fb(i1 noundef zeroext %b) local_unnamed_addr #1 !dbg !35 { |
| 99 | +entry: |
| 100 | + 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 |
| 101 | + %0 = load i32, ptr @_ZL4beta, align 4, !dbg !42, !tbaa !43 |
| 102 | + %tobool.not = icmp eq i32 %0, 0, !dbg !42 |
| 103 | + %cond = select i1 %tobool.not, ptr @_ZL4beta, ptr @_ZL5alpha, !dbg !42 |
| 104 | + ret ptr %cond, !dbg !42 |
| 105 | +} |
| 106 | + |
| 107 | +; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) |
| 108 | +declare void @llvm.dbg.value(metadata, metadata, metadata) #2 |
| 109 | + |
| 110 | +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" } |
| 111 | +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" } |
| 112 | +attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } |
| 113 | + |
| 114 | +!llvm.dbg.cu = !{!2} |
| 115 | +!llvm.module.flags = !{!28, !29, !30, !31, !32} |
| 116 | +!llvm.ident = !{!33} |
| 117 | + |
| 118 | +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) |
| 119 | +!1 = distinct !DIGlobalVariable(name: "bss_global", scope: !2, file: !3, line: 1, type: !7, isLocal: false, isDefinition: true) |
| 120 | +!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) |
| 121 | +!3 = !DIFile(filename: "t.cpp", directory: "/") |
| 122 | +!4 = !{!0, !5, !8, !15, !18, !24, !26} |
| 123 | +!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression()) |
| 124 | +!6 = distinct !DIGlobalVariable(name: "data_global", scope: !2, file: !3, line: 2, type: !7, isLocal: false, isDefinition: true) |
| 125 | +!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 126 | +!8 = !DIGlobalVariableExpression(var: !9, expr: !DIExpression()) |
| 127 | +!9 = distinct !DIGlobalVariable(scope: null, file: !3, line: 5, type: !10, isLocal: true, isDefinition: true) |
| 128 | +!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, size: 72, elements: !13) |
| 129 | +!11 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !12) |
| 130 | +!12 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_unsigned_char) |
| 131 | +!13 = !{!14} |
| 132 | +!14 = !DISubrange(count: 9) |
| 133 | +!15 = !DIGlobalVariableExpression(var: !16, expr: !DIExpression()) |
| 134 | +!16 = distinct !DIGlobalVariable(name: "str", scope: !2, file: !3, line: 4, type: !17, isLocal: false, isDefinition: true) |
| 135 | +!17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32) |
| 136 | +!18 = !DIGlobalVariableExpression(var: !19, expr: !DIExpression()) |
| 137 | +!19 = distinct !DIGlobalVariable(name: "function_global", scope: !20, file: !3, line: 8, type: !7, isLocal: true, isDefinition: true) |
| 138 | +!20 = distinct !DISubprogram(name: "f", linkageName: "_Z1fv", scope: !3, file: !3, line: 7, type: !21, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2) |
| 139 | +!21 = !DISubroutineType(types: !22) |
| 140 | +!22 = !{!23} |
| 141 | +!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 32) |
| 142 | +!24 = !DIGlobalVariableExpression(var: !25, expr: !DIExpression()) |
| 143 | +!25 = distinct !DIGlobalVariable(name: "beta", linkageName: "_ZL4beta", scope: !2, file: !3, line: 13, type: !7, isLocal: true, isDefinition: true) |
| 144 | +!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) |
| 145 | +!27 = distinct !DIGlobalVariable(name: "alpha", linkageName: "_ZL5alpha", scope: !2, file: !3, line: 12, type: !7, isLocal: true, isDefinition: true) |
| 146 | +!28 = !{i32 7, !"Dwarf Version", i32 3} |
| 147 | +!29 = !{i32 2, !"Debug Info Version", i32 3} |
| 148 | +!30 = !{i32 1, !"wchar_size", i32 2} |
| 149 | +!31 = !{i32 8, !"PIC Level", i32 2} |
| 150 | +!32 = !{i32 7, !"debug-info-assignment-tracking", i1 true} |
| 151 | +!33 = !{!"clang version 18.0.0"} |
| 152 | +!34 = !DILocation(line: 9, scope: !20) |
| 153 | +!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) |
| 154 | +!36 = !DISubroutineType(types: !37) |
| 155 | +!37 = !{!23, !38} |
| 156 | +!38 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean) |
| 157 | +!39 = !{!40} |
| 158 | +!40 = !DILocalVariable(name: "b", arg: 1, scope: !35, file: !3, line: 14, type: !38) |
| 159 | +!41 = !DILocation(line: 0, scope: !35) |
| 160 | +!42 = !DILocation(line: 14, scope: !35) |
| 161 | +!43 = !{!44, !44, i64 0} |
| 162 | +!44 = !{!"int", !45, i64 0} |
| 163 | +!45 = !{!"omnipotent char", !46, i64 0} |
| 164 | +!46 = !{!"Simple C++ TBAA"} |
0 commit comments