diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2014-10-31 20:52:04 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2014-10-31 20:52:04 +0000 |
commit | 5b2927fe83c93ce44efba945bedeefd6a13f8de8 (patch) | |
tree | 5da5cf6d29bd9841e4ff0de199b9aad77d9e1373 /llvm/lib/Target/R600/AMDGPUPromoteAlloca.cpp | |
parent | aa73831757c93afa414030db56d180e1ec7b8274 (diff) | |
download | bcm5719-llvm-5b2927fe83c93ce44efba945bedeefd6a13f8de8.tar.gz bcm5719-llvm-5b2927fe83c93ce44efba945bedeefd6a13f8de8.zip |
R600: Don't promote allocas when one of the users is a ptrtoint instruction
We need to figure out how to track ptrtoint values all the
way until result is converted back to a pointer in order
to correctly rewrite the pointer type.
llvm-svn: 220997
Diffstat (limited to 'llvm/lib/Target/R600/AMDGPUPromoteAlloca.cpp')
-rw-r--r-- | llvm/lib/Target/R600/AMDGPUPromoteAlloca.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/llvm/lib/Target/R600/AMDGPUPromoteAlloca.cpp b/llvm/lib/Target/R600/AMDGPUPromoteAlloca.cpp index 8e85b03d4eb..b81fef47d55 100644 --- a/llvm/lib/Target/R600/AMDGPUPromoteAlloca.cpp +++ b/llvm/lib/Target/R600/AMDGPUPromoteAlloca.cpp @@ -234,7 +234,8 @@ static bool tryPromoteAllocaToVector(AllocaInst *Alloca) { return true; } -static void collectUsesWithPtrTypes(Value *Val, std::vector<Value*> &WorkList) { +static bool collectUsesWithPtrTypes(Value *Val, std::vector<Value*> &WorkList) { + bool Success = true; for (User *User : Val->users()) { if(std::find(WorkList.begin(), WorkList.end(), User) != WorkList.end()) continue; @@ -242,11 +243,20 @@ static void collectUsesWithPtrTypes(Value *Val, std::vector<Value*> &WorkList) { WorkList.push_back(User); continue; } + + // FIXME: Correctly handle ptrtoint instructions. + Instruction *UseInst = dyn_cast<Instruction>(User); + if (UseInst && UseInst->getOpcode() == Instruction::PtrToInt) + return false; + if (!User->getType()->isPointerTy()) continue; + WorkList.push_back(User); - collectUsesWithPtrTypes(User, WorkList); + + Success &= collectUsesWithPtrTypes(User, WorkList); } + return Success; } void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) { @@ -274,6 +284,13 @@ void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) { return; } + std::vector<Value*> WorkList; + + if (!collectUsesWithPtrTypes(&I, WorkList)) { + DEBUG(dbgs() << " Do not know how to convert all uses\n"); + return; + } + DEBUG(dbgs() << "Promoting alloca to local memory\n"); LocalMemAvailable -= AllocaSize; @@ -320,10 +337,6 @@ void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) { I.replaceAllUsesWith(Offset); I.eraseFromParent(); - std::vector<Value*> WorkList; - - collectUsesWithPtrTypes(Offset, WorkList); - for (std::vector<Value*>::iterator i = WorkList.begin(), e = WorkList.end(); i != e; ++i) { Value *V = *i; |