summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2016-12-20 23:46:36 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2016-12-20 23:46:36 +0000
commit3f08914e7e58d195818f38f396b9550a7d896ea9 (patch)
treea727a581aaa563a7a076f66cf3bab96ed61e18c9 /llvm/lib/CodeGen
parente52614b5c7c25d4b674aa304b6a6e18c1d201c2e (diff)
downloadbcm5719-llvm-3f08914e7e58d195818f38f396b9550a7d896ea9.tar.gz
bcm5719-llvm-3f08914e7e58d195818f38f396b9550a7d896ea9.zip
[Analysis] Centralize objectsize lowering logic.
We're currently doing nearly the same thing for @llvm.objectsize in three different places: two of them are missing checks for overflow, and one of them could subtly break if InstCombine gets much smarter about removing alloc sites. Seems like a good idea to not do that. llvm-svn: 290214
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp14
1 files changed, 2 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 1e5d682a331..3dea9eb6b1f 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -1948,18 +1948,8 @@ bool CodeGenPrepare::optimizeCallInst(CallInst *CI, bool& ModifiedDT) {
default: break;
case Intrinsic::objectsize: {
// Lower all uses of llvm.objectsize.*
- uint64_t Size;
- Type *ReturnTy = CI->getType();
- Constant *RetVal = nullptr;
- ConstantInt *Op1 = cast<ConstantInt>(II->getArgOperand(1));
- ObjSizeMode Mode = Op1->isZero() ? ObjSizeMode::Max : ObjSizeMode::Min;
- if (getObjectSize(II->getArgOperand(0),
- Size, *DL, TLInfo, false, Mode)) {
- RetVal = ConstantInt::get(ReturnTy, Size);
- } else {
- RetVal = ConstantInt::get(ReturnTy,
- Mode == ObjSizeMode::Min ? 0 : -1ULL);
- }
+ ConstantInt *RetVal =
+ lowerObjectSizeCall(II, *DL, TLInfo, /*MustSucceed=*/true);
// Substituting this can cause recursive simplifications, which can
// invalidate our iterator. Use a WeakVH to hold onto it in case this
// happens.
OpenPOWER on IntegriCloud