summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2019-07-01 22:43:39 +0000
committerReid Kleckner <rnk@google.com>2019-07-01 22:43:39 +0000
commitd72163947a531249d2b3cc0a95154cc9d43b2d46 (patch)
tree24f933572277dd029b488fe8778fbfa4741c97e4 /llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
parent86e4d7ea35eee5329e960d20dedda02ff9968aad (diff)
downloadbcm5719-llvm-d72163947a531249d2b3cc0a95154cc9d43b2d46.tar.gz
bcm5719-llvm-d72163947a531249d2b3cc0a95154cc9d43b2d46.zip
[PGO] Update ICP pass for recent byval type changes
Fixes verifier errors encountered in PR42413. Reviewers: xur, t.p.northover, inglorion, gbiv, george.burgess.iv Differential Revision: https://reviews.llvm.org/D63842 llvm-svn: 364861
Diffstat (limited to 'llvm/lib/Transforms/Utils/CallPromotionUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/CallPromotionUtils.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp b/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
index 1cb883517e8..f04d76e70c0 100644
--- a/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
+++ b/llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
@@ -412,6 +412,15 @@ Instruction *llvm::promoteCall(CallSite CS, Function *Callee,
// Remove any incompatible attributes for the argument.
AttrBuilder ArgAttrs(CallerPAL.getParamAttributes(ArgNo));
ArgAttrs.remove(AttributeFuncs::typeIncompatible(FormalTy));
+
+ // If byval is used, this must be a pointer type, and the byval type must
+ // match the element type. Update it if present.
+ if (ArgAttrs.getByValType()) {
+ Type *NewTy = Callee->getParamByValType(ArgNo);
+ ArgAttrs.addByValAttr(
+ NewTy ? NewTy : cast<PointerType>(FormalTy)->getElementType());
+ }
+
NewArgAttrs.push_back(AttributeSet::get(Ctx, ArgAttrs));
AttributeChanged = true;
} else
OpenPOWER on IntegriCloud