aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/BasicAliasAnalysis.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-06 04:27:31 +0000
committerChris Lattner <sabre@nondot.org>2009-11-06 04:27:31 +0000
commit7b550ccfc5a3346c17e0390a59e2d6d19bc52705 (patch)
tree9c3af8482a1eab3d262715e590726e5acf675951 /lib/Analysis/BasicAliasAnalysis.cpp
parent6580da4755cf98aa9b0c32186536e80d7dd41f90 (diff)
remove a bunch of extraneous LLVMContext arguments
from various APIs, addressing PR5325. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86231 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp40
1 files changed, 18 insertions, 22 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index c81190b418..2f4663531a 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -23,7 +23,6 @@
#include "llvm/GlobalVariable.h"
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
-#include "llvm/LLVMContext.h"
#include "llvm/Operator.h"
#include "llvm/Pass.h"
#include "llvm/Target/TargetData.h"
@@ -99,7 +98,7 @@ static bool isNonEscapingLocalObject(const Value *V) {
/// isObjectSmallerThan - Return true if we can prove that the object specified
/// by V is smaller than Size.
static bool isObjectSmallerThan(const Value *V, unsigned Size,
- LLVMContext &Context, const TargetData &TD) {
+ const TargetData &TD) {
const Type *AccessTy;
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
AccessTy = GV->getType()->getElementType();
@@ -109,7 +108,7 @@ static bool isObjectSmallerThan(const Value *V, unsigned Size,
else
return false;
} else if (const CallInst* CI = extractMallocCall(V)) {
- if (!isArrayMalloc(V, Context, &TD))
+ if (!isArrayMalloc(V, &TD))
// The size is the argument to the malloc call.
if (const ConstantInt* C = dyn_cast<ConstantInt>(CI->getOperand(1)))
return (C->getZExtValue() < Size);
@@ -665,10 +664,9 @@ BasicAliasAnalysis::aliasCheck(const Value *V1, unsigned V1Size,
// If the size of one access is larger than the entire object on the other
// side, then we know such behavior is undefined and can assume no alias.
- LLVMContext &Context = V1->getContext();
if (TD)
- if ((V1Size != ~0U && isObjectSmallerThan(O2, V1Size, Context, *TD)) ||
- (V2Size != ~0U && isObjectSmallerThan(O1, V2Size, Context, *TD)))
+ if ((V1Size != ~0U && isObjectSmallerThan(O2, V1Size, *TD)) ||
+ (V2Size != ~0U && isObjectSmallerThan(O1, V2Size, *TD)))
return NoAlias;
// If one pointer is the result of a call/invoke and the other is a
@@ -707,16 +705,16 @@ BasicAliasAnalysis::aliasCheck(const Value *V1, unsigned V1Size,
// This function is used to determine if the indices of two GEP instructions are
// equal. V1 and V2 are the indices.
-static bool IndexOperandsEqual(Value *V1, Value *V2, LLVMContext &Context) {
+static bool IndexOperandsEqual(Value *V1, Value *V2) {
if (V1->getType() == V2->getType())
return V1 == V2;
if (Constant *C1 = dyn_cast<Constant>(V1))
if (Constant *C2 = dyn_cast<Constant>(V2)) {
// Sign extend the constants to long types, if necessary
- if (C1->getType() != Type::getInt64Ty(Context))
- C1 = ConstantExpr::getSExt(C1, Type::getInt64Ty(Context));
- if (C2->getType() != Type::getInt64Ty(Context))
- C2 = ConstantExpr::getSExt(C2, Type::getInt64Ty(Context));
+ if (C1->getType() != Type::getInt64Ty(C1->getContext()))
+ C1 = ConstantExpr::getSExt(C1, Type::getInt64Ty(C1->getContext()));
+ if (C2->getType() != Type::getInt64Ty(C1->getContext()))
+ C2 = ConstantExpr::getSExt(C2, Type::getInt64Ty(C1->getContext()));
return C1 == C2;
}
return false;
@@ -737,8 +735,6 @@ BasicAliasAnalysis::CheckGEPInstructions(
const PointerType *GEPPointerTy = cast<PointerType>(BasePtr1Ty);
- LLVMContext &Context = GEPPointerTy->getContext();
-
// Find the (possibly empty) initial sequence of equal values... which are not
// necessarily constants.
unsigned NumGEP1Operands = NumGEP1Ops, NumGEP2Operands = NumGEP2Ops;
@@ -746,8 +742,7 @@ BasicAliasAnalysis::CheckGEPInstructions(
unsigned MaxOperands = std::max(NumGEP1Operands, NumGEP2Operands);
unsigned UnequalOper = 0;
while (UnequalOper != MinOperands &&
- IndexOperandsEqual(GEP1Ops[UnequalOper], GEP2Ops[UnequalOper],
- Context)) {
+ IndexOperandsEqual(GEP1Ops[UnequalOper], GEP2Ops[UnequalOper])) {
// Advance through the type as we go...
++UnequalOper;
if (const CompositeType *CT = dyn_cast<CompositeType>(BasePtr1Ty))
@@ -811,10 +806,11 @@ BasicAliasAnalysis::CheckGEPInstructions(
if (Constant *G2OC = dyn_cast<ConstantInt>(const_cast<Value*>(G2Oper))){
if (G1OC->getType() != G2OC->getType()) {
// Sign extend both operands to long.
- if (G1OC->getType() != Type::getInt64Ty(Context))
- G1OC = ConstantExpr::getSExt(G1OC, Type::getInt64Ty(Context));
- if (G2OC->getType() != Type::getInt64Ty(Context))
- G2OC = ConstantExpr::getSExt(G2OC, Type::getInt64Ty(Context));
+ const Type *Int64Ty = Type::getInt64Ty(G1OC->getContext());
+ if (G1OC->getType() != Int64Ty)
+ G1OC = ConstantExpr::getSExt(G1OC, Int64Ty);
+ if (G2OC->getType() != Int64Ty)
+ G2OC = ConstantExpr::getSExt(G2OC, Int64Ty);
GEP1Ops[FirstConstantOper] = G1OC;
GEP2Ops[FirstConstantOper] = G2OC;
}
@@ -950,7 +946,7 @@ BasicAliasAnalysis::CheckGEPInstructions(
for (unsigned i = 0; i != FirstConstantOper; ++i) {
if (!isa<StructType>(ZeroIdxTy))
GEP1Ops[i] = GEP2Ops[i] =
- Constant::getNullValue(Type::getInt32Ty(Context));
+ Constant::getNullValue(Type::getInt32Ty(ZeroIdxTy->getContext()));
if (const CompositeType *CT = dyn_cast<CompositeType>(ZeroIdxTy))
ZeroIdxTy = CT->getTypeAtIndex(GEP1Ops[i]);
@@ -992,11 +988,11 @@ BasicAliasAnalysis::CheckGEPInstructions(
//
if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty))
GEP1Ops[i] =
- ConstantInt::get(Type::getInt64Ty(Context),
+ ConstantInt::get(Type::getInt64Ty(AT->getContext()),
AT->getNumElements()-1);
else if (const VectorType *VT = dyn_cast<VectorType>(BasePtr1Ty))
GEP1Ops[i] =
- ConstantInt::get(Type::getInt64Ty(Context),
+ ConstantInt::get(Type::getInt64Ty(VT->getContext()),
VT->getNumElements()-1);
}
}