Skip to content

Commit 60906ff

Browse files
committed
Removed the interface from hlfir.as_expr.
1 parent 7f44a45 commit 60906ff

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
@@ -551,6 +551,13 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
551551
assert(opResult.getOwner() == defOp && "v must be a result of defOp");
552552
ty = opResult.getType();
553553
llvm::TypeSwitch<Operation *>(defOp)
554+
.Case<hlfir::AsExprOp>([&](auto op) {
555+
// TODO: we should probably always report hlfir.as_expr
556+
// as a unique source, and let the codegen decide whether
557+
// to use the original buffer or create a copy.
558+
v = op.getVar();
559+
defOp = v.getDefiningOp();
560+
})
554561
.Case<hlfir::AssociateOp>([&](auto op) {
555562
assert(opResult != op.getMustFreeStrorageFlag() &&
556563
"MustFreeStorageFlag result is not an aliasing candidate");

0 commit comments

Comments
 (0)