aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorMichael Kruse <llvm-project@meinersbur.de>2021-09-04 18:50:49 -0500
committerMichael Kruse <llvm-project@meinersbur.de>2021-09-04 19:18:58 -0500
commit650bbc56203c947bb85176c40ca9c7c7a91c3c57 (patch)
treea3a0f5a20176355f7de8b8eced441b605f4c9ed9 /clang/lib/CodeGen/CodeGenFunction.h
parent37e6a27da754e1a613b0f657c9ae91221237d66a (diff)
downloadllvm-650bbc56203c947bb85176c40ca9c7c7a91c3c57.zip
llvm-650bbc56203c947bb85176c40ca9c7c7a91c3c57.tar.gz
llvm-650bbc56203c947bb85176c40ca9c7c7a91c3c57.tar.bz2
[OpenMP][OpenMPIRBuilder] Implement loop unrolling.
Recommit of 707ce34b06190e275572c3c46843036db1bab6d1. Don't introduce a dependency to the LLVMPasses component, instead register the required passes individually. Add methods for loop unrolling to the OpenMPIRBuilder class and use them in Clang if `-fopenmp-enable-irbuilder` is enabled. The unrolling methods are: * `unrollLoopFull` * `unrollLoopPartial` * `unrollLoopHeuristic` `unrollLoopPartial` and `unrollLoopHeuristic` can use compiler heuristics to automatically determine the unroll factor. If possible, that is if no CanonicalLoopInfo is required to pass to another method, metadata for LLVM's LoopUnrollPass is added. Otherwise the unroll factor is determined using the same heurstics as user by LoopUnrollPass. Not requiring a CanonicalLoopInfo, especially with `unrollLoopHeuristic` allows greater flexibility. With full unrolling and partial unrolling with known unroll factor, instead of duplicating instructions by the OpenMPIRBuilder, the full unroll is still delegated to the LoopUnrollPass. In case of partial unrolling the loop is first tiled using the existing `tileLoops` methods, then the inner loop fully unrolled using the same mechanism. Reviewed By: jdoerfert, kiranchandramohan Differential Revision: https://reviews.llvm.org/D107764
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index a27f4da..023fd4d 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -291,6 +291,10 @@ public:
/// nest would extend.
SmallVector<llvm::CanonicalLoopInfo *, 4> OMPLoopNestStack;
+ /// Number of nested loop to be consumed by the last surrounding
+ /// loop-associated directive.
+ int ExpectedOMPLoopDepth = 0;
+
// CodeGen lambda for loops and support for ordered clause
typedef llvm::function_ref<void(CodeGenFunction &, const OMPLoopDirective &,
JumpDest)>