File tree 3 files changed +36
-6
lines changed
lib/Transforms/InstCombine
3 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -4111,6 +4111,11 @@ Instruction *InstCombinerImpl::visitCallBase(CallBase &Call) {
4111
4111
Call, Builder.CreateBitOrPointerCast (ReturnedArg, CallTy));
4112
4112
}
4113
4113
4114
+ // Drop unnecessary callee_type metadata from calls that were converted
4115
+ // into direct calls.
4116
+ if (Call.getMetadata (LLVMContext::MD_callee_type) && !Call.isIndirectCall ())
4117
+ Call.setMetadata (LLVMContext::MD_callee_type, nullptr );
4118
+
4114
4119
// Drop unnecessary kcfi operand bundles from calls that were converted
4115
4120
// into direct calls.
4116
4121
auto Bundle = Call.getOperandBundle (LLVMContext::OB_kcfi);
Original file line number Diff line number Diff line change 13
13
# CHECK-NEXT: - { bb: {{.*}}, offset: {{.*}}, fwdArgRegs: []
14
14
15
15
--- |
16
- declare noundef i32 @_Z4fizzii(i32 noundef %x, i32 noundef %y)
17
-
18
- declare noundef i32 @_Z4buzzii(i32 noundef %x, i32 noundef %y)
19
-
20
- define dso_local noundef i32 @_Z3barii(i32 noundef %x, i32 noundef %y) {
16
+ declare !type !0 noundef i32 @_Z4fizzii(i32 noundef %x, i32 noundef %y)
17
+
18
+ declare !type !0 noundef i32 @_Z4buzzii(i32 noundef %x, i32 noundef %y)
19
+
20
+ define dso_local noundef i32 @_Z3barii(i32 noundef %x, i32 noundef %y) !type !0 {
21
21
entry :
22
22
%x.addr = alloca i32, align 4
23
23
%y.addr = alloca i32, align 4
33
33
ret i32 %sub
34
34
}
35
35
36
- define dso_local noundef i32 @_Z3fooii(i32 noundef %x, i32 noundef %y) {
36
+ define dso_local noundef i32 @_Z3fooii(i32 noundef %x, i32 noundef %y) !type !0 {
37
37
entry :
38
38
%x.addr = alloca i32, align 4
39
39
%y.addr = alloca i32, align 4
Original file line number Diff line number Diff line change
1
+ ;; Test if the callee_type metadata is dropped when an indirect function call through a function ptr is promoted
2
+ ;; to a direct function call during instcombine.
3
+
4
+ ; RUN: opt < %s -O2 | llvm-dis | FileCheck %s
5
+
6
+ define dso_local noundef i32 @_Z13call_indirectPFicEc (ptr noundef %func , i8 noundef signext %x ) local_unnamed_addr !type !0 {
7
+ entry:
8
+ %call = call noundef i32 %func (i8 noundef signext %x ), !callee_type !1
9
+ ret i32 %call
10
+ }
11
+
12
+ define dso_local noundef i32 @_Z3barv () local_unnamed_addr !type !3 {
13
+ entry:
14
+ ; CHECK: %call.i = tail call noundef i32 @_Z3fooc(i8 noundef signext 97)
15
+ ; CHECK-NOT: %call.i = tail call noundef i32 @_Z3fooc(i8 noundef signext 97), !callee_type !1
16
+ %call = call noundef i32 @_Z13call_indirectPFicEc (ptr noundef nonnull @_Z3fooc , i8 noundef signext 97 )
17
+ ret i32 %call
18
+ }
19
+
20
+ declare !type !2 noundef i32 @_Z3fooc (i8 noundef signext )
21
+
22
+ !0 = !{i64 0 , !"_ZTSFiPvcE.generalized" }
23
+ !1 = !{!2 }
24
+ !2 = !{i64 0 , !"_ZTSFicE.generalized" }
25
+ !3 = !{i64 0 , !"_ZTSFivE.generalized" }
You can’t perform that action at this time.
0 commit comments