Skip to content

Commit 1a8d810

Browse files
necipfazilPrabhuk
authored andcommitted
Fixed the tests and addressed most of the review comments.
Created using spr 1.3.6-beta.1
1 parent 460f02a commit 1a8d810

File tree

7 files changed

+71
-127
lines changed

7 files changed

+71
-127
lines changed

llvm/include/llvm/CodeGen/MachineFunction.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction {
493493
/// Callee type id.
494494
ConstantInt *TypeId = nullptr;
495495

496-
CallSiteInfo() {}
496+
CallSiteInfo() = default;
497497

498498
/// Extracts the numeric type id from the CallBase's type operand bundle,
499499
/// and sets TypeId. This is used as type id for the indirect call in the
@@ -503,12 +503,11 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction {
503503
if (!CB.isIndirectCall())
504504
return;
505505

506-
auto Opt = CB.getOperandBundle(LLVMContext::OB_type);
507-
if (!Opt.has_value()) {
508-
errs() << "warning: cannot find indirect call type operand bundle for "
509-
"call graph section\n";
506+
std::optional<OperandBundleUse> Opt =
507+
CB.getOperandBundle(LLVMContext::OB_type);
508+
// Return if the operand bundle for call graph section cannot be found.
509+
if (!Opt.has_value())
510510
return;
511-
}
512511

513512
// Get generalized type id string
514513
auto OB = Opt.value();
@@ -520,9 +519,9 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction {
520519
"invalid type identifier");
521520

522521
// Compute numeric type id from generalized type id string
523-
uint64_t TypeIdVal = llvm::MD5Hash(TypeIdStr->getString());
522+
uint64_t TypeIdVal = MD5Hash(TypeIdStr->getString());
524523
IntegerType *Int64Ty = Type::getInt64Ty(CB.getContext());
525-
TypeId = llvm::ConstantInt::get(Int64Ty, TypeIdVal, /*IsSigned=*/false);
524+
TypeId = ConstantInt::get(Int64Ty, TypeIdVal, /*IsSigned=*/false);
526525
}
527526
};
528527

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
; Tests that call site type ids can be extracted and set from type operand
2-
; bundles.
1+
;; Tests that call site type ids can be extracted and set from type operand
2+
;; bundles.
33

4-
; Verify the exact typeId value to ensure it is not garbage but the value
5-
; computed as the type id from the type operand bundle.
6-
; RUN: llc --call-graph-section -mtriple aarch64-linux-gnu %s -stop-before=finalize-isel -o - | FileCheck %s
7-
8-
; ModuleID = 'test.c'
9-
source_filename = "test.c"
10-
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
11-
target triple = "aarch64-unknown-linux-gnu"
4+
;; Verify the exact typeId value to ensure it is not garbage but the value
5+
;; computed as the type id from the type operand bundle.
6+
; RUN: llc --call-graph-section -mtriple aarch64-linux-gnu < %s -stop-before=finalize-isel -o - | FileCheck %s
127

