summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/MemoryBuiltins.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2013-12-14 00:27:48 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2013-12-14 00:27:48 +0000
commitd3ee7af2f4b1de29cb4312eff874c60f78a187cd (patch)
treee949a0ef08ecc5b3cb2b889314d1438a14cbb13f /llvm/lib/Analysis/MemoryBuiltins.cpp
parent092647b37a9ea0d84fe88942b29adc2f06da8bbc (diff)
downloadbcm5719-llvm-d3ee7af2f4b1de29cb4312eff874c60f78a187cd.tar.gz
bcm5719-llvm-d3ee7af2f4b1de29cb4312eff874c60f78a187cd.zip
Teach MemoryBuiltins about address spaces
llvm-svn: 197292
Diffstat (limited to 'llvm/lib/Analysis/MemoryBuiltins.cpp')
-rw-r--r--llvm/lib/Analysis/MemoryBuiltins.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp
index 1db0f634c94..37e2e271cee 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -399,12 +399,14 @@ ObjectSizeOffsetVisitor::ObjectSizeOffsetVisitor(const DataLayout *DL,
LLVMContext &Context,
bool RoundToAlign)
: DL(DL), TLI(TLI), RoundToAlign(RoundToAlign) {
- IntegerType *IntTy = DL->getIntPtrType(Context);
- IntTyBits = IntTy->getBitWidth();
- Zero = APInt::getNullValue(IntTyBits);
+ // Pointer size must be rechecked for each object visited since it could have
+ // a different address space.
}
SizeOffsetType ObjectSizeOffsetVisitor::compute(Value *V) {
+ IntTyBits = DL->getPointerTypeSizeInBits(V->getType());
+ Zero = APInt::getNullValue(IntTyBits);
+
V = V->stripPointerCasts();
if (Instruction *I = dyn_cast<Instruction>(V)) {
// If we have already seen this instruction, bail out. Cycles can happen in
@@ -592,11 +594,15 @@ ObjectSizeOffsetEvaluator::ObjectSizeOffsetEvaluator(const DataLayout *DL,
bool RoundToAlign)
: DL(DL), TLI(TLI), Context(Context), Builder(Context, TargetFolder(DL)),
RoundToAlign(RoundToAlign) {
- IntTy = DL->getIntPtrType(Context);
- Zero = ConstantInt::get(IntTy, 0);
+ // IntTy and Zero must be set for each compute() since the address space may
+ // be different for later objects.
}
SizeOffsetEvalType ObjectSizeOffsetEvaluator::compute(Value *V) {
+ // XXX - Are vectors of pointers possible here?
+ IntTy = cast<IntegerType>(DL->getIntPtrType(V->getType()));
+ Zero = ConstantInt::get(IntTy, 0);
+
SizeOffsetEvalType Result = compute_(V);
if (!bothKnown(Result)) {
OpenPOWER on IntegriCloud