diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2013-11-10 01:44:37 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2013-11-10 01:44:37 +0000 |
commit | 5bcefabcda5ef0e9b8b355a40875b2a83d302b5d (patch) | |
tree | 057a1b66887972305d9bef8609b60e0d1b6a799a /llvm/lib/Transforms/IPO/MergeFunctions.cpp | |
parent | 3c93dc9f9dea8237fcd6c59417832ad214b40174 (diff) | |
download | bcm5719-llvm-5bcefabcda5ef0e9b8b355a40875b2a83d302b5d.tar.gz bcm5719-llvm-5bcefabcda5ef0e9b8b355a40875b2a83d302b5d.zip |
Teach MergeFunctions about address spaces
llvm-svn: 194342
Diffstat (limited to 'llvm/lib/Transforms/IPO/MergeFunctions.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/MergeFunctions.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp index 7e4c1668455..b8397d6414b 100644 --- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp +++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp @@ -214,9 +214,12 @@ bool FunctionComparator::isEquivalentType(Type *Ty1, Type *Ty2) const { return true; if (Ty1->getTypeID() != Ty2->getTypeID()) { if (TD) { - LLVMContext &Ctx = Ty1->getContext(); - if (isa<PointerType>(Ty1) && Ty2 == TD->getIntPtrType(Ctx)) return true; - if (isa<PointerType>(Ty2) && Ty1 == TD->getIntPtrType(Ctx)) return true; + + if (isa<PointerType>(Ty1) && Ty2 == TD->getIntPtrType(Ty1)) + return true; + + if (isa<PointerType>(Ty2) && Ty1 == TD->getIntPtrType(Ty2)) + return true; } return false; } @@ -352,14 +355,19 @@ bool FunctionComparator::isEquivalentOperation(const Instruction *I1, // Determine whether two GEP operations perform the same underlying arithmetic. bool FunctionComparator::isEquivalentGEP(const GEPOperator *GEP1, const GEPOperator *GEP2) { - // When we have target data, we can reduce the GEP down to the value in bytes - // added to the address. - unsigned BitWidth = TD ? TD->getPointerSizeInBits() : 1; - APInt Offset1(BitWidth, 0), Offset2(BitWidth, 0); - if (TD && - GEP1->accumulateConstantOffset(*TD, Offset1) && - GEP2->accumulateConstantOffset(*TD, Offset2)) { - return Offset1 == Offset2; + unsigned AS = GEP1->getPointerAddressSpace(); + if (AS != GEP2->getPointerAddressSpace()) + return false; + + if (TD) { + // When we have target data, we can reduce the GEP down to the value in bytes + // added to the address. + unsigned BitWidth = TD ? TD->getPointerSizeInBits(AS) : 1; + APInt Offset1(BitWidth, 0), Offset2(BitWidth, 0); + if (GEP1->accumulateConstantOffset(*TD, Offset1) && + GEP2->accumulateConstantOffset(*TD, Offset2)) { + return Offset1 == Offset2; + } } if (GEP1->getPointerOperand()->getType() != |