summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 6aacf5dd0ef..e34360087c6 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -632,6 +632,18 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
return EraseInstFromFunction(CI);
break;
}
+ case Intrinsic::objectsize: {
+ ConstantInt *Const = dyn_cast<ConstantInt>(II->getOperand(2));
+
+ if (!Const) return 0;
+
+ const Type *Ty = CI.getType();
+
+ if (Const->getZExtValue() == 0)
+ return ReplaceInstUsesWith(CI, Constant::getAllOnesValue(Ty));
+ else
+ return ReplaceInstUsesWith(CI, ConstantInt::get(Ty, 0));
+ }
}
return visitCallSite(II);
OpenPOWER on IntegriCloud