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