Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a703c75

Browse files
committed
Rebase on parent.
Created using spr 1.3.6-beta.1
2 parents 64fcf91 + 84e71ce commit a703c75

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

llvm/lib/Transforms/Utils/ValueMapper.cpp

+7
Original file line numberDiff line numberDiff 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) {

llvm/test/Transforms/InstCombine/callee-type-metadata.ll renamed to llvm/test/Transforms/Inline/drop-callee-type-metadata.ll

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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

66
define i32 @_Z13call_indirectPFicEc(ptr %func, i8 %x) local_unnamed_addr !type !0 {
77
entry:
@@ -16,7 +16,6 @@ entry:
1616
%call = call i32 @_Z13call_indirectPFicEc(ptr nonnull @_Z3fooc, i8 97)
1717
ret i32 %call
1818
}
19-
2019
declare !type !2 i32 @_Z3fooc(i8 signext)
2120

2221
!0 = !{i64 0, !"_ZTSFiPvcE.generalized"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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"}

0 commit comments

Comments
 (0)