summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/PtrUseVisitor.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2019-06-14 21:38:31 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2019-06-14 21:38:31 +0000
commit282dac717eb440dd44d31fe8c3750650bd4d2cff (patch)
treecf9bafffa6eb5d8acf5efc2ac739d9c6be672328 /llvm/lib/Analysis/PtrUseVisitor.cpp
parentbbab7acedf40620243eba2b8d6625f660a59a087 (diff)
downloadbcm5719-llvm-282dac717eb440dd44d31fe8c3750650bd4d2cff.tar.gz
bcm5719-llvm-282dac717eb440dd44d31fe8c3750650bd4d2cff.zip
SROA: Allow eliminating addrspacecasted allocas
There is a circular dependency between SROA and InferAddressSpaces today that requires running both multiple times in order to be able to eliminate all simple allocas and addrspacecasts. InferAddressSpaces can't remove addrspacecasts when written to memory, and SROA helps move pointers out of memory. This should avoid inserting new commuting addrspacecasts with GEPs, since there are unresolved questions about pointer wrapping between different address spaces. For now, don't replace volatile operations that don't match the alloca addrspace, as it would change the address space of the access. It may be still OK to insert an addrspacecast from the new alloca, but be more conservative for now. llvm-svn: 363462
Diffstat (limited to 'llvm/lib/Analysis/PtrUseVisitor.cpp')
-rw-r--r--llvm/lib/Analysis/PtrUseVisitor.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/PtrUseVisitor.cpp b/llvm/lib/Analysis/PtrUseVisitor.cpp
index f78446c6fb4..9a834ba4866 100644
--- a/llvm/lib/Analysis/PtrUseVisitor.cpp
+++ b/llvm/lib/Analysis/PtrUseVisitor.cpp
@@ -34,5 +34,11 @@ bool detail::PtrUseVisitorBase::adjustOffsetForGEP(GetElementPtrInst &GEPI) {
if (!IsOffsetKnown)
return false;
- return GEPI.accumulateConstantOffset(DL, Offset);
+ APInt TmpOffset(DL.getIndexTypeSizeInBits(GEPI.getType()), 0);
+ if (GEPI.accumulateConstantOffset(DL, TmpOffset)) {
+ Offset += TmpOffset.sextOrTrunc(Offset.getBitWidth());
+ return true;
+ }
+
+ return false;
}
OpenPOWER on IntegriCloud