From c7b719fc032ec29af7fa0181292fb6b08854d74d Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Wed, 1 Oct 2014 20:10:44 +0000 Subject: Annotate LLVM-IR for all parallel loops This change allows to annotate all parallel loops with loop id metadata. Furthermore, it will annotate memory instructions with llvm.mem.parallel_loop_access metadata for all surrounding parallel loops. This is especially usefull if an external paralleliser is used. This also removes the PollyLoopInfo class and comments the LoopAnnotator. A test case for multiple parallel loops is attached. llvm-svn: 218793 --- polly/lib/CodeGen/LoopGenerators.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'polly/lib/CodeGen/LoopGenerators.cpp') diff --git a/polly/lib/CodeGen/LoopGenerators.cpp b/polly/lib/CodeGen/LoopGenerators.cpp index ef9bda58fd5..1ec9fb85026 100644 --- a/polly/lib/CodeGen/LoopGenerators.cpp +++ b/polly/lib/CodeGen/LoopGenerators.cpp @@ -64,12 +64,6 @@ Value *polly::createLoop(Value *LB, Value *UB, Value *Stride, BasicBlock *PreHeaderBB = BasicBlock::Create(Context, "polly.loop_preheader", F); - if (Annotator) { - Annotator->Begin(HeaderBB); - if (Parallel) - Annotator->SetCurrentParallel(); - } - // Update LoopInfo Loop *OuterLoop = LI.getLoopFor(BeforeBB); Loop *NewLoop = new Loop(); @@ -86,6 +80,11 @@ Value *polly::createLoop(Value *LB, Value *UB, Value *Stride, NewLoop->addBasicBlockToLoop(HeaderBB, LI.getBase()); + // Notify the annotator (if present) that we have a new loop, but only + // after the header block is set. + if (Annotator) + Annotator->pushLoop(NewLoop, Parallel); + // ExitBB ExitBB = SplitBlock(BeforeBB, Builder.GetInsertPoint()++, P); ExitBB->setName("polly.loop_exit"); @@ -122,7 +121,12 @@ Value *polly::createLoop(Value *LB, Value *UB, Value *Stride, UB = Builder.CreateSub(UB, Stride, "polly.adjust_ub"); LoopCondition = Builder.CreateICmp(Predicate, IV, UB); LoopCondition->setName("polly.loop_cond"); - Builder.CreateCondBr(LoopCondition, HeaderBB, ExitBB); + + // Create the loop latch and annotate it as such. + BranchInst *B = Builder.CreateCondBr(LoopCondition, HeaderBB, ExitBB); + if (Annotator) + Annotator->annotateLoopLatch(B, NewLoop, Parallel); + IV->addIncoming(IncrementedIV, HeaderBB); if (GuardBB) DT.changeImmediateDominator(ExitBB, GuardBB); -- cgit v1.2.3