Skip to content

Commit 1bff5f6

Browse files
committed
Revert "[OpenMP] Introduce the initial support for OpenMP kernel language (#66844)"
This reverts commit e997dca.
1 parent 27770a7 commit 1bff5f6

20 files changed

+657
-1145
lines changed

clang/include/clang/AST/OpenMPClause.h

-21
Original file line numberDiff line numberDiff line change
@@ -9220,27 +9220,6 @@ class OMPXAttributeClause
92209220
}
92219221
};
92229222

9223-
/// This represents 'ompx_bare' clause in the '#pragma omp target teams ...'
9224-
/// directive.
9225-
///
9226-
/// \code
9227-
/// #pragma omp target teams ompx_bare
9228-
/// \endcode
9229-
/// In this example directive '#pragma omp target teams' has a 'ompx_bare'
9230-
/// clause.
9231-
class OMPXBareClause : public OMPNoChildClause<llvm::omp::OMPC_ompx_bare> {
9232-
public:
9233-
/// Build 'ompx_bare' clause.
9234-
///
9235-
/// \param StartLoc Starting location of the clause.
9236-
/// \param EndLoc Ending location of the clause.
9237-
OMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
9238-
: OMPNoChildClause(StartLoc, EndLoc) {}
9239-
9240-
/// Build an empty clause.
9241-
OMPXBareClause() = default;
9242-
};
9243-
92449223
} // namespace clang
92459224

92469225
#endif // LLVM_CLANG_AST_OPENMPCLAUSE_H

clang/include/clang/AST/RecursiveASTVisitor.h

-5
Original file line numberDiff line numberDiff line change
@@ -3890,11 +3890,6 @@ bool RecursiveASTVisitor<Derived>::VisitOMPXAttributeClause(
38903890
return true;
38913891
}
38923892

3893-
template <typename Derived>
3894-
bool RecursiveASTVisitor<Derived>::VisitOMPXBareClause(OMPXBareClause *C) {
3895-
return true;
3896-
}
3897-
38983893
// FIXME: look at the following tricky-seeming exprs to see if we
38993894
// need to recurse on anything. These are ones that have methods
39003895
// returning decls or qualtypes or nestednamespecifier -- though I'm

clang/include/clang/Basic/DiagnosticParseKinds.td

-4
Original file line numberDiff line numberDiff line change
@@ -1360,8 +1360,6 @@ def warn_clause_expected_string : Warning<
13601360
"expected string literal in 'clause %0' - ignoring">, InGroup<IgnoredPragmas>;
13611361
def err_omp_unexpected_clause : Error<
13621362
"unexpected OpenMP clause '%0' in directive '#pragma omp %1'">;
1363-
def err_omp_unexpected_clause_extension_only : Error<
1364-
"OpenMP clause '%0' is only available as extension, use '-fopenmp-extensions'">;
13651363
def err_omp_immediate_directive : Error<
13661364
"'#pragma omp %0' %select{|with '%2' clause }1cannot be an immediate substatement">;
13671365
def err_omp_expected_identifier_for_critical : Error<
@@ -1454,8 +1452,6 @@ def warn_unknown_declare_variant_isa_trait
14541452
"spelling or consider restricting the context selector with the "
14551453
"'arch' selector further">,
14561454
InGroup<SourceUsesOpenMP>;
1457-
def note_ompx_bare_clause : Note<
1458-
"OpenMP extension clause '%0' only allowed with '#pragma omp %1'">;
14591455
def note_omp_declare_variant_ctx_options
14601456
: Note<"context %select{set|selector|property}0 options are: %1">;
14611457
def warn_omp_declare_variant_expected

clang/include/clang/Sema/Sema.h

-4
Original file line numberDiff line numberDiff line change
@@ -12448,10 +12448,6 @@ class Sema final {
1244812448
SourceLocation LParenLoc,
1244912449
SourceLocation EndLoc);
1245012450

