diff options
Diffstat (limited to 'lib/Analysis/IPA')
-rw-r--r-- | lib/Analysis/IPA/Andersens.cpp | 27 | ||||
-rw-r--r-- | lib/Analysis/IPA/CallGraph.cpp | 3 | ||||
-rw-r--r-- | lib/Analysis/IPA/GlobalsModRef.cpp | 15 |
3 files changed, 23 insertions, 22 deletions
diff --git a/lib/Analysis/IPA/Andersens.cpp b/lib/Analysis/IPA/Andersens.cpp index 1c9159dfbfcc1..17f304c021193 100644 --- a/lib/Analysis/IPA/Andersens.cpp +++ b/lib/Analysis/IPA/Andersens.cpp @@ -59,12 +59,11 @@ #include "llvm/Instructions.h" #include "llvm/Module.h" #include "llvm/Pass.h" -#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/InstIterator.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Analysis/AliasAnalysis.h" -#include "llvm/Analysis/MallocHelper.h" +#include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/Analysis/Passes.h" #include "llvm/Support/Debug.h" #include "llvm/System/Atomic.h" @@ -126,8 +125,8 @@ namespace { static bool isPod() { return true; } }; - class VISIBILITY_HIDDEN Andersens : public ModulePass, public AliasAnalysis, - private InstVisitor<Andersens> { + class Andersens : public ModulePass, public AliasAnalysis, + private InstVisitor<Andersens> { struct Node; /// Constraint - Objects of this structure are used to represent the various @@ -594,11 +593,12 @@ namespace { void visitReturnInst(ReturnInst &RI); void visitInvokeInst(InvokeInst &II) { visitCallSite(CallSite(&II)); } void visitCallInst(CallInst &CI) { - if (isMalloc(&CI)) visitAllocationInst(CI); + if (isMalloc(&CI)) visitAlloc(CI); else visitCallSite(CallSite(&CI)); } void visitCallSite(CallSite CS); - void visitAllocationInst(Instruction &I); + void visitAllocaInst(AllocaInst &I); + void visitAlloc(Instruction &I); void visitLoadInst(LoadInst &LI); void visitStoreInst(StoreInst &SI); void visitGetElementPtrInst(GetElementPtrInst &GEP); @@ -792,7 +792,7 @@ void Andersens::IdentifyObjects(Module &M) { // object. if (isa<PointerType>(II->getType())) { ValueNodes[&*II] = NumObjects++; - if (AllocationInst *AI = dyn_cast<AllocationInst>(&*II)) + if (AllocaInst *AI = dyn_cast<AllocaInst>(&*II)) ObjectNodes[AI] = NumObjects++; else if (isMalloc(&*II)) ObjectNodes[&*II] = NumObjects++; @@ -1016,6 +1016,8 @@ bool Andersens::AnalyzeUsesOfFunction(Value *V) { } } else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(*UI)) { if (AnalyzeUsesOfFunction(GEP)) return true; + } else if (isFreeCall(*UI)) { + return false; } else if (CallInst *CI = dyn_cast<CallInst>(*UI)) { // Make sure that this is just the function being called, not that it is // passing into the function. @@ -1037,8 +1039,6 @@ bool Andersens::AnalyzeUsesOfFunction(Value *V) { } else if (ICmpInst *ICI = dyn_cast<ICmpInst>(*UI)) { if (!isa<ConstantPointerNull>(ICI->getOperand(1))) return true; // Allow comparison against null. - } else if (isa<FreeInst>(*UI)) { - return false; } else { return true; } @@ -1156,7 +1156,6 @@ void Andersens::visitInstruction(Instruction &I) { case Instruction::Switch: case Instruction::Unwind: case Instruction::Unreachable: - case Instruction::Free: case Instruction::ICmp: case Instruction::FCmp: return; @@ -1167,7 +1166,11 @@ void Andersens::visitInstruction(Instruction &I) { } } -void Andersens::visitAllocationInst(Instruction &I) { +void Andersens::visitAllocaInst(AllocaInst &I) { + visitAlloc(I); +} + +void Andersens::visitAlloc(Instruction &I) { unsigned ObjectIndex = getObject(&I); GraphNodes[ObjectIndex].setValue(&I); Constraints.push_back(Constraint(Constraint::AddressOf, getNodeValue(I), @@ -2819,7 +2822,7 @@ void Andersens::PrintNode(const Node *N) const { else errs() << "(unnamed)"; - if (isa<GlobalValue>(V) || isa<AllocationInst>(V) || isMalloc(V)) + if (isa<GlobalValue>(V) || isa<AllocaInst>(V) || isMalloc(V)) if (N == &GraphNodes[getObject(V)]) errs() << "<mem>"; } diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index e2b288d1ba96c..9cd8bb8c2df1b 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -17,7 +17,6 @@ #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" #include "llvm/Support/CallSite.h" -#include "llvm/Support/Compiler.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -26,7 +25,7 @@ namespace { //===----------------------------------------------------------------------===// // BasicCallGraph class definition // -class VISIBILITY_HIDDEN BasicCallGraph : public CallGraph, public ModulePass { +class BasicCallGraph : public CallGraph, public ModulePass { // Root is root of the call graph, or the external node if a 'main' function // couldn't be found. // diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index 7949288340a8f..ddd6ff9bd8253 100644 --- a/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/lib/Analysis/IPA/GlobalsModRef.cpp @@ -23,8 +23,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/CallGraph.h" -#include "llvm/Analysis/MallocHelper.h" -#include "llvm/Support/Compiler.h" +#include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/InstIterator.h" #include "llvm/ADT/Statistic.h" @@ -44,7 +43,7 @@ namespace { /// function in the program. Later, the entries for these functions are /// removed if the function is found to call an external function (in which /// case we know nothing about it. - struct VISIBILITY_HIDDEN FunctionRecord { + struct FunctionRecord { /// GlobalInfo - Maintain mod/ref info for all of the globals without /// addresses taken that are read or written (transitively) by this /// function. @@ -69,8 +68,7 @@ namespace { }; /// GlobalsModRef - The actual analysis pass. - class VISIBILITY_HIDDEN GlobalsModRef - : public ModulePass, public AliasAnalysis { + class GlobalsModRef : public ModulePass, public AliasAnalysis { /// NonAddressTakenGlobals - The globals that do not have their addresses /// taken. std::set<GlobalValue*> NonAddressTakenGlobals; @@ -240,6 +238,8 @@ bool GlobalsModRef::AnalyzeUsesOfPointer(Value *V, } else if (BitCastInst *BCI = dyn_cast<BitCastInst>(*UI)) { if (AnalyzeUsesOfPointer(BCI, Readers, Writers, OkayStoreDest)) return true; + } else if (isFreeCall(*UI)) { + Writers.push_back(cast<Instruction>(*UI)->getParent()->getParent()); } else if (CallInst *CI = dyn_cast<CallInst>(*UI)) { // Make sure that this is just the function being called, not that it is // passing into the function. @@ -261,8 +261,6 @@ bool GlobalsModRef::AnalyzeUsesOfPointer(Value *V, } else if (ICmpInst *ICI = dyn_cast<ICmpInst>(*UI)) { if (!isa<ConstantPointerNull>(ICI->getOperand(1))) return true; // Allow comparison against null. - } else if (FreeInst *F = dyn_cast<FreeInst>(*UI)) { - Writers.push_back(F->getParent()->getParent()); } else { return true; } @@ -439,7 +437,8 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) { if (cast<StoreInst>(*II).isVolatile()) // Treat volatile stores as reading memory somewhere. FunctionEffect |= Ref; - } else if (isMalloc(&cast<Instruction>(*II)) || isa<FreeInst>(*II)) { + } else if (isMalloc(&cast<Instruction>(*II)) || + isFreeCall(&cast<Instruction>(*II))) { FunctionEffect |= ModRef; } |