summaryrefslogtreecommitdiffstats
path: root/polly/lib/CodeGen/LoopGenerators.cpp
diff options
context:
space:
mode:
authorJohannes Doerfert <doerfert@cs.uni-saarland.de>2014-10-03 19:12:05 +0000
committerJohannes Doerfert <doerfert@cs.uni-saarland.de>2014-10-03 19:12:05 +0000
commit1356ac75d1e99d6f26d198a691f727b23e811c09 (patch)
tree39454dc2019fe80e46d9dcb3517562b8421d7ee0 /polly/lib/CodeGen/LoopGenerators.cpp
parent990cd4c2e27368583c7f4f684f91e9523014e3d3 (diff)
downloadbcm5719-llvm-1356ac75d1e99d6f26d198a691f727b23e811c09.tar.gz
bcm5719-llvm-1356ac75d1e99d6f26d198a691f727b23e811c09.zip
Put the parallel context alloca into the function entry block.
We use lifetime markers to limit the actual life range (similar to clang). Differential Revision: http://reviews.llvm.org/D5582 llvm-svn: 219005
Diffstat (limited to 'polly/lib/CodeGen/LoopGenerators.cpp')
-rw-r--r--polly/lib/CodeGen/LoopGenerators.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/polly/lib/CodeGen/LoopGenerators.cpp b/polly/lib/CodeGen/LoopGenerators.cpp
index 10595f90341..c0994b3d643 100644
--- a/polly/lib/CodeGen/LoopGenerators.cpp
+++ b/polly/lib/CodeGen/LoopGenerators.cpp
@@ -168,6 +168,11 @@ Value *ParallelLoopGenerator::createParallelLoop(
Builder.CreateCall(SubFn, SubFnParam);
createCallJoinThreads();
+ // Mark the end of the lifetime for the parameter struct.
+ Type *Ty = Struct->getType();
+ ConstantInt *SizeOf = Builder.getInt64(DL.getTypeAllocSize(Ty));
+ Builder.CreateLifetimeEnd(Struct, SizeOf);
+
return IV;
}
@@ -273,9 +278,17 @@ ParallelLoopGenerator::storeValuesIntoStruct(SetVector<Value *> &Values) {
for (Value *V : Values)
Members.push_back(V->getType());
+ // We do not want to allocate the alloca inside any loop, thus we allocate it
+ // in the entry block of the function and use annotations to denote the actual
+ // live span (similar to clang).
+ BasicBlock &EntryBB = Builder.GetInsertBlock()->getParent()->getEntryBlock();
+ Instruction *IP = EntryBB.getFirstInsertionPt();
StructType *Ty = StructType::get(Builder.getContext(), Members);
- Value *Struct =
- new AllocaInst(Ty, 0, "polly.par.userContext", Builder.GetInsertPoint());
+ Value *Struct = new AllocaInst(Ty, 0, "polly.par.userContext", IP);
+
+ // Mark the start of the lifetime for the parameter struct.
+ ConstantInt *SizeOf = Builder.getInt64(DL.getTypeAllocSize(Ty));
+ Builder.CreateLifetimeStart(Struct, SizeOf);
for (unsigned i = 0; i < Values.size(); i++) {
Value *Address = Builder.CreateStructGEP(Struct, i);
OpenPOWER on IntegriCloud