[llvm-commits] [llvm] r92853 - in /llvm/trunk/lib/Transforms: InstCombine/InstCombineCalls.cpp Scalar/SimplifyLibCalls.cpp
Eric Christopher
echristo at apple.com
Wed Jan 6 12:04:44 PST 2010
Author: echristo
Date: Wed Jan 6 14:04:44 2010
New Revision: 92853
URL: http://llvm.org/viewvc/llvm-project?rev=92853&view=rev
Log:
Move the object size intrinsic optimization to inst-combine and make
it work for any integer size return type.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=92853&r1=92852&r2=92853&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Wed Jan 6 14:04:44 2010
@@ -632,6 +632,18 @@
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);
Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=92853&r1=92852&r2=92853&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Wed Jan 6 14:04:44 2010
@@ -1095,27 +1095,6 @@
//===----------------------------------------------------------------------===//
//===---------------------------------------===//
-// 'object size'
-namespace {
-struct SizeOpt : public LibCallOptimization {
- virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
- // TODO: We can do more with this, but delaying to here should be no change
- // in behavior.
- ConstantInt *Const = dyn_cast<ConstantInt>(CI->getOperand(2));
-
- if (!Const) return 0;
-
- const Type *Ty = Callee->getFunctionType()->getReturnType();
-
- if (Const->getZExtValue() == 0)
- return Constant::getAllOnesValue(Ty);
- else
- return ConstantInt::get(Ty, 0);
- }
-};
-}
-
-//===---------------------------------------===//
// 'memcpy_chk' Optimizations
struct MemCpyChkOpt : public LibCallOptimization {
@@ -1745,7 +1724,6 @@
FWriteOpt FWrite; FPutsOpt FPuts; FPrintFOpt FPrintF;
// Object Size Checking
- SizeOpt ObjectSize;
MemCpyChkOpt MemCpyChk; MemSetChkOpt MemSetChk; MemMoveChkOpt MemMoveChk;
bool Modified; // This is only used by doInitialization.
@@ -1855,8 +1833,6 @@
Optimizations["fprintf"] = &FPrintF;
// Object Size Checking
- Optimizations["llvm.objectsize.i32"] = &ObjectSize;
- Optimizations["llvm.objectsize.i64"] = &ObjectSize;
Optimizations["__memcpy_chk"] = &MemCpyChk;
Optimizations["__memset_chk"] = &MemSetChk;
Optimizations["__memmove_chk"] = &MemMoveChk;
More information about the llvm-commits
mailing list