diff options
author | Scott Linder <scott@scottlinder.com> | 2018-10-10 16:35:47 +0000 |
---|---|---|
committer | Scott Linder <scott@scottlinder.com> | 2018-10-10 16:35:47 +0000 |
commit | 3759efc650aa0fcc75de954d7de1649aca0d6f9d (patch) | |
tree | ff4b9bca4ee13bc9c4a002c701b2affb3d747837 /llvm/lib/Transforms/Utils/CallPromotionUtils.cpp | |
parent | 611a55a084b44423f99e1009a71cdb0daf54312d (diff) | |
download | bcm5719-llvm-3759efc650aa0fcc75de954d7de1649aca0d6f9d.tar.gz bcm5719-llvm-3759efc650aa0fcc75de954d7de1649aca0d6f9d.zip |
Relax trivial cast requirements in CallPromotionUtils
Differential Revision: https://reviews.llvm.org/D52792
llvm-svn: 344153
Diffstat (limited to 'llvm/lib/Transforms/Utils/CallPromotionUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/CallPromotionUtils.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp b/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp index 6d18d061461..261ab87c3e7 100644 --- a/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp +++ b/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp @@ -177,8 +177,8 @@ static void createRetBitCast(CallSite CS, Type *RetTy, CastInst **RetBitCast) { 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 @@ bool llvm::isLegalToPromote(CallSite CS, Function *Callee, 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 @@ bool llvm::isLegalToPromote(CallSite CS, Function *Callee, 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 @@ Instruction *llvm::promoteCall(CallSite CS, Function *Callee, 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); } } |