-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[NFC][Flang] Move bounds helper functions to Util header. #158658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
#include "flang/Optimizer/Dialect/Support/KindMapping.h" | ||
#include "flang/Optimizer/HLFIR/HLFIROps.h" | ||
#include "flang/Optimizer/OpenMP/Passes.h" | ||
#include "flang/Optimizer/OpenMP/Utils.h" | ||
|
||
#include "mlir/Dialect/Func/IR/FuncOps.h" | ||
#include "mlir/Dialect/OpenMP/OpenMPDialect.h" | ||
|
@@ -106,8 +107,8 @@ class MapsForPrivatizedSymbolsPass | |
// Figure out the bounds because knowing the bounds will help the subsequent | ||
// MapInfoFinalizationPass map the underlying data of the descriptor. | ||
llvm::SmallVector<mlir::Value> boundsOps; | ||
if (needsBoundsOps(varPtr)) | ||
genBoundsOps(builder, varPtr, boundsOps); | ||
if (flangomp::needsBoundsOps(varPtr)) | ||
boundsOps = flangomp::genBoundsOps(builder, varPtr); | ||
Comment on lines
+110
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function call assignment changes the API contract. The old code appended to an existing vector via reference parameter, while the new code returns a new vector. This could impact performance if boundsOps already contains elements, as they would be overwritten rather than appended to. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
|
||
mlir::omp::VariableCaptureKind captureKind = | ||
mlir::omp::VariableCaptureKind::ByRef; | ||
|
@@ -194,38 +195,5 @@ class MapsForPrivatizedSymbolsPass | |
} | ||
} | ||
} | ||
// As the name suggests, this function examines var to determine if | ||
// it has dynamic size. If true, this pass'll have to extract these | ||
// bounds from descriptor of var and add the bounds to the resultant | ||
// MapInfoOp. | ||
bool needsBoundsOps(mlir::Value var) { | ||
assert(mlir::isa<omp::PointerLikeType>(var.getType()) && | ||
"needsBoundsOps can deal only with pointer types"); | ||
mlir::Type t = fir::unwrapRefType(var.getType()); | ||
// t could be a box, so look inside the box | ||
auto innerType = fir::dyn_cast_ptrOrBoxEleTy(t); | ||
if (innerType) | ||
return fir::hasDynamicSize(innerType); | ||
return fir::hasDynamicSize(t); | ||
} | ||
|
||
void genBoundsOps(fir::FirOpBuilder &builder, mlir::Value var, | ||
llvm::SmallVector<mlir::Value> &boundsOps) { | ||
mlir::Location loc = var.getLoc(); | ||
fir::factory::AddrAndBoundsInfo info = | ||
fir::factory::getDataOperandBaseAddr(builder, var, | ||
/*isOptional=*/false, loc); | ||
fir::ExtendedValue extendedValue = | ||
hlfir::translateToExtendedValue(loc, builder, hlfir::Entity{info.addr}, | ||
/*continguousHint=*/true) | ||
.first; | ||
llvm::SmallVector<mlir::Value> boundsOpsVec = | ||
fir::factory::genImplicitBoundsOps<mlir::omp::MapBoundsOp, | ||
mlir::omp::MapBoundsType>( | ||
builder, info, extendedValue, | ||
/*dataExvIsAssumedSize=*/false, loc); | ||
for (auto bounds : boundsOpsVec) | ||
boundsOps.push_back(bounds); | ||
} | ||
}; | ||
} // namespace |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
add_flang_library(FIRSupport | ||
BoxValue.cpp | ||
DataLayout.cpp | ||
InitFIR.cpp | ||
InternalNames.cpp | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't
BoxValue.h
move toflang/Optimizer/Support
?