138
define dso_local void @foo(i8 signext %a) !type !3 {
149
entry:
@@ -19,21 +14,16 @@ entry:
1914
define dso_local i32 @main() !type !4 {
2015
entry:
2116
%retval = alloca i32, align 4
22-
%fp = alloca void (i8)*, align 8
23-
store i32 0, i32* %retval, align 4
24-
store void (i8)* @foo, void (i8)** %fp, align 8
25-
%0 = load void (i8)*, void (i8)** %fp, align 8
17+
%fp = alloca ptr, align 8
18+
store i32 0, ptr %retval, align 4
19+
store ptr @foo, ptr %fp, align 8
20+
%0 = load ptr, ptr %fp, align 8
2621
; CHECK: callSites:
2722
; CHECK-NEXT: - { bb: {{.*}}, offset: {{.*}}, fwdArgRegs: [], typeId:
2823
; CHECK-NEXT: 7854600665770582568 }
2924
call void %0(i8 signext 97) [ "type"(metadata !"_ZTSFvcE.generalized") ]
3025
ret i32 0
3126
}
3227

33-
!llvm.module.flags = !{!0, !1, !2}
34-
35-
!0 = !{i32 1, !"wchar_size", i32 4}
36-
!1 = !{i32 7, !"uwtable", i32 1}
37-
!2 = !{i32 7, !"frame-pointer", i32 2}
3828
!3 = !{i64 0, !"_ZTSFvcE.generalized"}
3929
!4 = !{i64 0, !"_ZTSFiE.generalized"}
Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
; Tests that call site type ids can be extracted and set from type operand
2-
; bundles.
1+
;; Tests that call site type ids can be extracted and set from type operand
2+
;; bundles.
33

4-
; Verify the exact typeId value to ensure it is not garbage but the value
5-
; computed as the type id from the type operand bundle.
6-
; RUN: llc --call-graph-section -mtriple arm-linux-gnu %s -stop-before=finalize-isel -o - | FileCheck %s
7-
8-
; ModuleID = 'test.c'
9-
source_filename = "test.c"
10-
target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
11-
target triple = "armv4t-unknown-linux-gnu"
4+
;; Verify the exact typeId value to ensure it is not garbage but the value
5+
;; computed as the type id from the type operand bundle.
6+
; RUN: llc --call-graph-section -mtriple arm-linux-gnu < %s -stop-before=finalize-isel -o - | FileCheck %s
127

138
define dso_local void @foo(i8 signext %a) !type !3 {
149
entry:
@@ -19,21 +14,16 @@ entry:
1914
define dso_local i32 @main() !type !4 {
2015
entry:
2116
%retval = alloca i32, align 4
22-
%fp = alloca void (i8)*, align 8
23-
store i32 0, i32* %retval, align 4
24-
store void (i8)* @foo, void (i8)** %fp, align 8
25-
%0 = load void (i8)*, void (i8)** %fp, align 8
17+
%fp = alloca ptr, align 8
18+
store i32 0, ptr %retval, align 4
19+
store ptr @foo, ptr %fp, align 8
20+
%0 = load ptr, ptr %fp, align 8
2621
; CHECK: callSites:
2722
; CHECK-NEXT: - { bb: {{.*}}, offset: {{.*}}, fwdArgRegs: [], typeId:
2823
; CHECK-NEXT: 7854600665770582568 }
2924
call void %0(i8 signext 97) [ "type"(metadata !"_ZTSFvcE.generalized") ]
3025
ret i32 0
3126
}
3227

33-
!llvm.module.flags = !{!0, !1, !2}
34-
35-
!0 = !{i32 1, !"wchar_size", i32 4}
36-
!1 = !{i32 7, !"uwtable", i32 1}
37-
!2 = !{i32 7, !"frame-pointer", i32 2}
3828
!3 = !{i64 0, !"_ZTSFvcE.generalized"}
3929
!4 = !{i64 0, !"_ZTSFiE.generalized"}
Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
; Test MIR printer and parser for type id field in call site info. Test that
2-
; it works well with/without --emit-call-site-info.
1+
;; Test MIR printer and parser for type id field in call site info. Test that
2+
;; it works well with/without --emit-call-site-info.
33

4-
; Multiplex --call-graph-section and -emit-call-site-info as both utilize
5-
; CallSiteInfo and callSites.
4+
;; Multiplex --call-graph-section and -emit-call-site-info as both utilize
5+
;; CallSiteInfo and callSites.
66

77
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
88
;; Test printer and parser with --call-graph-section only.
99

10-
; Test printer.
11-
; Verify that fwdArgRegs is not set, typeId is set.
12-
; Verify the exact typeId value to ensure it is not garbage but the value
13-
; computed as the type id from the type operand bundle.
10+
;; Test printer.
11+
;; Verify that fwdArgRegs is not set, typeId is set.
12+
;; Verify the exact typeId value to ensure it is not garbage but the value
13+
;; computed as the type id from the type operand bundle.
1414
; RUN: llc --call-graph-section %s -stop-before=finalize-isel -o %t1.mir
1515
; RUN: cat %t1.mir | FileCheck %s --check-prefix=PRINTER_CGS
1616
; PRINTER_CGS: name: main
@@ -19,8 +19,8 @@
1919
; PRINTER_CGS-NEXT: 7854600665770582568 }
2020

2121

22-
; Test parser.
23-
; Verify that we get the same result.
22+
;; Test parser.
23+
;; Verify that we get the same result.
2424
; RUN: llc --call-graph-section %t1.mir -run-pass=finalize-isel -o - \
2525
; RUN: | FileCheck %s --check-prefix=PARSER_CGS
2626
; PARSER_CGS: name: main
@@ -31,8 +31,8 @@
3131
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3232
;; Test printer and parser with -emit-call-site-info only.
3333

34-
; Test printer.
35-
; Verify that fwdArgRegs is set, typeId is not set.
34+
;; Test printer.
35+
;; Verify that fwdArgRegs is set, typeId is not set.
3636
; RUN: llc -emit-call-site-info %s -stop-before=finalize-isel -o %t2.mir
3737
; RUN: cat %t2.mir | FileCheck %s --check-prefix=PRINTER_CSI
3838
; PRINTER_CSI: name: main
@@ -42,8 +42,8 @@
4242
; PRINTER_CSI-NOT: typeId:
4343

4444

45-
; Test parser.
46-
; Verify that we get the same result.
45+
;; Test parser.
46+
;; Verify that we get the same result.
4747
; RUN: llc -emit-call-site-info %t2.mir -run-pass=finalize-isel -o - \
4848
; RUN: | FileCheck %s --check-prefix=PARSER_CSI
4949
; PARSER_CSI: name: main
@@ -55,10 +55,10 @@
5555
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5656
;; Test printer and parser with both -emit-call-site-info and --call-graph-section.
5757

58-
; Test printer.
59-
; Verify both fwdArgRegs and typeId are set.
60-
; Verify the exact typeId value to ensure it is not garbage but the value
61-
; computed as the type id from the type operand bundle.
58+
;; Test printer.
59+
;; Verify both fwdArgRegs and typeId are set.
60+
;; Verify the exact typeId value to ensure it is not garbage but the value
61+
;; computed as the type id from the type operand bundle.
6262
; RUN: llc --call-graph-section -emit-call-site-info %s -stop-before=finalize-isel -o %t2.mir
6363
; RUN: cat %t2.mir | FileCheck %s --check-prefix=PRINTER_CGS_CSI
6464
; PRINTER_CGS_CSI: name: main
@@ -68,8 +68,8 @@
6868
; PRINTER_CGS_CSI-NEXT: 7854600665770582568 }
6969

