diff options
author | Eric Christopher <echristo@apple.com> | 2010-01-06 20:04:44 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2010-01-06 20:04:44 +0000 |
commit | 2cdb806fd88bccd7d4bf22fa358cc79609492f55 (patch) | |
tree | 77d88f5d2139186ea44b5c16b10209330be44d5a /llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | |
parent | 746012a6c14e86d8a8314cd32e7651e0d51dac08 (diff) | |
download | bcm5719-llvm-2cdb806fd88bccd7d4bf22fa358cc79609492f55.tar.gz bcm5719-llvm-2cdb806fd88bccd7d4bf22fa358cc79609492f55.zip |
Move the object size intrinsic optimization to inst-combine and make
it work for any integer size return type.
llvm-svn: 92853
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 12 |
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); |