Skip to content

Commit 6b6c6d0

Browse files
authored
[NFC] Remove unnecessary changes from the trunk (#212)
Re-created PR currently in ATD lost during merge to amd-staging.
1 parent 622fecd commit 6b6c6d0

File tree

7 files changed

+68
-126
lines changed

7 files changed

+68
-126
lines changed

flang/lib/Lower/OpenMP/DataSharingProcessor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ void DataSharingProcessor::doPrivatize(const semantics::Symbol *sym,
573573
clauseOps->privateSyms.push_back(mlir::SymbolRefAttr::get(privatizerOp));
574574
clauseOps->privateVars.push_back(hsb.getAddr());
575575
}
576+
576577
symToPrivatizer[sym] = privatizerOp;
577578
}
578579

flang/lib/Lower/OpenMP/DataSharingProcessor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ class DataSharingProcessor {
8888
bool useDelayedPrivatization;
8989
bool callsInitClone = false;
9090
lower::SymMap &symTable;
91-
9291
OMPConstructSymbolVisitor visitor;
9392
bool privatizationDone = false;
9493

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 63 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,6 @@ static void createBodyOfOp(mlir::Operation &op, const OpWithBodyGenInfo &info,
11021102
firOpBuilder.createBlock(&op.getRegion(0));
11031103
return {};
11041104
}();
1105-
11061105
// Mark the earliest insertion point.
11071106
mlir::Operation *marker = insertMarker(firOpBuilder);
11081107

@@ -1858,7 +1857,6 @@ static mlir::omp::LoopNestOp genLoopNestOp(
18581857
std::pair<mlir::omp::BlockArgOpenMPOpInterface, const EntryBlockArgs &>>
18591858
wrapperArgs,
18601859
llvm::omp::Directive directive, DataSharingProcessor &dsp) {
1861-
18621860
auto ivCallback = [&](mlir::Operation *op) {
18631861
genLoopVars(op, converter, loc, iv, wrapperArgs);
18641862
return llvm::SmallVector<const semantics::Symbol *>(iv);
@@ -1867,15 +1865,13 @@ static mlir::omp::LoopNestOp genLoopNestOp(
18671865
auto *nestedEval =
18681866
getCollapsedLoopEval(eval, getCollapseValue(item->clauses));
18691867

1870-
auto loopNestOp = genOpWithBody<mlir::omp::LoopNestOp>(
1868+
return genOpWithBody<mlir::omp::LoopNestOp>(
18711869
OpWithBodyGenInfo(converter, symTable, semaCtx, loc, *nestedEval,
18721870
directive)
18731871
.setClauses(&item->clauses)
18741872
.setDataSharingProcessor(&dsp)
18751873
.setGenRegionEntryCb(ivCallback),
18761874
queue, item, clauseOps);
1877-
1878-
return loopNestOp;
18791875
}
18801876

18811877
static void genLoopOp(lower::AbstractConverter &converter,
@@ -2202,76 +2198,77 @@ genTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
22022198
if (!converter.getSymbolAddress(sym))
22032199
return;
22042200

2205-
if (llvm::is_contained(mapSyms, &sym))
2206-
return;
2207-
2208-
if (const auto *details =
2209-
sym.template detailsIf<semantics::HostAssocDetails>())
2210-
converter.copySymbolBinding(details->symbol(), sym);
2211-
std::stringstream name;
2212-
fir::ExtendedValue dataExv = converter.getSymbolExtendedValue(sym);
2213-
name << sym.name().ToString();
2214-
2215-
lower::AddrAndBoundsInfo info = getDataOperandBaseAddr(
2216-
converter, firOpBuilder, sym, converter.getCurrentLocation());
2217-
llvm::SmallVector<mlir::Value> bounds =
2218-
lower::genImplicitBoundsOps<mlir::omp::MapBoundsOp,
2219-
mlir::omp::MapBoundsType>(
2220-
firOpBuilder, info, dataExv,
2221-
semantics::IsAssumedSizeArray(sym.GetUltimate()),
2222-
converter.getCurrentLocation());
2223-
2224-
llvm::omp::OpenMPOffloadMappingFlags mapFlag =
2225-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_IMPLICIT;
2226-
mlir::omp::VariableCaptureKind captureKind =
2227-
mlir::omp::VariableCaptureKind::ByRef;
2228-
2229-
mlir::Value baseOp = info.rawInput;
2230-
mlir::Type eleType = baseOp.getType();
2231-
if (auto refType = mlir::dyn_cast<fir::ReferenceType>(baseOp.getType()))
2232-
eleType = refType.getElementType();
2233-
2234-
// If a variable is specified in declare target link and if device
2235-
// type is not specified as `nohost`, it needs to be mapped tofrom
2236-
mlir::ModuleOp mod = firOpBuilder.getModule();
2237-
mlir::Operation *op = mod.lookupSymbol(converter.mangleName(sym));
2238-
auto declareTargetOp =
2239-
llvm::dyn_cast_if_present<mlir::omp::DeclareTargetInterface>(op);
2240-
if (declareTargetOp && declareTargetOp.isDeclareTarget()) {
2241-
if (declareTargetOp.getDeclareTargetCaptureClause() ==
2242-
mlir::omp::DeclareTargetCaptureClause::link &&
2243-
declareTargetOp.getDeclareTargetDeviceType() !=
2244-
mlir::omp::DeclareTargetDeviceType::nohost) {
2201+
if (!llvm::is_contained(mapSyms, &sym)) {
2202+
if (const auto *details =
2203+
sym.template detailsIf<semantics::HostAssocDetails>())
2204+
converter.copySymbolBinding(details->symbol(), sym);
2205+
std::stringstream name;
2206+
fir::ExtendedValue dataExv = converter.getSymbolExtendedValue(sym);
2207+
name << sym.name().ToString();
2208+
2209+
lower::AddrAndBoundsInfo info = getDataOperandBaseAddr(
2210+
converter, firOpBuilder, sym, converter.getCurrentLocation());
2211+
llvm::SmallVector<mlir::Value> bounds =
2212+
lower::genImplicitBoundsOps<mlir::omp::MapBoundsOp,
2213+
mlir::omp::MapBoundsType>(
2214+
firOpBuilder, info, dataExv,
2215+
semantics::IsAssumedSizeArray(sym.GetUltimate()),
2216+
converter.getCurrentLocation());
2217+
2218+
llvm::omp::OpenMPOffloadMappingFlags mapFlag =
2219+
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_IMPLICIT;
2220+
mlir::omp::VariableCaptureKind captureKind =
2221+
mlir::omp::VariableCaptureKind::ByRef;
2222+
2223+
mlir::Value baseOp = info.rawInput;
2224+
mlir::Type eleType = baseOp.getType();
2225+
if (auto refType = mlir::dyn_cast<fir::ReferenceType>(baseOp.getType()))
2226+
eleType = refType.getElementType();
2227+
2228+
// If a variable is specified in declare target link and if device
2229+
// type is not specified as `nohost`, it needs to be mapped tofrom
2230+
mlir::ModuleOp mod = firOpBuilder.getModule();
2231+
mlir::Operation *op = mod.lookupSymbol(converter.mangleName(sym));
2232+
auto declareTargetOp =
2233+
llvm::dyn_cast_if_present<mlir::omp::DeclareTargetInterface>(op);
2234+
if (declareTargetOp && declareTargetOp.isDeclareTarget()) {
2235+
if (declareTargetOp.getDeclareTargetCaptureClause() ==
2236+
mlir::omp::DeclareTargetCaptureClause::link &&
2237+
declareTargetOp.getDeclareTargetDeviceType() !=
2238+
mlir::omp::DeclareTargetDeviceType::nohost) {
2239+
mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
2240+
mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
2241+
}
2242+
} else if (fir::isa_trivial(eleType) || fir::isa_char(eleType)) {
2243+
captureKind = mlir::omp::VariableCaptureKind::ByCopy;
2244+
} else if (!fir::isa_builtin_cptr_type(eleType)) {
22452245
mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
22462246
mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
22472247
}
2248-
} else if (fir::isa_trivial(eleType) || fir::isa_char(eleType)) {
2249-
captureKind = mlir::omp::VariableCaptureKind::ByCopy;
2250-
} else if (!fir::isa_builtin_cptr_type(eleType)) {
2251-
mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
2252-
mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
2248+
auto location =
2249+
mlir::NameLoc::get(mlir::StringAttr::get(firOpBuilder.getContext(),
2250+
sym.name().ToString()),
2251+
baseOp.getLoc());
2252+
mlir::Value mapOp = createMapInfoOp(
2253+
firOpBuilder, location, baseOp, /*varPtrPtr=*/mlir::Value{},
2254+
name.str(), bounds, /*members=*/{},
2255+
/*membersIndex=*/mlir::ArrayAttr{},
2256+
static_cast<
2257+
std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
2258+
mapFlag),
2259+
captureKind, baseOp.getType());
2260+
2261+
clauseOps.mapVars.push_back(mapOp);
2262+
mapSyms.push_back(&sym);
22532263
}
2254-
auto location = mlir::NameLoc::get(
2255-
mlir::StringAttr::get(firOpBuilder.getContext(), sym.name().ToString()),
2256-
baseOp.getLoc());
2257-
mlir::Value mapOp = createMapInfoOp(
2258-
firOpBuilder, location, baseOp, /*varPtrPtr=*/mlir::Value{}, name.str(),
2259-
bounds, /*members=*/{},
2260-
/*membersIndex=*/mlir::ArrayAttr{},
2261-
static_cast<
2262-
std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
2263-
mapFlag),
2264-
captureKind, baseOp.getType());
2265-
2266-
clauseOps.mapVars.push_back(mapOp);
2267-
mapSyms.push_back(&sym);
22682264
};
22692265
lower::pft::visitAllSymbols(eval, captureImplicitMap);
22702266

22712267
auto targetOp = firOpBuilder.create<mlir::omp::TargetOp>(loc, clauseOps);
22722268

22732269
llvm::SmallVector<mlir::Value> mapBaseValues;
22742270
extractMappedBaseValues(clauseOps.mapVars, mapBaseValues);
2271+
22752272
EntryBlockArgs args;
22762273
args.hostEvalVars = clauseOps.hostEvalVars;
22772274
// TODO: Add in_reduction syms and vars.
@@ -2471,14 +2468,12 @@ genTeamsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
24712468
return llvm::to_vector(args.getSyms());
24722469
};
24732470

2474-
auto teamsOp = genOpWithBody<mlir::omp::TeamsOp>(
2471+
return genOpWithBody<mlir::omp::TeamsOp>(
24752472
OpWithBodyGenInfo(converter, symTable, semaCtx, loc, eval,
24762473
llvm::omp::Directive::OMPD_teams)
24772474
.setClauses(&item->clauses)
24782475
.setGenRegionEntryCb(genRegionEntryCB),
24792476
queue, item, clauseOps);
2480-
2481-
return teamsOp;
24822477
}
24832478

24842479
//===----------------------------------------------------------------------===//
@@ -2528,6 +2523,7 @@ static void genStandaloneDo(lower::AbstractConverter &converter,
25282523
const ConstructQueue &queue,
25292524
ConstructQueue::const_iterator item) {
25302525
lower::StatementContext stmtCtx;
2526+
25312527
mlir::omp::WsloopOperands wsloopClauseOps;
25322528
llvm::SmallVector<const semantics::Symbol *> wsloopReductionSyms;
25332529
genWsloopClauses(converter, semaCtx, stmtCtx, item->clauses, loc,
@@ -3449,7 +3445,6 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
34493445
ConstructQueue queue{
34503446
buildConstructQueue(converter.getFirOpBuilder().getModule(), semaCtx,
34513447
eval, source, directive, clauses)};
3452-
34533448
genOMPDispatch(converter, symTable, semaCtx, eval, currentLocation, queue,
34543449
queue.begin());
34553450
}
@@ -3475,7 +3470,6 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
34753470
std::get<parser::OmpSectionBlocks>(sectionsConstruct.t);
34763471
clauses.append(makeClauses(
34773472
std::get<parser::OmpClauseList>(endSectionsDirective.t), semaCtx));
3478-
34793473
mlir::Location currentLocation = converter.getCurrentLocation();
34803474

34813475
llvm::omp::Directive directive =

llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,6 +2917,7 @@ class OpenMPIRBuilder {
29172917
Function *OutlinedFunction,
29182918
StringRef EntryFnName,
29192919
StringRef EntryFnIDName);
2920+
29202921
/// Type of BodyGen to use for region codegen
29212922
///
29222923
/// Priv: If device pointer privatization is required, emit the body of the

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ static const omp::GV &getGridValue(const Triple &T, Function *Kernel) {
153153
if (T.isAMDGPU()) {
154154
StringRef Features =
155155
Kernel->getFnAttribute("target-features").getValueAsString();
156-
157156
if (Features.count("+wavefrontsize64"))
158157
return omp::getAMDGPUGridValues<64>();
159158
return omp::getAMDGPUGridValues<32>();
@@ -1295,6 +1294,7 @@ static void targetParallelCallback(
12951294
CallInst *CI = cast<CallInst>(OutlinedFn.user_back());
12961295
assert(CI && "Expected call instruction to outlined function");
12971296
CI->getParent()->setName("omp_parallel");
1297+
12981298
Builder.SetInsertPoint(CI);
12991299
Type *PtrTy = OMPIRBuilder->VoidPtr;
13001300
Value *NullPtrValue = Constant::getNullValue(PtrTy);
@@ -4450,7 +4450,6 @@ OpenMPIRBuilder::applyStaticChunkedWorkshareLoop(DebugLoc DL,
44504450
IsLastChunk, CountUntilOrigTripCount, ChunkRange, "omp_chunk.tripcount");
44514451
Value *BackcastedChunkTC =
44524452
Builder.CreateTrunc(ChunkTripCount, IVTy, "omp_chunk.tripcount.trunc");
4453-
44544453
CLI->setTripCount(BackcastedChunkTC);
44554454

44564455
// Update all uses of the induction variable except the one in the condition
@@ -6937,44 +6936,6 @@ FunctionCallee OpenMPIRBuilder::createDispatchDeinitFunction() {
69376936
return getOrCreateRuntimeFunction(M, omp::OMPRTL___kmpc_dispatch_deinit);
69386937
}
69396938

6940-
static void emitUsed(StringRef Name, std::vector<llvm::WeakTrackingVH> &List,
6941-
Type *Int8PtrTy, Module &M) {
6942-
if (List.empty())
6943-
return;
6944-
6945-
// Convert List to what ConstantArray needs.
6946-
SmallVector<Constant *, 8> UsedArray;
6947-
UsedArray.resize(List.size());
6948-
for (unsigned i = 0, e = List.size(); i != e; ++i) {
6949-
UsedArray[i] = ConstantExpr::getPointerBitCastOrAddrSpaceCast(
6950-
cast<Constant>(&*List[i]), Int8PtrTy);
6951-
}
6952-
6953-
if (UsedArray.empty())
6954-
return;
6955-
ArrayType *ATy = ArrayType::get(Int8PtrTy, UsedArray.size());
6956-
6957-
auto *GV =
6958-
new GlobalVariable(M, ATy, false, llvm::GlobalValue::AppendingLinkage,
6959-
llvm::ConstantArray::get(ATy, UsedArray), Name);
6960-
6961-
GV->setSection("llvm.metadata");
6962-
}
6963-
6964-
static void
6965-
emitExecutionMode(OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
6966-
StringRef FunctionName, omp::OMPTgtExecModeFlags ExecFlags,
6967-
std::vector<llvm::WeakTrackingVH> &LLVMCompilerUsed) {
6968-
auto Int8Ty = Type::getInt8Ty(Builder.getContext());
6969-
auto *GVMode =
6970-
new llvm::GlobalVariable(OMPBuilder.M, Int8Ty, /*isConstant=*/true,
6971-
llvm::GlobalValue::WeakAnyLinkage,
6972-
llvm::ConstantInt::get(Int8Ty, ExecFlags),
6973-
Twine(FunctionName, "_exec_mode"));
6974-
GVMode->setVisibility(llvm::GlobalVariable::ProtectedVisibility);
6975-
LLVMCompilerUsed.emplace_back(GVMode);
6976-
}
6977-
69786939
static Value *removeASCastIfPresent(Value *V) {
69796940
if (Operator::getOpcode(V) == Instruction::AddrSpaceCast)
69806941
return cast<Operator>(V)->getOperand(0);
@@ -7678,6 +7639,7 @@ emitTargetCall(OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
76787639
Result, Clause)
76797640
: Clause;
76807641
};
7642+
76817643
// If a multi-dimensional THREAD_LIMIT is set, it is the OMPX_BARE case, so
76827644
// the NUM_THREADS clause is overriden by THREAD_LIMIT.
76837645
SmallVector<Value *, 3> NumThreadsC;

mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2396,7 +2396,6 @@ LogicalResult DistributeOp::verifyRegions() {
23962396
if (!isComposite())
23972397
return emitError()
23982398
<< "'omp.composite' attribute missing from composite wrapper";
2399-
24002399
// Check for the allowed leaf constructs that may appear in a composite
24012400
// construct directly after DISTRIBUTE.
24022401
if (isa<WsloopOp>(nested)) {

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4207,7 +4207,6 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
42074207
// If device info is available then region has already been generated
42084208
if (info.DevicePtrInfoMap.empty()) {
42094209
builder.restoreIP(codeGenIP);
4210-
42114210
// For device pass, if use_device_ptr(addr) mappings were present,
42124211
// we need to link them here before codegen.
42134212
if (ompBuilder->Config.IsTargetDevice.value_or(false)) {
@@ -5039,7 +5038,6 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
50395038
return exitBlock.takeError();
50405039

50415040
builder.SetInsertPoint(*exitBlock);
5042-
50435041
if (!privateCleanupRegions.empty()) {
50445042
if (failed(inlineOmpRegionCleanup(
50455043
privateCleanupRegions, llvmPrivateVars, moduleTranslation,
@@ -5281,6 +5279,7 @@ static bool isTargetDeviceOp(Operation *op) {
52815279
static LogicalResult
52825280
convertHostOrTargetOperation(Operation *op, llvm::IRBuilderBase &builder,
52835281
LLVM::ModuleTranslation &moduleTranslation) {
5282+
52845283
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
52855284

52865285
return llvm::TypeSwitch<Operation *, LogicalResult>(op)
@@ -5406,19 +5405,6 @@ convertHostOrTargetOperation(Operation *op, llvm::IRBuilderBase &builder,
54065405
});
54075406
}
54085407

5409-
template <typename FirstOpType, typename... RestOpTypes>
5410-
bool matchOpNest(Operation *op, FirstOpType &firstOp, RestOpTypes &...restOps) {
5411-
if ((firstOp = mlir::dyn_cast<FirstOpType>(op))) {
5412-
if constexpr (sizeof...(RestOpTypes) == 0) {
5413-
return true;
5414-
} else {
5415-
Block &innerBlock = getContainedBlock(firstOp);
5416-
return matchOpScanNest(innerBlock, restOps...);
5417-
}
5418-
}
5419-
return false;
5420-
}
5421-
54225408
static LogicalResult
54235409
convertTargetDeviceOp(Operation *op, llvm::IRBuilderBase &builder,
54245410
LLVM::ModuleTranslation &moduleTranslation) {

0 commit comments

Comments
 (0)