7070

71-
; Test parser.
72-
; Verify that we get the same result.
71+
;; Test parser.
72+
;; Verify that we get the same result.
7373
; RUN: llc --call-graph-section -emit-call-site-info %t2.mir -run-pass=finalize-isel -o - \
7474
; RUN: | FileCheck %s --check-prefix=PARSER_CGS_CSI
7575
; PARSER_CGS_CSI: name: main
@@ -80,11 +80,6 @@
8080

8181
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8282

83-
; ModuleID = 'test.c'
84-
source_filename = "test.c"
85-
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
86-
target triple = "x86_64-unknown-linux-gnu"
87-
8883
; Function Attrs: noinline nounwind optnone uwtable
8984
define dso_local void @foo(i8 signext %a) !type !3 {
9085
entry:
@@ -95,18 +90,13 @@ entry:
9590
define dso_local i32 @main() !type !4 {
9691
entry:
9792
%retval = alloca i32, align 4
98-
%fp = alloca void (i8)*, align 8
99-
store i32 0, i32* %retval, align 4
100-
store void (i8)* @foo, void (i8)** %fp, align 8
101-
%0 = load void (i8)*, void (i8)** %fp, align 8
93+
%fp = alloca ptr, align 8
94+
store i32 0, ptr %retval, align 4
95+
store ptr @foo, ptr %fp, align 8
96+
%0 = load ptr, ptr %fp, align 8
10297
call void %0(i8 signext 97) [ "type"(metadata !"_ZTSFvcE.generalized") ]
10398
ret i32 0
10499
}
105100

106-
!llvm.module.flags = !{!0, !1, !2}
107-
108-
!0 = !{i32 1, !"wchar_size", i32 4}
109-
!1 = !{i32 7, !"uwtable", i32 1}
110-
!2 = !{i32 7, !"frame-pointer", i32 2}
111101
!3 = !{i64 0, !"_ZTSFvcE.generalized"}
112102
!4 = !{i64 0, !"_ZTSFiE.generalized"}

llvm/test/CodeGen/MIR/X86/call-site-info-typeid.mir

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
# CHECK-NEXT: 123456789 }
99

1010
--- |
11-
; ModuleID = 'test.ll'
12-
source_filename = "test.ll"
13-
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
14-
target triple = "x86_64-unknown-linux-gnu"
15-
1611
define dso_local void @foo(i8 signext %a) {
1712
entry:
1813
ret void
@@ -21,10 +16,10 @@
2116
define dso_local i32 @main() {
2217
entry:
2318
%retval = alloca i32, align 4
24-
%fp = alloca void (i8)*, align 8
25-
store i32 0, i32* %retval, align 4
26-
store void (i8)* @foo, void (i8)** %fp, align 8
27-
%0 = load void (i8)*, void (i8)** %fp, align 8
19+
%fp = alloca ptr, align 8
20+
store i32 0, ptr %retval, align 4
21+
store ptr @foo, ptr %fp, align 8
22+
%0 = load ptr, ptr %fp, align 8
2823
call void %0(i8 signext 97)
2924
ret i32 0
3025
}
Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
; Tests that call site type ids can be extracted and set from type operand
2-
; bundles.
1+
;; Tests that call site type ids can be extracted and set from type operand
2+
;; bundles.
33

4-
; Verify the exact typeId value to ensure it is not garbage but the value
5-
; computed as the type id from the type operand bundle.
6-
; RUN: llc --call-graph-section -mtriple=mips-linux-gnu %s -stop-before=finalize-isel -o - | FileCheck %s
7-
8-
; ModuleID = 'test.c'
9-
source_filename = "test.c"
10-
target datalayout = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
11-
target triple = "mips-unknown-linux-gnu"
4+
;; Verify the exact typeId value to ensure it is not garbage but the value
5+
;; computed as the type id from the type operand bundle.
6+
; RUN: llc --call-graph-section -mtriple=mips-linux-gnu < %s -stop-before=finalize-isel -o - | FileCheck %s
127

138
define dso_local void @foo(i8 signext %a) !type !3 {
149
entry:
@@ -19,21 +14,16 @@ entry:
1914
define dso_local i32 @main() !type !4 {
2015
entry:
2116
%retval = alloca i32, align 4
22-
%fp = alloca void (i8)*, align 8
23-
store i32 0, i32* %retval, align 4
24-
store void (i8)* @foo, void (i8)** %fp, align 8
25-
%0 = load void (i8)*, void (i8)** %fp, align 8
17+
%fp = alloca ptr, align 8
18+
store i32 0, ptr %retval, align 4
19+
store ptr @foo, ptr %fp, align 8
20+
%0 = load ptr, ptr %fp, align 8
2621
; CHECK: callSites:
2722
; CHECK-NEXT: - { bb: {{.*}}, offset: {{.*}}, fwdArgRegs: [], typeId:
2823
; CHECK-NEXT: 7854600665770582568 }
2924
call void %0(i8 signext 97) [ "type"(metadata !"_ZTSFvcE.generalized") ]
3025
ret i32 0
3126
}
3227

33-
!llvm.module.flags = !{!0, !1, !2}
34-
35-
!0 = !{i32 1, !"wchar_size", i32 4}
36-
!1 = !{i32 7, !"uwtable", i32 1}
37-
!2 = !{i32 7, !"frame-pointer", i32 2}
3828
!3 = !{i64 0, !"_ZTSFvcE.generalized"}
3929
!4 = !{i64 0, !"_ZTSFiE.generalized"}
Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
; Tests that call site type ids can be extracted and set from type operand
2-
; bundles.
1+
;; Tests that call site type ids can be extracted and set from type operand
2+
;; bundles.
33

4-
; Verify the exact typeId value to ensure it is not garbage but the value
5-
; computed as the type id from the type operand bundle.
6-
; RUN: llc --call-graph-section -mtriple=x86_64-unknown-linux %s -stop-before=finalize-isel -o - | FileCheck %s
7-
8-
; ModuleID = 'test.c'
9-
source_filename = "test.c"
10-
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
11-
target triple = "x86_64-unknown-linux-gnu"
4+
;; Verify the exact typeId value to ensure it is not garbage but the value
5+
;; computed as the type id from the type operand bundle.
6+
; RUN: llc --call-graph-section -mtriple=x86_64-unknown-linux < %s -stop-before=finalize-isel -o - | FileCheck %s
127

138
define dso_local void @foo(i8 signext %a) !type !3 {
149
entry:
@@ -19,21 +14,16 @@ entry:
1914
define dso_local i32 @main() !type !4 {
2015
entry:
2116
%retval = alloca i32, align 4
22-
%fp = alloca void (i8)*, align 8
23-
store i32 0, i32* %retval, align 4
24-
store void (i8)* @foo, void (i8)** %fp, align 8
25-
%0 = load void (i8)*, void (i8)** %fp, align 8
17+
%fp = alloca ptr, align 8
18+
store i32 0, ptr %retval, align 4
19+
store ptr @foo, ptr %fp, align 8
20+
%0 = load ptr, ptr %fp, align 8
2621
; CHECK: callSites:
2722
; CHECK-NEXT: - { bb: {{.*}}, offset: {{.*}}, fwdArgRegs: [], typeId:
2823
; CHECK-NEXT: 7854600665770582568 }
2924
call void %0(i8 signext 97) [ "type"(metadata !"_ZTSFvcE.generalized") ]
3025
ret i32 0
3126
}
3227

33-
!llvm.module.flags = !{!0, !1, !2}
34-
35-
!0 = !{i32 1, !"wchar_size", i32 4}
36-
!1 = !{i32 7, !"uwtable", i32 1}
37-
!2 = !{i32 7, !"frame-pointer", i32 2}
3828
!3 = !{i64 0, !"_ZTSFvcE.generalized"}
3929
!4 = !{i64 0, !"_ZTSFiE.generalized"}

0 commit comments

Comments
 (0)