File tree Expand file tree Collapse file tree 3 files changed +29
-4
lines changed Expand file tree Collapse file tree 3 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -985,6 +985,13 @@ void Mapper::remapInstruction(Instruction *I) {
985985 " Referenced value not in value map!" );
986986 }
987987
988+ // Drop callee_type metadata from calls that were remapped
989+ // into a direct call from an indirect one.
990+ if (auto *CB = dyn_cast<CallBase>(I)) {
991+ if (CB->getMetadata (LLVMContext::MD_callee_type) && !CB->isIndirectCall ())
992+ CB->setMetadata (LLVMContext::MD_callee_type, nullptr );
993+ }
994+
988995 // Remap phi nodes' incoming blocks.
989996 if (PHINode *PN = dyn_cast<PHINode>(I)) {
990997 for (unsigned i = 0 , e = PN->getNumIncomingValues (); i != e; ++i) {
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 .
1+ ;; Test if the callee_type metadata is dropped when it is
2+ ;; is mapped to a direct function call from an indirect call during inlining .
33
4- ; RUN: opt < %s -passes="cgscc( inline),instcombine " -S | FileCheck %s
4+ ; RUN: opt < %s -passes="inline" -S | FileCheck %s
55
66define i32 @_Z13call_indirectPFicEc (ptr %func , i8 %x ) local_unnamed_addr !type !0 {
77entry:
1616 %call = call i32 @_Z13call_indirectPFicEc (ptr nonnull @_Z3fooc , i8 97 )
1717 ret i32 %call
1818}
19-
2019declare !type !2 i32 @_Z3fooc (i8 signext )
2120
2221!0 = !{i64 0 , !"_ZTSFiPvcE.generalized" }
Original file line number Diff line number Diff line change 1+ ;; Test if the callee_type metadata is dropped when it is attached
2+ ;; to a direct function call during instcombine.
3+
4+ ; RUN: opt < %s -passes="instcombine" -disable-verify -S | FileCheck %s
5+
6+ define i32 @_Z3barv () local_unnamed_addr !type !3 {
7+ entry:
8+ ; CHECK: %call = call i32 @_Z3fooc(i8 97)
9+ ; CHECK-NOT: %call = call i32 @_Z3fooc(i8 97), !callee_type !1
10+ %call = call i32 @_Z3fooc (i8 97 ), !callee_type !1
11+ ret i32 %call
12+ }
13+
14+ declare !type !2 i32 @_Z3fooc (i8 signext )
15+
16+ !0 = !{i64 0 , !"_ZTSFiPvcE.generalized" }
17+ !1 = !{!2 }
18+ !2 = !{i64 0 , !"_ZTSFicE.generalized" }
19+ !3 = !{i64 0 , !"_ZTSFivE.generalized" }
You can’t perform that action at this time.
0 commit comments