Skip to content

Commit cdcbaa3

Browse files
LebedevRImemfrob
authored andcommitted
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.
1 parent b93344e commit cdcbaa3

22 files changed

+25
-2700
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10572,11 +10572,6 @@ class Sema final {
1057210572
/// an OpenMP loop directive.
1057310573
StmtResult ActOnOpenMPCanonicalLoop(Stmt *AStmt);
1057410574

10575-
/// Process a canonical OpenMP loop nest that can either be a canonical
10576-
/// literal loop (ForStmt or CXXForRangeStmt), or the generated loop of an
10577-
/// OpenMP loop transformation construct.
10578-
StmtResult ActOnOpenMPLoopnest(Stmt *AStmt);
10579-
1058010575
/// End of OpenMP region.
1058110576
///
1058210577
/// \param S Statement associated with the current OpenMP region.

clang/lib/CodeGen/CGStmtOpenMP.cpp

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,27 +1951,11 @@ llvm::CanonicalLoopInfo *
19511951
CodeGenFunction::EmitOMPCollapsedCanonicalLoopNest(const Stmt *S, int Depth) {
19521952
assert(Depth == 1 && "Nested loops with OpenMPIRBuilder not yet implemented");
19531953

1954-
// The caller is processing the loop-associated directive processing the \p
1955-
// Depth loops nested in \p S. Put the previous pending loop-associated
1956-
// directive to the stack. If the current loop-associated directive is a loop
1957-
// transformation directive, it will push its generated loops onto the stack
1958-
// such that together with the loops left here they form the combined loop
1959-
// nest for the parent loop-associated directive.
1960-
int ParentExpectedOMPLoopDepth = ExpectedOMPLoopDepth;
1961-
ExpectedOMPLoopDepth = Depth;
1962-
19631954
EmitStmt(S);
19641955
assert(OMPLoopNestStack.size() >= (size_t)Depth && "Found too few loops");
19651956

19661957
// The last added loop is the outermost one.
1967-
llvm::CanonicalLoopInfo *Result = OMPLoopNestStack.back();
1968-
1969-
// Pop the \p Depth loops requested by the call from that stack and restore
1970-
// the previous context.
1971-
OMPLoopNestStack.set_size(OMPLoopNestStack.size() - Depth);
1972-
ExpectedOMPLoopDepth = ParentExpectedOMPLoopDepth;
1973-
1974-
return Result;
1958+
return OMPLoopNestStack.back();
19751959
}
19761960

19771961
void CodeGenFunction::EmitOMPCanonicalLoop(const OMPCanonicalLoop *S) {
@@ -2601,46 +2585,6 @@ void CodeGenFunction::EmitOMPTileDirective(const OMPTileDirective &S) {
26012585
}
26022586

26032587
void CodeGenFunction::EmitOMPUnrollDirective(const OMPUnrollDirective &S) {
2604-
bool UseOMPIRBuilder = CGM.getLangOpts().OpenMPIRBuilder;
2605-
2606-
if (UseOMPIRBuilder) {
2607-
auto DL = SourceLocToDebugLoc(S.getBeginLoc());
2608-
const Stmt *Inner = S.getRawStmt();
2609-
2610-
// Consume nested loop. Clear the entire remaining loop stack because a
2611-
// fully unrolled loop is non-transformable. For partial unrolling the
2612-
// generated outer loop is pushed back to the stack.
2613-
llvm::CanonicalLoopInfo *CLI = EmitOMPCollapsedCanonicalLoopNest(Inner, 1);
2614-
OMPLoopNestStack.clear();
2615-
2616-
llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
2617-
2618-
bool NeedsUnrolledCLI = ExpectedOMPLoopDepth >= 1;
2619-
llvm::CanonicalLoopInfo *UnrolledCLI = nullptr;
2620-
2621-
if (S.hasClausesOfKind<OMPFullClause>()) {
2622-
assert(ExpectedOMPLoopDepth == 0);
2623-
OMPBuilder.unrollLoopFull(DL, CLI);
2624-
} else if (auto *PartialClause = S.getSingleClause<OMPPartialClause>()) {
2625-
uint64_t Factor = 0;
2626-
if (Expr *FactorExpr = PartialClause->getFactor()) {
2627-
Factor = FactorExpr->EvaluateKnownConstInt(getContext()).getZExtValue();
2628-
assert(Factor >= 1 && "Only positive factors are valid");
2629-
}
2630-
OMPBuilder.unrollLoopPartial(DL, CLI, Factor,
2631-
NeedsUnrolledCLI ? &UnrolledCLI : nullptr);
2632-
} else {
2633-
OMPBuilder.unrollLoopHeuristic(DL, CLI);
2634-
}
2635-
2636-
assert((!NeedsUnrolledCLI || UnrolledCLI) &&
2637-
"NeedsUnrolledCLI implies UnrolledCLI to be set");
2638-
if (UnrolledCLI)
2639-
OMPLoopNestStack.push_back(UnrolledCLI);
2640-
2641-
return;
2642-
}
2643-
26442588
// This function is only called if the unrolled loop is not consumed by any
26452589
// other loop-associated construct. Such a loop-associated construct will have
26462590
// used the transformed AST.

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,6 @@ class CodeGenFunction : public CodeGenTypeCache {
291291
/// nest would extend.
292292
SmallVector<llvm::CanonicalLoopInfo *, 4> OMPLoopNestStack;
293293

294-
/// Number of nested loop to be consumed by the last surrounding
295-
/// loop-associated directive.
296-
int ExpectedOMPLoopDepth = 0;
297-
298294
// CodeGen lambda for loops and support for ordered clause
299295
typedef llvm::function_ref<void(CodeGenFunction &, const OMPLoopDirective &,
300296
JumpDest)>

clang/lib/Parse/ParseOpenMP.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,8 @@ Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
25622562

25632563
if (AssociatedStmt.isUsable() && isOpenMPLoopDirective(DKind) &&
25642564
getLangOpts().OpenMPIRBuilder)
2565-
AssociatedStmt = Actions.ActOnOpenMPLoopnest(AssociatedStmt.get());
2565+
AssociatedStmt =
2566+
Actions.ActOnOpenMPCanonicalLoop(AssociatedStmt.get());
25662567
}
25672568
AssociatedStmt = Actions.ActOnOpenMPRegionEnd(AssociatedStmt, Clauses);
25682569
} else if (DKind == OMPD_target_update || DKind == OMPD_target_enter_data ||

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5573,19 +5573,6 @@ StmtResult Sema::ActOnOpenMPCanonicalLoop(Stmt *AStmt) {
55735573
LoopVarFunc, LVRef);
55745574
}
55755575

5576-
StmtResult Sema::ActOnOpenMPLoopnest(Stmt *AStmt) {
5577-
// Handle a literal loop.
5578-
if (isa<ForStmt>(AStmt) || isa<CXXForRangeStmt>(AStmt))
5579-
return ActOnOpenMPCanonicalLoop(AStmt);
5580-
5581-
// If not a literal loop, it must be the result of a loop transformation.
5582-
OMPExecutableDirective *LoopTransform = cast<OMPExecutableDirective>(AStmt);
5583-
assert(
5584-
isOpenMPLoopTransformationDirective(LoopTransform->getDirectiveKind()) &&
5585-
"Loop transformation directive expected");
5586-
return LoopTransform;
5587-
}
5588-
55895576
static ExprResult buildUserDefinedMapperRef(Sema &SemaRef, Scope *S,
55905577
CXXScopeSpec &MapperIdScopeSpec,
55915578
const DeclarationNameInfo &MapperId,

clang/test/OpenMP/irbuilder_unroll_full.c

Lines changed: 0 additions & 153 deletions
This file was deleted.

0 commit comments

Comments
 (0)