[PATCH] D52792: Relax trivial cast requirements in CallPromotionUtils
Scott Linder via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 2 11:25:45 PDT 2018
scott.linder updated this revision to Diff 167990.
scott.linder added a comment.
Sorry, moved a little fast and grabbed the wrong patch at first.
https://reviews.llvm.org/D52792
Files:
lib/Transforms/Utils/CallPromotionUtils.cpp
Index: lib/Transforms/Utils/CallPromotionUtils.cpp
===================================================================
--- lib/Transforms/Utils/CallPromotionUtils.cpp
+++ lib/Transforms/Utils/CallPromotionUtils.cpp
@@ -177,8 +177,8 @@
InsertBefore = &*std::next(CS.getInstruction()->getIterator());
// Bitcast the return value to the correct type.
- auto *Cast = CastInst::Create(Instruction::BitCast, CS.getInstruction(),
- RetTy, "", InsertBefore);
+ auto *Cast = CastInst::CreateBitOrPointerCast(CS.getInstruction(), RetTy, "",
+ InsertBefore);
if (RetBitCast)
*RetBitCast = Cast;
@@ -321,12 +321,14 @@
const char **FailureReason) {
assert(!CS.getCalledFunction() && "Only indirect call sites can be promoted");
+ auto &DL = Callee->getParent()->getDataLayout();
+
// Check the return type. The callee's return value type must be bitcast
// compatible with the call site's type.
Type *CallRetTy = CS.getInstruction()->getType();
Type *FuncRetTy = Callee->getReturnType();
if (CallRetTy != FuncRetTy)
- if (!CastInst::isBitCastable(FuncRetTy, CallRetTy)) {
+ if (!CastInst::isBitOrNoopPointerCastable(FuncRetTy, CallRetTy, DL)) {
if (FailureReason)
*FailureReason = "Return type mismatch";
return false;
@@ -351,7 +353,7 @@
Type *ActualTy = CS.getArgument(I)->getType();
if (FormalTy == ActualTy)
continue;
- if (!CastInst::isBitCastable(ActualTy, FormalTy)) {
+ if (!CastInst::isBitOrNoopPointerCastable(ActualTy, FormalTy, DL)) {
if (FailureReason)
*FailureReason = "Argument type mismatch";
return false;
@@ -396,8 +398,8 @@
Type *FormalTy = CalleeType->getParamType(ArgNo);
Type *ActualTy = Arg->getType();
if (FormalTy != ActualTy) {
- auto *Cast = CastInst::Create(Instruction::BitCast, Arg, FormalTy, "",
- CS.getInstruction());
+ auto *Cast = CastInst::CreateBitOrPointerCast(Arg, FormalTy, "",
+ CS.getInstruction());
CS.setArgument(ArgNo, Cast);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52792.167990.patch
Type: text/x-patch
Size: 2213 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181002/5dd79f88/attachment-0001.bin>
More information about the llvm-commits
mailing list