diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2021-09-02 12:40:22 +0300 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2021-09-02 12:42:23 +0300 |
commit | 50634deaa54afc08962563ccb1f0c0a6266b64b5 (patch) | |
tree | cce59912f6e1f9e214cd14741e35abfb848c1b0a /clang/lib | |
parent | f5b997e6b7061323fff13fafcc0c311d9e78e848 (diff) | |
download | llvm-50634deaa54afc08962563ccb1f0c0a6266b64b5.zip llvm-50634deaa54afc08962563ccb1f0c0a6266b64b5.tar.gz llvm-50634deaa54afc08962563ccb1f0c0a6266b64b5.tar.bz2 |
Revert "[OpenMP][OpenMPIRBuilder] Implement loop unrolling."
Breaks build with -DBUILD_SHARED_LIBS=ON
```
CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle):
"LLVMFrontendOpenMP" of type SHARED_LIBRARY
depends on "LLVMPasses" (weak)
"LLVMipo" of type SHARED_LIBRARY
depends on "LLVMFrontendOpenMP" (weak)
"LLVMCoroutines" of type SHARED_LIBRARY
depends on "LLVMipo" (weak)
"LLVMPasses" of type SHARED_LIBRARY
depends on "LLVMCoroutines" (weak)
depends on "LLVMipo" (weak)
At least one of these targets is not a STATIC_LIBRARY. Cyclic dependencies are allowed only among static libraries.
CMake Generate step failed. Build files cannot be regenerated correctly.
```
This reverts commit 707ce34b06190e275572c3c46843036db1bab6d1.
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 58 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 4 | ||||
-rw-r--r-- | clang/lib/Parse/ParseOpenMP.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 13 |
4 files changed, 3 insertions, 75 deletions
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index a9d1fd1..b965150 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -1951,27 +1951,11 @@ llvm::CanonicalLoopInfo * CodeGenFunction::EmitOMPCollapsedCanonicalLoopNest(const Stmt *S, int Depth) { assert(Depth == 1 && "Nested loops with OpenMPIRBuilder not yet implemented"); - // The caller is processing the loop-associated directive processing the \p - // Depth loops nested in \p S. Put the previous pending loop-associated - // directive to the stack. If the current loop-associated directive is a loop - // transformation directive, it will push its generated loops onto the stack - // such that together with the loops left here they form the combined loop - // nest for the parent loop-associated directive. - int ParentExpectedOMPLoopDepth = ExpectedOMPLoopDepth; - ExpectedOMPLoopDepth = Depth; - EmitStmt(S); assert(OMPLoopNestStack.size() >= (size_t)Depth && "Found too few loops"); // The last added loop is the outermost one. - llvm::CanonicalLoopInfo *Result = OMPLoopNestStack.back(); - - // Pop the \p Depth loops requested by the call from that stack and restore - // the previous context. - OMPLoopNestStack.set_size(OMPLoopNestStack.size() - Depth); - ExpectedOMPLoopDepth = ParentExpectedOMPLoopDepth; - - return Result; + return OMPLoopNestStack.back(); } void CodeGenFunction::EmitOMPCanonicalLoop(const OMPCanonicalLoop *S) { @@ -2601,46 +2585,6 @@ void CodeGenFunction::EmitOMPTileDirective(const OMPTileDirective &S) { } void CodeGenFunction::EmitOMPUnrollDirective(const OMPUnrollDirective &S) { - bool UseOMPIRBuilder = CGM.getLangOpts().OpenMPIRBuilder; - - if (UseOMPIRBuilder) { - auto DL = SourceLocToDebugLoc(S.getBeginLoc()); - const Stmt *Inner = S.getRawStmt(); - - // Consume nested loop. Clear the entire remaining loop stack because a - // fully unrolled loop is non-transformable. For partial unrolling the - // generated outer loop is pushed back to the stack. - llvm::CanonicalLoopInfo *CLI = EmitOMPCollapsedCanonicalLoopNest(Inner, 1); - OMPLoopNestStack.clear(); - - llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder(); - - bool NeedsUnrolledCLI = ExpectedOMPLoopDepth >= 1; - llvm::CanonicalLoopInfo *UnrolledCLI = nullptr; - - if (S.hasClausesOfKind<OMPFullClause>()) { - assert(ExpectedOMPLoopDepth == 0); - OMPBuilder.unrollLoopFull(DL, CLI); - } else if (auto *PartialClause = S.getSingleClause<OMPPartialClause>()) { - uint64_t Factor = 0; - if (Expr *FactorExpr = PartialClause->getFactor()) { - Factor = FactorExpr->EvaluateKnownConstInt(getContext()).getZExtValue(); - assert(Factor >= 1 && "Only positive factors are valid"); - } - OMPBuilder.unrollLoopPartial(DL, CLI, Factor, - NeedsUnrolledCLI ? &UnrolledCLI : nullptr); - } else { - OMPBuilder.unrollLoopHeuristic(DL, CLI); - } - - assert((!NeedsUnrolledCLI || UnrolledCLI) && - "NeedsUnrolledCLI implies UnrolledCLI to be set"); - if (UnrolledCLI) - OMPLoopNestStack.push_back(UnrolledCLI); - - return; - } - // This function is only called if the unrolled loop is not consumed by any // other loop-associated construct. Such a loop-associated construct will have // used the transformed AST. diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index b43f37c..1f05877 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -291,10 +291,6 @@ 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)> diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 5f8f984..a45168d 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2562,7 +2562,8 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) { if (AssociatedStmt.isUsable() && isOpenMPLoopDirective(DKind) && getLangOpts().OpenMPIRBuilder) - AssociatedStmt = Actions.ActOnOpenMPLoopnest(AssociatedStmt.get()); + AssociatedStmt = + Actions.ActOnOpenMPCanonicalLoop(AssociatedStmt.get()); } AssociatedStmt = Actions.ActOnOpenMPRegionEnd(AssociatedStmt, Clauses); } else if (DKind == OMPD_target_update || DKind == OMPD_target_enter_data || diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 0c678e8..b6e43d3 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -5573,19 +5573,6 @@ StmtResult Sema::ActOnOpenMPCanonicalLoop(Stmt *AStmt) { LoopVarFunc, LVRef); } -StmtResult Sema::ActOnOpenMPLoopnest(Stmt *AStmt) { - // Handle a literal loop. - if (isa<ForStmt>(AStmt) || isa<CXXForRangeStmt>(AStmt)) - return ActOnOpenMPCanonicalLoop(AStmt); - - // If not a literal loop, it must be the result of a loop transformation. - OMPExecutableDirective *LoopTransform = cast<OMPExecutableDirective>(AStmt); - assert( - isOpenMPLoopTransformationDirective(LoopTransform->getDirectiveKind()) && - "Loop transformation directive expected"); - return LoopTransform; -} - static ExprResult buildUserDefinedMapperRef(Sema &SemaRef, Scope *S, CXXScopeSpec &MapperIdScopeSpec, const DeclarationNameInfo &MapperId, |