[flang-commits] [flang] 955eaaf - [flang] Only check for embox/rebox if defining op is present
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Mon Mar 13 07:26:04 PDT 2023
Author: Valentin Clement
Date: 2023-03-13T15:25:56+01:00
New Revision: 955eaaf1b52f35bf01e9cffb0029064cab265f2d
URL: https://github.com/llvm/llvm-project/commit/955eaaf1b52f35bf01e9cffb0029064cab265f2d
DIFF: https://github.com/llvm/llvm-project/commit/955eaaf1b52f35bf01e9cffb0029064cab265f2d.diff
LOG: [flang] Only check for embox/rebox if defining op is present
When the base box is a block argument, the defining op is null.
Only try to recover embox/rebox if there is a defining op.
Reviewed By: PeteSteinfeld
Differential Revision: https://reviews.llvm.org/D145910
Added:
Modified:
flang/lib/Lower/ConvertExpr.cpp
Removed:
################################################################################
diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index b6003562baf35..f6cd76188316b 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -7238,17 +7238,19 @@ updateBoxForParentComponent(Fortran::lower::AbstractConverter &converter,
mlir::Operation *op = boxBase.getDefiningOp();
mlir::Type actualTy = converter.genType(expr);
- if (auto embox = mlir::dyn_cast<fir::EmboxOp>(op)) {
- auto newBox = builder.create<fir::EmboxOp>(
- loc, fir::BoxType::get(actualTy), embox.getMemref(), embox.getShape(),
- embox.getSlice(), embox.getTypeparams());
- return fir::substBase(box, newBox);
- }
- if (auto rebox = mlir::dyn_cast<fir::ReboxOp>(op)) {
- auto newBox = builder.create<fir::ReboxOp>(loc, fir::BoxType::get(actualTy),
- rebox.getBox(), rebox.getShape(),
- rebox.getSlice());
- return fir::substBase(box, newBox);
+ if (op) {
+ if (auto embox = mlir::dyn_cast<fir::EmboxOp>(op)) {
+ auto newBox = builder.create<fir::EmboxOp>(
+ loc, fir::BoxType::get(actualTy), embox.getMemref(), embox.getShape(),
+ embox.getSlice(), embox.getTypeparams());
+ return fir::substBase(box, newBox);
+ }
+ if (auto rebox = mlir::dyn_cast<fir::ReboxOp>(op)) {
+ auto newBox = builder.create<fir::ReboxOp>(
+ loc, fir::BoxType::get(actualTy), rebox.getBox(), rebox.getShape(),
+ rebox.getSlice());
+ return fir::substBase(box, newBox);
+ }
}
mlir::Value empty;
More information about the flang-commits
mailing list