diff options
| author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-02-02 21:16:12 +0000 |
|---|---|---|
| committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-02-02 21:16:12 +0000 |
| commit | de4208122b32222a575c4d817adfa080be7b1168 (patch) | |
| tree | bbf2af336edb28cd642e1227b6d4444bde349aac /llvm/lib/Target | |
| parent | 21eecb4f14cd36a7c5beb40437fd70b5a966922d (diff) | |
| download | bcm5719-llvm-de4208122b32222a575c4d817adfa080be7b1168.tar.gz bcm5719-llvm-de4208122b32222a575c4d817adfa080be7b1168.zip | |
AMDGPU: Do not promote allocas with non-inbounds GEPs
If we can't assume the pointer value isn't within the bounds
of the object, it seems risky to try to replace the pointer
calculations.
llvm-svn: 259573
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp index d22fa323521..9f085bfa09b 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp @@ -447,6 +447,13 @@ static bool collectUsesWithPtrTypes(Value *Val, std::vector<Value*> &WorkList) { if (!User->getType()->isPointerTy()) continue; + if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(UseInst)) { + // Be conservative if an address could be computed outside the bounds of + // the alloca. + if (!GEP->isInBounds()) + return false; + } + WorkList.push_back(User); if (!collectUsesWithPtrTypes(User, WorkList)) return false; |

