File tree 3 files changed +29
-4
lines changed
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) {
985
985
" Referenced value not in value map!" );
986
986
}
987
987
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
+
988
995
// Remap phi nodes' incoming blocks.
989
996
if (PHINode *PN = dyn_cast<PHINode>(I)) {
990
997
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 .
3
3
4
- ; RUN: opt < %s -passes="cgscc( inline),instcombine " -S | FileCheck %s
4
+ ; RUN: opt < %s -passes="inline" -S | FileCheck %s
5
5
6
6
define i32 @_Z13call_indirectPFicEc (ptr %func , i8 %x ) local_unnamed_addr !type !0 {
7
7
entry:
16
16
%call = call i32 @_Z13call_indirectPFicEc (ptr nonnull @_Z3fooc , i8 97 )
17
17
ret i32 %call
18
18
}
19
-
20
19
declare !type !2 i32 @_Z3fooc (i8 signext )
21
20
22
21
!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