File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
lib/Transforms/InstCombine
test/Transforms/InstCombine Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -4111,6 +4111,11 @@ Instruction *InstCombinerImpl::visitCallBase(CallBase &Call) {
41114111 Call, Builder.CreateBitOrPointerCast (ReturnedArg, CallTy));
41124112 }
41134113
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+
41144119 // Drop unnecessary kcfi operand bundles from calls that were converted
41154120 // into direct calls.
41164121 auto Bundle = Call.getOperandBundle (LLVMContext::OB_kcfi);
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