[PATCH] D16775: AMDGPU: Report AMDGPUPromoteAlloca changed the function
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 1 09:54:21 PST 2016
arsenm created this revision.
arsenm added a reviewer: tstellarAMD.
arsenm added a subscriber: llvm-commits.
Herald added a subscriber: arsenm.
http://reviews.llvm.org/D16775
Files:
lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
Index: lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
===================================================================
--- lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
+++ lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
@@ -101,51 +101,50 @@
if (!TM)
return false;
- const AMDGPUSubtarget &ST = TM->getSubtarget<AMDGPUSubtarget>(F);
-
FunctionType *FTy = F.getFunctionType();
- LocalMemAvailable = ST.getLocalMemorySize();
-
// If the function has any arguments in the local address space, then it's
// possible these arguments require the entire local memory space, so
// we cannot use local memory in the pass.
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
Type *ParamTy = FTy->getParamType(i);
if (ParamTy->isPointerTy() &&
ParamTy->getPointerAddressSpace() == AMDGPUAS::LOCAL_ADDRESS) {
- LocalMemAvailable = 0;
DEBUG(dbgs() << "Function has local memory argument. Promoting to "
"local memory disabled.\n");
- break;
+ return false;
}
}
- if (LocalMemAvailable > 0) {
- // Check how much local memory is being used by global objects
- for (Module::global_iterator I = Mod->global_begin(),
- E = Mod->global_end(); I != E; ++I) {
- GlobalVariable *GV = &*I;
- if (GV->getType()->getAddressSpace() != AMDGPUAS::LOCAL_ADDRESS)
+ const AMDGPUSubtarget &ST = TM->getSubtarget<AMDGPUSubtarget>(F);
+ LocalMemAvailable = ST.getLocalMemorySize();
+ if (LocalMemAvailable == 0)
+ return false;
+
+
+ // Check how much local memory is being used by global objects
+ for (Module::global_iterator I = Mod->global_begin(),
+ E = Mod->global_end(); I != E; ++I) {
+ GlobalVariable *GV = &*I;
+ if (GV->getType()->getAddressSpace() != AMDGPUAS::LOCAL_ADDRESS)
+ continue;
+ for (Value::use_iterator U = GV->use_begin(),
+ UE = GV->use_end(); U != UE; ++U) {
+ Instruction *Use = dyn_cast<Instruction>(*U);
+ if (!Use)
continue;
- for (Value::use_iterator U = GV->use_begin(),
- UE = GV->use_end(); U != UE; ++U) {
- Instruction *Use = dyn_cast<Instruction>(*U);
- if (!Use)
- continue;
- if (Use->getParent()->getParent() == &F)
- LocalMemAvailable -=
- Mod->getDataLayout().getTypeAllocSize(GV->getValueType());
- }
+ if (Use->getParent()->getParent() == &F)
+ LocalMemAvailable -=
+ Mod->getDataLayout().getTypeAllocSize(GV->getValueType());
}
}
LocalMemAvailable = std::max(0, LocalMemAvailable);
DEBUG(dbgs() << LocalMemAvailable << "bytes free in local memory.\n");
visit(F);
- return false;
+ return true;
}
std::pair<Value *, Value *>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16775.46552.patch
Type: text/x-patch
Size: 2790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160201/c8c4007c/attachment.bin>
More information about the llvm-commits
mailing list