|
| 1 | +; RUN: rm -rf %t && split-file %s %t && cd %t |
| 2 | +; RUN: llc -filetype=obj a.ll -o a.o |
| 3 | +; RUN: llvm-readelf -r a.o 2>err | FileCheck %s --check-prefix=RELOC |
| 4 | +; RUN: llvm-objdump -Sl --no-show-raw-insn a.o 2>err | FileCheck %s |
| 5 | +;; Test that ULEB128 relocs do not lead to spurious warnings. |
| 6 | +;; https://github.com/llvm/llvm-project/issues/101544 |
| 7 | +; RUN: count 0 < err |
| 8 | + |
| 9 | +; RELOC: Relocation section '.rela.debug_loclists' |
| 10 | +; RELOC: R_RISCV_SET_ULEB128 |
| 11 | +; RELOC-NEXT: R_RISCV_SUB_ULEB128 |
| 12 | + |
| 13 | +; CHECK: ; foo(): |
| 14 | +; CHECK-NEXT: /proc/self/cwd/a.c:2 |
| 15 | +; CHECK-NEXT: ; int foo(int x) { |
| 16 | +; CHECK-NEXT: 0: addi sp, sp, -0x10 |
| 17 | +; CHECK-NEXT: 2: sd ra, 0x8(sp) |
| 18 | +; CHECK-NEXT: /proc/self/cwd/a.c:3 |
| 19 | +; CHECK-NEXT: ; ext(); |
| 20 | +; CHECK-NEXT: 4: auipc ra, 0x0 |
| 21 | + |
| 22 | +;--- a.c |
| 23 | +int ext(void); |
| 24 | +int foo(int x) { |
| 25 | + ext(); |
| 26 | + return 0; |
| 27 | +} |
| 28 | + |
| 29 | +int ext(void); |
| 30 | +void foo2() { |
| 31 | + { |
| 32 | + int ret = ext(); |
| 33 | + if (__builtin_expect(ret, 0)) |
| 34 | + ext(); |
| 35 | + } |
| 36 | +} |
| 37 | +;--- gen |
| 38 | +clang --target=riscv64-linux -S -emit-llvm -g -O1 a.c -o - | sed -E '/^attribute/s/,-[-0-9a-z]+//g' |
| 39 | +;--- a.ll |
| 40 | +; ModuleID = 'a.c' |
| 41 | +source_filename = "a.c" |
| 42 | +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128" |
| 43 | +target triple = "riscv64-unknown-linux" |
| 44 | + |
| 45 | +; Function Attrs: nounwind uwtable |
| 46 | +define dso_local noundef signext i32 @foo(i32 noundef signext %x) local_unnamed_addr #0 !dbg !13 { |
| 47 | +entry: |
| 48 | + #dbg_value(i32 %x, !18, !DIExpression(), !19) |
| 49 | + %call = tail call signext i32 @ext() #2, !dbg !20 |
| 50 | + ret i32 0, !dbg !21 |
| 51 | +} |
| 52 | + |
| 53 | +declare !dbg !22 signext i32 @ext() local_unnamed_addr #1 |
| 54 | + |
| 55 | +; Function Attrs: nounwind uwtable |
| 56 | +define dso_local void @foo2() local_unnamed_addr #0 !dbg !25 { |
| 57 | +entry: |
| 58 | + %call = tail call signext i32 @ext() #2, !dbg !31 |
| 59 | + #dbg_value(i32 %call, !29, !DIExpression(), !32) |
| 60 | + %tobool.not = icmp eq i32 %call, 0, !dbg !33 |
| 61 | + br i1 %tobool.not, label %if.end, label %if.then, !dbg !35, !prof !36 |
| 62 | + |
| 63 | +if.then: ; preds = %entry |
| 64 | + %call1 = tail call signext i32 @ext() #2, !dbg !37 |
| 65 | + br label %if.end, !dbg !37 |
| 66 | + |
| 67 | +if.end: ; preds = %if.then, %entry |
| 68 | + ret void, !dbg !38 |
| 69 | +} |
| 70 | + |
| 71 | +attributes #0 = { nounwind uwtable "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv64" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,+zicsr,+zmmul" } |
| 72 | +attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv64" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,+zicsr,+zmmul" } |
| 73 | +attributes #2 = { nounwind } |
| 74 | + |
| 75 | +!llvm.dbg.cu = !{!0} |
| 76 | +!llvm.module.flags = !{!2, !3, !4, !5, !6, !8, !9, !10, !11, !12} |
| 77 | + |
| 78 | +!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) |
| 79 | +!1 = !DIFile(filename: "a.c", directory: "/proc/self/cwd", checksumkind: CSK_MD5, checksum: "4791066d0b0e4fd9c4b4df1c56f349cb") |
| 80 | +!2 = !{i32 7, !"Dwarf Version", i32 5} |
| 81 | +!3 = !{i32 2, !"Debug Info Version", i32 3} |
| 82 | +!4 = !{i32 1, !"wchar_size", i32 4} |
| 83 | +!5 = !{i32 1, !"target-abi", !"lp64d"} |
| 84 | +!6 = !{i32 6, !"riscv-isa", !7} |
| 85 | +!7 = !{!"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zmmul1p0"} |
| 86 | +!8 = !{i32 8, !"PIC Level", i32 2} |
| 87 | +!9 = !{i32 7, !"PIE Level", i32 2} |
| 88 | +!10 = !{i32 7, !"uwtable", i32 2} |
| 89 | +!11 = !{i32 8, !"SmallDataLimit", i32 8} |
| 90 | +!12 = !{i32 7, !"debug-info-assignment-tracking", i1 true} |
| 91 | +!13 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !14, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !17) |
| 92 | +!14 = !DISubroutineType(types: !15) |
| 93 | +!15 = !{!16, !16} |
| 94 | +!16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 95 | +!17 = !{!18} |
| 96 | +!18 = !DILocalVariable(name: "x", arg: 1, scope: !13, file: !1, line: 2, type: !16) |
| 97 | +!19 = !DILocation(line: 0, scope: !13) |
| 98 | +!20 = !DILocation(line: 3, column: 3, scope: !13) |
| 99 | +!21 = !DILocation(line: 4, column: 3, scope: !13) |
| 100 | +!22 = !DISubprogram(name: "ext", scope: !1, file: !1, line: 1, type: !23, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) |
| 101 | +!23 = !DISubroutineType(types: !24) |
| 102 | +!24 = !{!16} |
| 103 | +!25 = distinct !DISubprogram(name: "foo2", scope: !1, file: !1, line: 8, type: !26, scopeLine: 8, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !28) |
| 104 | +!26 = !DISubroutineType(types: !27) |
| 105 | +!27 = !{null} |
| 106 | +!28 = !{!29} |
| 107 | +!29 = !DILocalVariable(name: "ret", scope: !30, file: !1, line: 10, type: !16) |
| 108 | +!30 = distinct !DILexicalBlock(scope: !25, file: !1, line: 9, column: 3) |
| 109 | +!31 = !DILocation(line: 10, column: 15, scope: !30) |
| 110 | +!32 = !DILocation(line: 0, scope: !30) |
| 111 | +!33 = !DILocation(line: 11, column: 9, scope: !34) |
| 112 | +!34 = distinct !DILexicalBlock(scope: !30, file: !1, line: 11, column: 9) |
| 113 | +!35 = !DILocation(line: 11, column: 9, scope: !30) |
| 114 | +!36 = !{!"branch_weights", !"expected", i32 2000, i32 1} |
| 115 | +!37 = !DILocation(line: 12, column: 7, scope: !34) |
| 116 | +!38 = !DILocation(line: 14, column: 1, scope: !25) |
0 commit comments