[PATCH] D48808: [CodeGen] Emit parallel_loop_access for each loop in the loop stack.
Michael Kruse via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 30 22:03:12 PDT 2018
Meinersbur created this revision.
Meinersbur added reviewers: ABataev, hfinkel.
Emit !llvm.mem.parallel_loop_access metadata for memory accesses even if the parallel loop is not the top on the loop stack.
Fixes llvm.org/PR37558.
Repository:
rC Clang
https://reviews.llvm.org/D48808
Files:
lib/CodeGen/CGLoopInfo.cpp
test/CodeGenCXX/pragma-loop-safety-nested.cpp
Index: test/CodeGenCXX/pragma-loop-safety-nested.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/pragma-loop-safety-nested.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+// Verify that the inner access is tagged with a parallel_loop_access
+// for the outer loop.
+void vectorize_nested_test(int *List, int Length) {
+#pragma clang loop vectorize(assume_safety) interleave(disable) unroll(disable)
+ for (int i = 0; i < Length; i += 2) {
+#pragma clang loop unroll(full)
+ for (int j = 0; j < 2; j += 1)
+ List[i + j] = (i + j) * 2;
+ }
+}
+
+// CHECK: %[[MUL:.+]] = mul
+// CHECK: store i32 %[[MUL]], i32* %{{.+}}, !llvm.mem.parallel_loop_access ![[OUTER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[INNER_LOOPID:[0-9]+]]
+// CHECK: br label %{{.+}}, !llvm.loop ![[OUTER_LOOPID]]
+
+// CHECK: ![[OUTER_LOOPID]] = distinct !{![[OUTER_LOOPID]],
+// CHECK: ![[INNER_LOOPID]] = distinct !{![[INNER_LOOPID]],
Index: lib/CodeGen/CGLoopInfo.cpp
===================================================================
--- lib/CodeGen/CGLoopInfo.cpp
+++ lib/CodeGen/CGLoopInfo.cpp
@@ -300,6 +300,7 @@
return;
}
- if (L.getAttributes().IsParallel && I->mayReadOrWriteMemory())
- I->setMetadata("llvm.mem.parallel_loop_access", L.getLoopID());
+ for (const LoopInfo &AL : Active)
+ if (AL.getAttributes().IsParallel && I->mayReadOrWriteMemory())
+ I->setMetadata("llvm.mem.parallel_loop_access", AL.getLoopID());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48808.153645.patch
Type: text/x-patch
Size: 1577 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180701/0db46a4a/attachment.bin>
More information about the cfe-commits
mailing list