Skip to content

Commit 7daf500

Browse files
committed
Removed the interface from hlfir.as_expr.
1 parent bd3e3db commit 7daf500

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

flang/include/flang/Optimizer/HLFIR/HLFIROps.td

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,8 @@ def hlfir_EndAssociateOp : hlfir_Op<"end_associate", [MemoryEffects<[MemFree]>]>
950950
}
951951

952952
def hlfir_AsExprOp
953-
: hlfir_Op<"as_expr", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
954-
fir_FortranObjectViewOpInterface]> {
953+
: hlfir_Op<
954+
"as_expr", [DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
955955
let summary = "Take the value of an array, character or derived variable";
956956

957957
let description = [{
@@ -975,9 +975,6 @@ def hlfir_AsExprOp
975975
let extraClassDeclaration = [{
976976
// Is this a "move" ?
977977
bool isMove() { return getMustFree() != mlir::Value{}; }
978-
// FortranObjectViewOpInterface methods:
979-
mlir::Value getViewSource(mlir::OpResult) { return getVar(); }
980-
std::optional<std::int64_t> getViewOffset(mlir::OpResult) { return 0; }
981978
}];
982979

983980
let assemblyFormat = [{

flang/lib/Optimizer/Analysis/AliasAnalysis.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,13 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
576576
assert(opResult.getOwner() == defOp && "v must be a result of defOp");
577577
ty = opResult.getType();
578578
llvm::TypeSwitch<Operation *>(defOp)
579+
.Case<hlfir::AsExprOp>([&](auto op) {
580+
// TODO: we should probably always report hlfir.as_expr
581+
// as a unique source, and let the codegen decide whether
582+
// to use the original buffer or create a copy.
583+
v = op.getVar();
584+
defOp = v.getDefiningOp();
585+
})
579586
.Case<hlfir::AssociateOp>([&](auto op) {
580587
assert(opResult != op.getMustFreeStrorageFlag() &&
581588
"MustFreeStorageFlag result is not an aliasing candidate");

0 commit comments

Comments
 (0)