[llvm-commits] [llvm] r95671 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Support/StandardPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/CMakeLists.txt lib/Transforms/Scalar/ObjectSizeLowering.cpp test/Transforms/InstCombine/objsize.ll test/Transforms/ObjSizeLower/
Eric Christopher
echristo at apple.com
Tue Feb 9 09:29:19 PST 2010
Author: echristo
Date: Tue Feb 9 11:29:18 2010
New Revision: 95671
URL: http://llvm.org/viewvc/llvm-project?rev=95671&view=rev
Log:
Pull these back out, they're a little too aggressive and time
consuming for a simple optimization.
Added:
llvm/trunk/test/Transforms/InstCombine/objsize.ll
- copied unchanged from r95627, llvm/trunk/test/Transforms/InstCombine/objsize.ll
Removed:
llvm/trunk/lib/Transforms/Scalar/ObjectSizeLowering.cpp
llvm/trunk/test/Transforms/ObjSizeLower/
Modified:
llvm/trunk/include/llvm/LinkAllPasses.h
llvm/trunk/include/llvm/Support/StandardPasses.h
llvm/trunk/include/llvm/Transforms/Scalar.h
llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt
Modified: llvm/trunk/include/llvm/LinkAllPasses.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllPasses.h?rev=95671&r1=95670&r2=95671&view=diff
==============================================================================
--- llvm/trunk/include/llvm/LinkAllPasses.h (original)
+++ llvm/trunk/include/llvm/LinkAllPasses.h Tue Feb 9 11:29:18 2010
@@ -138,7 +138,6 @@
(void) llvm::createGEPSplitterPass();
(void) llvm::createSCCVNPass();
(void) llvm::createABCDPass();
- (void) llvm::createObjectSizeLoweringPass();
(void)new llvm::IntervalPartition();
(void)new llvm::FindUsedTypes();
Modified: llvm/trunk/include/llvm/Support/StandardPasses.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=95671&r1=95670&r2=95671&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/StandardPasses.h (original)
+++ llvm/trunk/include/llvm/Support/StandardPasses.h Tue Feb 9 11:29:18 2010
@@ -118,6 +118,8 @@
// Start of function pass.
PM->add(createScalarReplAggregatesPass()); // Break up aggregate allocas
+ if (SimplifyLibCalls)
+ PM->add(createSimplifyLibCallsPass()); // Library Call Optimizations
PM->add(createInstructionCombiningPass()); // Cleanup for scalarrepl.
PM->add(createJumpThreadingPass()); // Thread jumps.
PM->add(createCFGSimplificationPass()); // Merge & remove BBs
@@ -126,9 +128,6 @@
PM->add(createTailCallEliminationPass()); // Eliminate tail calls
PM->add(createCFGSimplificationPass()); // Merge & remove BBs
PM->add(createReassociatePass()); // Reassociate expressions
- PM->add(createObjectSizeLoweringPass()); // Lower Intrinsic::objsize
- if (SimplifyLibCalls)
- PM->add(createSimplifyLibCallsPass()); // Library Call Optimizations
PM->add(createLoopRotatePass()); // Rotate Loop
PM->add(createLICMPass()); // Hoist loop invariants
PM->add(createLoopUnswitchPass(OptimizeSize || OptimizationLevel < 3));
Modified: llvm/trunk/include/llvm/Transforms/Scalar.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=95671&r1=95670&r2=95671&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Scalar.h (original)
+++ llvm/trunk/include/llvm/Transforms/Scalar.h Tue Feb 9 11:29:18 2010
@@ -336,12 +336,6 @@
//
FunctionPass *createABCDPass();
-//===----------------------------------------------------------------------===//
-//
-// ObjSizeLowering - Lower Intrinsic::objsize
-//
-FunctionPass *createObjectSizeLoweringPass();
-
} // End llvm namespace
#endif
Modified: llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt?rev=95671&r1=95670&r2=95671&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt (original)
+++ llvm/trunk/lib/Transforms/Scalar/CMakeLists.txt Tue Feb 9 11:29:18 2010
@@ -18,7 +18,6 @@
LoopUnrollPass.cpp
LoopUnswitch.cpp
MemCpyOptimizer.cpp
- ObjectSizeLowering.cpp
Reassociate.cpp
Reg2Mem.cpp
SCCP.cpp
Removed: llvm/trunk/lib/Transforms/Scalar/ObjectSizeLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ObjectSizeLowering.cpp?rev=95670&view=auto
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ObjectSizeLowering.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ObjectSizeLowering.cpp (removed)
@@ -1,114 +0,0 @@
-//===-- ObjectSizeLowering.cpp - Loop unroller pass -----------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This pass lowers Intrinsic::objectsize using SCEV to determine minimum or
-// maximum space left in an allocated object.
-//===----------------------------------------------------------------------===//
-
-#define DEBUG_TYPE "objsize-lower"
-#include "llvm/Constants.h"
-#include "llvm/Module.h"
-#include "llvm/Value.h"
-#include "llvm/Target/TargetData.h"
-#include "llvm/IntrinsicInst.h"
-#include "llvm/Transforms/Scalar.h"
-#include "llvm/Analysis/ScalarEvolution.h"
-#include "llvm/Analysis/ScalarEvolutionExpander.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/raw_ostream.h"
-
-using namespace llvm;
-
-namespace {
- class ObjSizeLower : public FunctionPass {
- ScalarEvolution *SE;
- TargetData *TD;
- public:
- static char ID; // Pass identification, replacement for typeid
- ObjSizeLower() : FunctionPass(&ID) {}
-
- bool runOnFunction(Function &F);
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesCFG();
- AU.addRequired<ScalarEvolution>();
- AU.addPreserved<ScalarEvolution>();
- }
- private:
- bool LowerCall(IntrinsicInst *);
- void ReplaceAllUsesWithUnknown(IntrinsicInst *, bool);
- };
-}
-
-char ObjSizeLower::ID = 0;
-static RegisterPass<ObjSizeLower> X("objsize-lower",
- "Object Size Lowering");
-
-// Public interface to the Object Size Lowering pass
-FunctionPass *llvm::createObjectSizeLoweringPass() {
- return new ObjSizeLower();
-}
-
-/// runOnFunction - Top level algorithm - Loop over each object size intrinsic
-/// and use Scalar Evolutions to get the maximum or minimum size left in the
-/// allocated object at any point.
-bool ObjSizeLower::runOnFunction(Function &F) {
- SE = &getAnalysis<ScalarEvolution>();
- TD = getAnalysisIfAvailable<TargetData>();
-
- // We really need TargetData for size calculations.
- if (!TD) return false;
-
- bool Changed = false;
- for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
- for (BasicBlock::iterator I = BB->begin(), L = BB->end(); I != L; ) {
- CallInst *CI = dyn_cast<CallInst>(I++);
- if (!CI) continue;
-
- // The only thing we care about are Intrinsic::objectsize calls
- IntrinsicInst *II = dyn_cast<IntrinsicInst>(CI);
- if (!II || II->getIntrinsicID() != Intrinsic::objectsize) continue;
-
- Changed |= LowerCall(II);
- }
- }
- return Changed;
-}
-
-// Unknown for llvm.objsize is -1 for maximum size, and 0 for minimum size.
-void ObjSizeLower::ReplaceAllUsesWithUnknown(IntrinsicInst *II, bool min) {
- const Type *ReturnTy = II->getCalledFunction()->getReturnType();
- II->replaceAllUsesWith(ConstantInt::get(ReturnTy, min ? 0 : -1ULL));
- II->eraseFromParent();
-}
-
-bool ObjSizeLower::LowerCall(IntrinsicInst *II) {
- ConstantInt *CI = cast<ConstantInt>(II->getOperand(2));
- bool minimum = (CI->getZExtValue() == 1);
- Value *Op = II->getOperand(1);
- const Type *ReturnTy = II->getCalledFunction()->getReturnType();
-
- // Grab the SCEV for our access.
- const SCEV *thisEV = SE->getSCEV(Op);
-
- if (const SCEVUnknown *SU = dyn_cast<SCEVUnknown>(thisEV)) {
- if (GlobalVariable *GV = dyn_cast<GlobalVariable>(SU->getValue())) {
- if (GV->hasDefinitiveInitializer()) {
- Constant *C = GV->getInitializer();
- size_t globalSize = TD->getTypeAllocSize(C->getType());
- II->replaceAllUsesWith(ConstantInt::get(ReturnTy, globalSize));
- II->eraseFromParent();
- return true;
- }
- }
- }
-
- ReplaceAllUsesWithUnknown(II, minimum);
- return true;
-}
More information about the llvm-commits
mailing list