Emit llvm.loop metadata for parallel loops
For now we only mark innermost loops for the loop vectorizer. We could later
also mark not-innermost loops to enable the introduction of openmp parallelism.
llvm-svn: 202854
diff --git a/polly/lib/CodeGen/LoopGenerators.cpp b/polly/lib/CodeGen/LoopGenerators.cpp
index 3f9e1b0..5815879 100644
--- a/polly/lib/CodeGen/LoopGenerators.cpp
+++ b/polly/lib/CodeGen/LoopGenerators.cpp
@@ -48,7 +48,8 @@
// always executed at least once, we can get rid of this branch.
Value *polly::createLoop(Value *LB, Value *UB, Value *Stride,
PollyIRBuilder &Builder, Pass *P, BasicBlock *&ExitBB,
- ICmpInst::Predicate Predicate) {
+ ICmpInst::Predicate Predicate,
+ LoopAnnotator *Annotator, bool Parallel) {
DominatorTree &DT = P->getAnalysis<DominatorTreeWrapperPass>().getDomTree();
LoopInfo &LI = P->getAnalysis<LoopInfo>();
@@ -65,6 +66,12 @@
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();