Skip to content

Commit ca35ec2

Browse files
committed
More readability improvments
1 parent 4325873 commit ca35ec2

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

flang/lib/Lower/OpenMP/DataSharingProcessor.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ void DataSharingProcessor::cloneSymbol(const semantics::Symbol *sym) {
100100
// If we are doing eager-privatization on a symbol created using delayed
101101
// privatization there could be incompatible types here e.g.
102102
// fir.ref<fir.box<fir.array<>>>
103-
bool success = false;
104-
[&]() {
103+
bool success = [&]() -> bool {
105104
const auto *details =
106105
sym->detailsIf<Fortran::semantics::HostAssocDetails>();
107106
assert(details && "No host-association found");
@@ -134,20 +133,19 @@ void DataSharingProcessor::cloneSymbol(const semantics::Symbol *sym) {
134133
nullptr, {}, nullptr);
135134

136135
// This can't be a CharArrayBoxValue because otherwise
137-
// boxTy.getElementType() would be a charcater type.
136+
// boxTy.getElementType() would be a character type.
138137
// Assume the array element type isn't polymorphic because we are
139138
// privatizing.
140139
fir::ExtendedValue newExv = fir::ArrayBoxValue{box, extents};
141140

142141
converter.bindSymbol(*sym, newExv);
143-
success = true;
144-
return;
142+
return true;
145143
}
146144
}
147145
}
148146

149147
// Normal case:
150-
success = converter.createHostAssociateVarClone(
148+
return converter.createHostAssociateVarClone(
151149
*sym, /*skipDefaultInit=*/isFirstPrivate);
152150
}();
153151
(void)success;

flang/lib/Lower/OpenMP/PrivateReductionUtils.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,7 @@ static void initializeIfDerivedTypeBox(fir::FirOpBuilder &builder,
167167
return;
168168

169169
// remove pointer and array types in the middle
170-
mlir::Type eleTy;
171-
if (boxTy)
172-
eleTy = boxTy.getElementType();
173-
if (classTy)
174-
eleTy = classTy.getEleTy();
170+
mlir::Type eleTy = boxTy ? boxTy.getElementType() : classTy.getEleTy();
175171
mlir::Type derivedTy = fir::unwrapRefType(eleTy);
176172
if (auto array = mlir::dyn_cast<fir::SequenceType>(derivedTy))
177173
derivedTy = array.getElementType();
@@ -231,7 +227,7 @@ static mlir::Value generateZeroShapeForRank(fir::FirOpBuilder &builder,
231227
fir::SequenceType seqTy =
232228
mlir::dyn_cast_if_present<fir::SequenceType>(eleType);
233229
if (!seqTy)
234-
return nullptr;
230+
return mlir::Value{};
235231

236232
unsigned rank = seqTy.getShape().size();
237233
mlir::Value zero =
@@ -289,9 +285,9 @@ void Fortran::lower::omp::populateByRefInitAndCleanupRegions(
289285
fir::IfOp ifOp = builder.create<fir::IfOp>(loc, isNotAllocated,
290286
/*withElseRegion=*/true);
291287
builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
292-
// just embox the null address and return
293-
// we have to give the embox a shape so that the LLVM box structure has the
294-
// right rank. This returns nullptr if the types don't match.
288+
// Just embox the null address and return.
289+
// We have to give the embox a shape so that the LLVM box structure has the
290+
// right rank. This returns an empty value if the types don't match.
295291
mlir::Value shape = generateZeroShapeForRank(builder, loc, moldArg);
296292

297293
mlir::Value nullBox =

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,9 +1335,9 @@ findAssociatedValue(Value privateVar, llvm::IRBuilderBase &builder,
13351335
return moduleTranslation.lookupValue(privateVar);
13361336
}
13371337

1338-
/// Allocate delayed private variables. Returns the basic block which comes
1339-
/// after all of these allocations. llvm::Value * for each of these private
1340-
/// variables are populated in llvmPrivateVars.
1338+
/// Allocate and initialize delayed private variables. Returns the basic block
1339+
/// which comes after all of these allocations. llvm::Value * for each of these
1340+
/// private variables are populated in llvmPrivateVars.
13411341
static llvm::Expected<llvm::BasicBlock *> allocateAndInitPrivateVars(
13421342
llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation,
13431343
MutableArrayRef<BlockArgument> privateBlockArgs,

0 commit comments

Comments
 (0)