12451-
/// Called on a well-formed 'ompx_bare' clause.
12452-
OMPClause *ActOnOpenMPXBareClause(SourceLocation StartLoc,
12453-
SourceLocation EndLoc);
12454-
1245512451
/// The kind of conversion being performed.
1245612452
enum CheckedConversionKind {
1245712453
/// An implicit conversion.

clang/lib/AST/OpenMPClause.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
170170
case OMPC_affinity:
171171
case OMPC_when:
172172
case OMPC_bind:
173-
case OMPC_ompx_bare:
174173
break;
175174
default:
176175
break;
@@ -2547,10 +2546,6 @@ void OMPClausePrinter::VisitOMPXAttributeClause(OMPXAttributeClause *Node) {
25472546
OS << ")";
25482547
}
25492548

2550-
void OMPClausePrinter::VisitOMPXBareClause(OMPXBareClause *Node) {
2551-
OS << "ompx_bare";
2552-
}
2553-
25542549
void OMPTraitInfo::getAsVariantMatchInfo(ASTContext &ASTCtx,
25552550
VariantMatchInfo &VMI) const {
25562551
for (const OMPTraitSet &Set : Sets) {

clang/lib/AST/StmtProfile.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,6 @@ void OMPClauseProfiler::VisitOMPDoacrossClause(const OMPDoacrossClause *C) {
930930
}
931931
void OMPClauseProfiler::VisitOMPXAttributeClause(const OMPXAttributeClause *C) {
932932
}
933-
void OMPClauseProfiler::VisitOMPXBareClause(const OMPXBareClause *C) {}
934933
} // namespace
935934

936935
void

clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp

+17-42
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,10 @@ CGOpenMPRuntimeGPU::getExecutionMode() const {
551551
return CurrentExecutionMode;
552552
}
553553

554-
CGOpenMPRuntimeGPU::DataSharingMode
555-
CGOpenMPRuntimeGPU::getDataSharingMode() const {
556-
return CurrentDataSharingMode;
554+
static CGOpenMPRuntimeGPU::DataSharingMode
555+
getDataSharingMode(CodeGenModule &CGM) {
556+
return CGM.getLangOpts().OpenMPCUDAMode ? CGOpenMPRuntimeGPU::CUDA
557+
: CGOpenMPRuntimeGPU::Generic;
557558
}
558559

559560
/// Check for inner (nested) SPMD construct, if any
@@ -751,9 +752,6 @@ void CGOpenMPRuntimeGPU::emitNonSPMDKernel(const OMPExecutableDirective &D,
751752
EntryFunctionState EST;
752753
WrapperFunctionsMap.clear();
753754

754-
[[maybe_unused]] bool IsBareKernel = D.getSingleClause<OMPXBareClause>();
755-
assert(!IsBareKernel && "bare kernel should not be at generic mode");
756-
757755
// Emit target region as a standalone region.
758756
class NVPTXPrePostActionTy : public PrePostActionTy {
759757
CGOpenMPRuntimeGPU::EntryFunctionState &EST;
@@ -762,13 +760,15 @@ void CGOpenMPRuntimeGPU::emitNonSPMDKernel(const OMPExecutableDirective &D,
762760
NVPTXPrePostActionTy(CGOpenMPRuntimeGPU::EntryFunctionState &EST)
763761
: EST(EST) {}
764762
void Enter(CodeGenFunction &CGF) override {
765-
auto &RT = static_cast<CGOpenMPRuntimeGPU &>(CGF.CGM.getOpenMPRuntime());
763+
auto &RT =
764+
static_cast<CGOpenMPRuntimeGPU &>(CGF.CGM.getOpenMPRuntime());
766765
RT.emitKernelInit(CGF, EST, /* IsSPMD */ false);
767766
// Skip target region initialization.
768767
RT.setLocThreadIdInsertPt(CGF, /*AtCurrentPoint=*/true);
769768
}
770769
void Exit(CodeGenFunction &CGF) override {
771-
auto &RT = static_cast<CGOpenMPRuntimeGPU &>(CGF.CGM.getOpenMPRuntime());
770+
auto &RT =
771+
static_cast<CGOpenMPRuntimeGPU &>(CGF.CGM.getOpenMPRuntime());
772772
RT.clearLocThreadIdInsertPt(CGF);
773773
RT.emitKernelDeinit(CGF, EST, /* IsSPMD */ false);
774774
}
@@ -807,39 +807,25 @@ void CGOpenMPRuntimeGPU::emitSPMDKernel(const OMPExecutableDirective &D,
807807
ExecutionRuntimeModesRAII ModeRAII(CurrentExecutionMode, EM_SPMD);
808808
EntryFunctionState EST;
809809

810-
bool IsBareKernel = D.getSingleClause<OMPXBareClause>();
811-
812810
// Emit target region as a standalone region.
813811
class NVPTXPrePostActionTy : public PrePostActionTy {
814812
CGOpenMPRuntimeGPU &RT;
815813
CGOpenMPRuntimeGPU::EntryFunctionState &EST;
816-
bool IsBareKernel;
817-
DataSharingMode Mode;
818814

819815
public:
820816
NVPTXPrePostActionTy(CGOpenMPRuntimeGPU &RT,
821-
CGOpenMPRuntimeGPU::EntryFunctionState &EST,
822-
bool IsBareKernel)
823-
: RT(RT), EST(EST), IsBareKernel(IsBareKernel),
824-
Mode(RT.CurrentDataSharingMode) {}
817+
CGOpenMPRuntimeGPU::EntryFunctionState &EST)
818+
: RT(RT), EST(EST) {}
825819
void Enter(CodeGenFunction &CGF) override {
826-
if (IsBareKernel) {
827-
RT.CurrentDataSharingMode = DataSharingMode::DS_CUDA;
828-
return;
829-
}
830820
RT.emitKernelInit(CGF, EST, /* IsSPMD */ true);
831821
// Skip target region initialization.
832822
RT.setLocThreadIdInsertPt(CGF, /*AtCurrentPoint=*/true);
833823
}
834824
void Exit(CodeGenFunction &CGF) override {
835-
if (IsBareKernel) {
836-
RT.CurrentDataSharingMode = Mode;
837-
return;
838-
}
839825
RT.clearLocThreadIdInsertPt(CGF);
840826
RT.emitKernelDeinit(CGF, EST, /* IsSPMD */ true);
841827
}
842-
} Action(*this, EST, IsBareKernel);
828+
} Action(*this, EST);
843829
CodeGen.setAction(Action);
844830
IsInTTDRegion = true;
845831
emitTargetOutlinedFunctionHelper(D, ParentName, OutlinedFn, OutlinedFnID,
@@ -857,8 +843,7 @@ void CGOpenMPRuntimeGPU::emitTargetOutlinedFunction(
857843
assert(!ParentName.empty() && "Invalid target region parent name!");
858844

859845
bool Mode = supportsSPMDExecutionMode(CGM.getContext(), D);
860-
bool IsBareKernel = D.getSingleClause<OMPXBareClause>();
861-
if (Mode || IsBareKernel)
846+
if (Mode)
862847
emitSPMDKernel(D, ParentName, OutlinedFn, OutlinedFnID, IsOffloadEntry,
863848
CodeGen);
864849
else
@@ -882,9 +867,6 @@ CGOpenMPRuntimeGPU::CGOpenMPRuntimeGPU(CodeGenModule &CGM)
882867
if (CGM.getLangOpts().NoGPULib || CGM.getLangOpts().OMPHostIRFile.empty())
883868
return;
884869

885-
if (CGM.getLangOpts().OpenMPCUDAMode)
886-
CurrentDataSharingMode = CGOpenMPRuntimeGPU::DS_CUDA;
887-
888870
OMPBuilder.createGlobalFlag(CGM.getLangOpts().OpenMPTargetDebug,
889871
"__omp_rtl_debug_kind");
890872
OMPBuilder.createGlobalFlag(CGM.getLangOpts().OpenMPTeamSubscription,
@@ -1048,7 +1030,7 @@ llvm::Function *CGOpenMPRuntimeGPU::emitTeamsOutlinedFunction(
10481030
void CGOpenMPRuntimeGPU::emitGenericVarsProlog(CodeGenFunction &CGF,
10491031
SourceLocation Loc,
10501032
bool WithSPMDCheck) {
1051-
if (getDataSharingMode() != CGOpenMPRuntimeGPU::DS_Generic &&
1033+
if (getDataSharingMode(CGM) != CGOpenMPRuntimeGPU::Generic &&
10521034
getExecutionMode() != CGOpenMPRuntimeGPU::EM_SPMD)
10531035
return;
10541036

@@ -1160,7 +1142,7 @@ void CGOpenMPRuntimeGPU::getKmpcFreeShared(
11601142

11611143
void CGOpenMPRuntimeGPU::emitGenericVarsEpilog(CodeGenFunction &CGF,
11621144
bool WithSPMDCheck) {
1163-
if (getDataSharingMode() != CGOpenMPRuntimeGPU::DS_Generic &&
1145+
if (getDataSharingMode(CGM) != CGOpenMPRuntimeGPU::Generic &&
11641146
getExecutionMode() != CGOpenMPRuntimeGPU::EM_SPMD)
11651147
return;
11661148

@@ -1196,18 +1178,11 @@ void CGOpenMPRuntimeGPU::emitTeamsCall(CodeGenFunction &CGF,
11961178
if (!CGF.HaveInsertPoint())
11971179
return;
11981180

1199-
bool IsBareKernel = D.getSingleClause<OMPXBareClause>();
1200-
12011181
Address ZeroAddr = CGF.CreateDefaultAlignTempAlloca(CGF.Int32Ty,
12021182
/*Name=*/".zero.addr");
12031183
CGF.Builder.CreateStore(CGF.Builder.getInt32(/*C*/ 0), ZeroAddr);
12041184
llvm::SmallVector<llvm::Value *, 16> OutlinedFnArgs;
1205-
// We don't emit any thread id function call in bare kernel, but because the
1206-
// outlined function has a pointer argument, we emit a nullptr here.
1207-
if (IsBareKernel)
1208-
OutlinedFnArgs.push_back(llvm::ConstantPointerNull::get(CGM.VoidPtrTy));
1209-
else
1210-
OutlinedFnArgs.push_back(emitThreadIDAddress(CGF, Loc).getPointer());
1185+
OutlinedFnArgs.push_back(emitThreadIDAddress(CGF, Loc).getPointer());
12111186
OutlinedFnArgs.push_back(ZeroAddr.getPointer());
12121187
OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end());
12131188
emitOutlinedFunctionCall(CGF, Loc, OutlinedFn, OutlinedFnArgs);
@@ -3298,7 +3273,7 @@ llvm::Function *CGOpenMPRuntimeGPU::createParallelDataSharingWrapper(
32983273

32993274
void CGOpenMPRuntimeGPU::emitFunctionProlog(CodeGenFunction &CGF,
33003275
const Decl *D) {
3301-
if (getDataSharingMode() != CGOpenMPRuntimeGPU::DS_Generic)
3276+
if (getDataSharingMode(CGM) != CGOpenMPRuntimeGPU::Generic)
33023277
return;
33033278

33043279
assert(D && "Expected function or captured|block decl.");
@@ -3407,7 +3382,7 @@ Address CGOpenMPRuntimeGPU::getAddressOfLocalVariable(CodeGenFunction &CGF,
34073382
VarTy, Align);
34083383
}
34093384

3410-
if (getDataSharingMode() != CGOpenMPRuntimeGPU::DS_Generic)
3385+
if (getDataSharingMode(CGM) != CGOpenMPRuntimeGPU::Generic)
34113386
return Address::invalid();
34123387

34133388
VD = VD->getCanonicalDecl();

clang/lib/CodeGen/CGOpenMPRuntimeGPU.h

+11-18
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ class CGOpenMPRuntimeGPU : public CGOpenMPRuntime {
3232
/// Unknown execution mode (orphaned directive).
3333
EM_Unknown,
3434
};
35-
36-
/// Target codegen is specialized based on two data-sharing modes: CUDA, in
37-
/// which the local variables are actually global threadlocal, and Generic, in
38-
/// which the local variables are placed in global memory if they may escape
39-
/// their declaration context.
40-
enum DataSharingMode {
41-
/// CUDA data sharing mode.
42-
DS_CUDA,
43-
/// Generic data-sharing mode.
44-
DS_Generic,
45-
};
46-
4735
private:
4836
/// Parallel outlined function work for workers to execute.
4937
llvm::SmallVector<llvm::Function *, 16> Work;
@@ -54,8 +42,6 @@ class CGOpenMPRuntimeGPU : public CGOpenMPRuntime {
5442

5543
ExecutionMode getExecutionMode() const;
5644

57-
DataSharingMode getDataSharingMode() const;
58-
5945
/// Get barrier to synchronize all threads in a block.
6046
void syncCTAThreads(CodeGenFunction &CGF);
6147

@@ -311,6 +297,17 @@ class CGOpenMPRuntimeGPU : public CGOpenMPRuntime {
311297
Address getAddressOfLocalVariable(CodeGenFunction &CGF,
312298
const VarDecl *VD) override;
313299

300+
/// Target codegen is specialized based on two data-sharing modes: CUDA, in
301+
/// which the local variables are actually global threadlocal, and Generic, in
302+
/// which the local variables are placed in global memory if they may escape
303+
/// their declaration context.
304+
enum DataSharingMode {
305+
/// CUDA data sharing mode.
306+
CUDA,
307+
/// Generic data-sharing mode.
308+
Generic,
309+
};
310+
314311
/// Cleans up references to the objects in finished function.
315312
///
316313
void functionFinished(CodeGenFunction &CGF) override;
@@ -346,10 +343,6 @@ class CGOpenMPRuntimeGPU : public CGOpenMPRuntime {
346343
/// to emit optimized code.
347344
ExecutionMode CurrentExecutionMode = EM_Unknown;
348345

349-
/// Track the data sharing mode when codegening directives within a target
350-
/// region.
351-
DataSharingMode CurrentDataSharingMode = DataSharingMode::DS_Generic;
352-
353346
/// true if currently emitting code for target/teams/distribute region, false
354347
/// - otherwise.
355348
bool IsInTTDRegion = false;

clang/lib/Parse/ParseOpenMP.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -3416,17 +3416,6 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
34163416
case OMPC_ompx_attribute:
34173417
Clause = ParseOpenMPOMPXAttributesClause(WrongDirective);
34183418
break;
3419-
case OMPC_ompx_bare:
3420-
if (WrongDirective)
3421-
Diag(Tok, diag::note_ompx_bare_clause)
3422-
<< getOpenMPClauseName(CKind) << "target teams";
3423-
if (!ErrorFound && !getLangOpts().OpenMPExtensions) {
3424-
Diag(Tok, diag::err_omp_unexpected_clause_extension_only)
3425-
<< getOpenMPClauseName(CKind) << getOpenMPDirectiveName(DKind);
3426-
ErrorFound = true;
3427-
}
3428-
Clause = ParseOpenMPClause(CKind, WrongDirective);
3429-
break;
34303419
default:
34313420
break;
34323421
}

clang/lib/Sema/SemaOpenMP.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -17553,9 +17553,6 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
1755317553
case OMPC_partial:
1755417554
Res = ActOnOpenMPPartialClause(nullptr, StartLoc, /*LParenLoc=*/{}, EndLoc);
1755517555
break;
17556-
case OMPC_ompx_bare:
17557-
Res = ActOnOpenMPXBareClause(StartLoc, EndLoc);
17558-
break;
1755917556
case OMPC_if:
1756017557
case OMPC_final:
1756117558
case OMPC_num_threads:
@@ -24282,8 +24279,3 @@ OMPClause *Sema::ActOnOpenMPXAttributeClause(ArrayRef<const Attr *> Attrs,
2428224279
SourceLocation EndLoc) {
2428324280
return new (Context) OMPXAttributeClause(Attrs, StartLoc, LParenLoc, EndLoc);
2428424281
}
24285-
24286-
OMPClause *Sema::ActOnOpenMPXBareClause(SourceLocation StartLoc,
24287-
SourceLocation EndLoc) {
24288-
return new (Context) OMPXBareClause(StartLoc, EndLoc);
24289-
}

clang/lib/Sema/TreeTransform.h

-14
Original file line numberDiff line numberDiff line change
@@ -2391,15 +2391,6 @@ class TreeTransform {
23912391
EndLoc);
23922392
}
23932393

2394-
/// Build a new OpenMP 'ompx_bare' clause.
2395-
///
2396-
/// By default, performs semantic analysis to build the new OpenMP clause.
2397-
/// Subclasses may override this routine to provide different behavior.
2398-
OMPClause *RebuildOMPXBareClause(SourceLocation StartLoc,
2399-
SourceLocation EndLoc) {
2400-
return getSema().ActOnOpenMPXBareClause(StartLoc, EndLoc);
2401-
}
2402-
24032394
/// Build a new OpenMP 'align' clause.
24042395
///
24052396
/// By default, performs semantic analysis to build the new OpenMP clause.
@@ -10813,11 +10804,6 @@ TreeTransform<Derived>::TransformOMPXAttributeClause(OMPXAttributeClause *C) {
1081310804
NewAttrs, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
1081410805
}
1081510806

10816-
template <typename Derived>
10817-
OMPClause *TreeTransform<Derived>::TransformOMPXBareClause(OMPXBareClause *C) {
10818-
return getDerived().RebuildOMPXBareClause(C->getBeginLoc(), C->getEndLoc());
10819-
}
10820-
1082110807
//===----------------------------------------------------------------------===//
1082210808
// Expression transformation
1082310809
//===----------------------------------------------------------------------===//

clang/lib/Serialization/ASTReader.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -10446,9 +10446,6 @@ OMPClause *OMPClauseReader::readClause() {
1044610446
case llvm::omp::OMPC_ompx_attribute:
1044710447
C = new (Context) OMPXAttributeClause();
1044810448
break;
10449-
case llvm::omp::OMPC_ompx_bare:
10450-
C = new (Context) OMPXBareClause();
10451-
break;
1045210449
#define OMP_CLAUSE_NO_CLASS(Enum, Str) \
1045310450
case llvm::omp::Enum: \
1045410451
break;
@@ -11550,8 +11547,6 @@ void OMPClauseReader::VisitOMPXAttributeClause(OMPXAttributeClause *C) {
1155011547
C->setLocEnd(Record.readSourceLocation());
1155111548
}
1155211549

11553-
void OMPClauseReader::VisitOMPXBareClause(OMPXBareClause *C) {}
11554-
1155511550
OMPTraitInfo *ASTRecordReader::readOMPTraitInfo() {
1155611551
OMPTraitInfo &TI = getContext().getNewOMPTraitInfo();
1155711552
TI.Sets.resize(readUInt32());

0 commit comments

Comments
 (0)