Skip to content

Commit f7487b3

Browse files
committed
[RISCV] Added test for 32 bit RISC-V
1 parent 08b1675 commit f7487b3

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
;; Test RISC-V 32 bit:
2+
; RUN: llc -emit-call-site-info -stop-after=livedebugvalues -mtriple=riscv32-linux-gnu -o - %s | FileCheck %s --check-prefix=CHECK32
3+
; RUN: llc -force-instr-ref-livedebugvalues=1 -emit-call-site-info -stop-after=livedebugvalues -mtriple=riscv32-linux-gnu -o - %s | FileCheck %s --check-prefix=CHECK32
4+
5+
;; Built from source:
6+
;; extern long fn1(long,long,long);
7+
;; long fn2(long a, long b, long c) {
8+
;; long local = fn1(a+b, c, b+10);
9+
;; if (local > 10)
10+
;; return local + 10;
11+
;; return b;
12+
;; }
13+
;; Using command:
14+
;; clang -g -O2 -target riscv32-linux-gnu m.c -c -S -emit-llvm
15+
;; Confirm that info from callSites attribute is used as entry_value in DIExpression.
16+
17+
;; Test riscv32:
18+
; CHECK32: $x10 = nsw ADD $x11, killed renamable $x10
19+
; CHECK32-NEXT: DBG_VALUE $x10, $noreg, !{{.*}}, !DIExpression(DW_OP_LLVM_entry_value, 1)
20+
21+
; ModuleID = 'm.c'
22+
source_filename = "m.c"
23+
target datalayout = "e-m:e-p:32:32-i64:64-n32-S128"
24+
target triple = "riscv32-unknown-linux-gnu"
25+
26+
; Function Attrs: nounwind uwtable
27+
define i32 @fn2(i32 noundef %a, i32 noundef %b, i32 noundef %c) !dbg !14 {
28+
entry:
29+
#dbg_value(i32 %a, !20, !DIExpression(), !23)
30+
#dbg_value(i32 %b, !21, !DIExpression(), !23)
31+
#dbg_value(i32 %c, !22, !DIExpression(), !23)
32+
%add = add nsw i32 %b, %a
33+
%add1 = add nsw i32 %b, 10
34+
%call = tail call i32 @fn1(i32 noundef %add, i32 noundef %c, i32 noundef %add1)
35+
#dbg_value(i32 %call, !22, !DIExpression(), !23)
36+
%cmp = icmp sgt i32 %call, 10
37+
%add2 = add nuw nsw i32 %call, 10
38+
%retval.0 = select i1 %cmp, i32 %add2, i32 %b
39+
ret i32 %retval.0, !dbg !29
40+
}
41+
42+
declare !dbg !30 i32 @fn1(i32 noundef, i32 noundef, i32 noundef)
43+
44+
!llvm.dbg.cu = !{!0}
45+
!llvm.module.flags = !{!2, !3, !4}
46+
!llvm.ident = !{!5}
47+
48+
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
49+
!1 = !DIFile(filename: "m.c", directory: ".")
50+
!2 = !{i32 7, !"Dwarf Version", i32 5}
51+
!3 = !{i32 2, !"Debug Info Version", i32 3}
52+
!4 = !{i32 1, !"wchar_size", i32 4}
53+
!5 = !{!"clang"}
54+
!14 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 2, type: !15, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !18)
55+
!15 = !DISubroutineType(types: !16)
56+
!16 = !{!17, !17, !17, !17}
57+
!17 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed)
58+
!18 = !{!19, !20, !21, !22}
59+
!19 = !DILocalVariable(name: "a", arg: 1, scope: !14, file: !1, line: 2, type: !17)
60+
!20 = !DILocalVariable(name: "b", arg: 2, scope: !14, file: !1, line: 2, type: !17)
61+
!21 = !DILocalVariable(name: "c", arg: 3, scope: !14, file: !1, line: 2, type: !17)
62+
!22 = !DILocalVariable(name: "local", scope: !14, file: !1, line: 3, type: !17)
63+
!23 = !DILocation(line: 0, scope: !14)
64+
!29 = !DILocation(line: 7, column: 1, scope: !14)
65+
!30 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !15, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
66+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
;; Test RISC-V 64 bit:
2+
; RUN: llc -emit-call-site-info -stop-after=livedebugvalues -mtriple=riscv64-linux-gnu -o - %s | FileCheck %s --check-prefix=CHECK64
3+
; RUN: llc -force-instr-ref-livedebugvalues=1 -emit-call-site-info -stop-after=livedebugvalues -mtriple=riscv64-linux-gnu -o - %s | FileCheck %s --check-prefix=CHECK64
4+
5+
;; Built from source:
6+
;; extern long fn1(long,long,long);
7+
;; long fn2(long a, long b, long c) {
8+
;; long local = fn1(a+b, c, b+10);
9+
;; if (local > 10)
10+
;; return local + 10;
11+
;; return b;
12+
;; }
13+
;; Using command:
14+
;; clang -g -O2 -target riscv64-linux-gnu m.c -c -S -emit-llvm
15+
;; Confirm that info from callSites attribute is used as entry_value in DIExpression.
16+
17+
;; Test riscv64:
18+
; CHECK64: $x10 = nsw ADD $x11, killed renamable $x10
19+
; CHECK64-NEXT: DBG_VALUE $x10, $noreg, !{{.*}}, !DIExpression(DW_OP_LLVM_entry_value, 1)
20+
21+
; ModuleID = 'm.c'
22+
source_filename = "m.c"
23+
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
24+
target triple = "riscv64-unknown-linux-gnu"
25+
26+
; Function Attrs: nounwind uwtable
27+
define i64 @fn2(i64 noundef %a, i64 noundef %b, i64 noundef %c) !dbg !14 {
28+
entry:
29+
#dbg_value(i64 %a, !19, !DIExpression(), !23)
30+
#dbg_value(i64 %b, !20, !DIExpression(), !23)
31+
#dbg_value(i64 %c, !21, !DIExpression(), !23)
32+
%add = add nsw i64 %b, %a
33+
%add1 = add nsw i64 %b, 10
34+
%call = tail call i64 @fn1(i64 noundef %add, i64 noundef %c, i64 noundef %add1)
35+
#dbg_value(i64 %call, !22, !DIExpression(), !23)
36+
%cmp = icmp sgt i64 %call, 10
37+
%add2 = add nuw nsw i64 %call, 10
38+
%retval.0 = select i1 %cmp, i64 %add2, i64 %b
39+
ret i64 %retval.0, !dbg !29
40+
}
41+
42+
declare !dbg !30 i64 @fn1(i64 noundef, i64 noundef, i64 noundef)
43+
44+
!llvm.dbg.cu = !{!0}
45+
!llvm.module.flags = !{!2, !3, !4}
46+
!llvm.ident = !{!5}
47+
48+
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
49+
!1 = !DIFile(filename: "m.c", directory: ".")
50+
!2 = !{i32 7, !"Dwarf Version", i32 5}
51+
!3 = !{i32 2, !"Debug Info Version", i32 3}
52+
!4 = !{i32 1, !"wchar_size", i32 4}
53+
!5 = !{!"clang"}
54+
!14 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 2, type: !15, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !18)
55+
!15 = !DISubroutineType(types: !16)
56+
!16 = !{!17, !17, !17, !17}
57+
!17 = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed)
58+
!18 = !{!19, !20, !21, !22}
59+
!19 = !DILocalVariable(name: "a", arg: 1, scope: !14, file: !1, line: 2, type: !17)
60+
!20 = !DILocalVariable(name: "b", arg: 2, scope: !14, file: !1, line: 2, type: !17)
61+
!21 = !DILocalVariable(name: "c", arg: 3, scope: !14, file: !1, line: 2, type: !17)
62+
!22 = !DILocalVariable(name: "local", scope: !14, file: !1, line: 3, type: !17)
63+
!23 = !DILocation(line: 0, scope: !14)
64+
!29 = !DILocation(line: 7, column: 1, scope: !14)
65+
!30 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !15, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
66+

0 commit comments

Comments
 (0)