Skip to content

Commit b6a2013

Browse files
Renaud-Kgithub-actions[bot]
authored andcommitted
Automerge: Reverting commits 5bc5161 and df42799 (#128057)
2 parents b0107b2 + df9d3c2 commit b6a2013

File tree

3 files changed

+39
-160
lines changed

3 files changed

+39
-160
lines changed

flang/lib/Optimizer/Analysis/AliasAnalysis.cpp

Lines changed: 39 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "flang/Optimizer/Analysis/AliasAnalysis.h"
10-
#include "flang/Optimizer/CodeGen/CGOps.h"
1110
#include "flang/Optimizer/Dialect/FIROps.h"
1211
#include "flang/Optimizer/Dialect/FIROpsSupport.h"
1312
#include "flang/Optimizer/Dialect/FIRType.h"
@@ -62,17 +61,13 @@ getOriginalDef(mlir::Value v,
6261
mlir::Type ty = defOp->getResultTypes()[0];
6362
llvm::TypeSwitch<Operation *>(defOp)
6463
.Case<fir::ConvertOp>([&](fir::ConvertOp op) { v = op.getValue(); })
65-
.Case<fir::DeclareOp, hlfir::DeclareOp, fir::cg::XDeclareOp>(
66-
[&](auto op) {
67-
v = op.getMemref();
68-
auto varIf =
69-
llvm::dyn_cast<fir::FortranVariableOpInterface>(defOp);
70-
if (varIf) {
71-
attributes |= getAttrsFromVariable(varIf);
72-
isCapturedInInternalProcedure |=
73-
varIf.isCapturedInInternalProcedure();
74-
}
75-
})
64+
.Case<fir::DeclareOp, hlfir::DeclareOp>([&](auto op) {
65+
v = op.getMemref();
66+
auto varIf = llvm::cast<fir::FortranVariableOpInterface>(defOp);
67+
attributes |= getAttrsFromVariable(varIf);
68+
isCapturedInInternalProcedure |=
69+
varIf.isCapturedInInternalProcedure();
70+
})
7671
.Case<fir::CoordinateOp>([&](auto op) {
7772
if (fir::AliasAnalysis::isPointerReference(ty))
7873
attributes.set(fir::AliasAnalysis::Attribute::Pointer);
@@ -596,21 +591,19 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
596591
followBoxData = true;
597592
approximateSource = true;
598593
})
599-
.Case<fir::EmboxOp, fir::ReboxOp, fir::cg::XEmboxOp, fir::cg::XReboxOp>(
600-
[&](auto op) {
601-
if (followBoxData) {
602-
v = op->getOperand(0);
603-
defOp = v.getDefiningOp();
604-
} else
605-
breakFromLoop = true;
606-
})
594+
.Case<fir::EmboxOp, fir::ReboxOp>([&](auto op) {
595+
if (followBoxData) {
596+
v = op->getOperand(0);
597+
defOp = v.getDefiningOp();
598+
} else
599+
breakFromLoop = true;
600+
})
607601
.Case<fir::LoadOp>([&](auto op) {
608602
// If load is inside target and it points to mapped item,
609603
// continue tracking.
610604
Operation *loadMemrefOp = op.getMemref().getDefiningOp();
611605
bool isDeclareOp =
612606
llvm::isa_and_present<fir::DeclareOp>(loadMemrefOp) ||
613-
llvm::isa_and_present<fir::cg::XDeclareOp>(loadMemrefOp) ||
614607
llvm::isa_and_present<hlfir::DeclareOp>(loadMemrefOp);
615608
if (isDeclareOp &&
616609
llvm::isa<omp::TargetOp>(loadMemrefOp->getParentOp())) {
@@ -673,8 +666,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
673666
global = llvm::cast<fir::AddrOfOp>(op).getSymbol();
674667
breakFromLoop = true;
675668
})
676-
.Case<hlfir::DeclareOp, fir::DeclareOp,
677-
fir::cg::XDeclareOp>([&](auto op) {
669+
.Case<hlfir::DeclareOp, fir::DeclareOp>([&](auto op) {
678670
bool isPrivateItem = false;
679671
if (omp::BlockArgOpenMPOpInterface argIface =
680672
dyn_cast<omp::BlockArgOpenMPOpInterface>(op->getParentOp())) {
@@ -708,33 +700,30 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
708700
return;
709701
}
710702
}
711-
auto varIf = llvm::dyn_cast<fir::FortranVariableOpInterface>(defOp);
712-
if (varIf) {
713-
// While going through a declare operation collect
714-
// the variable attributes from it. Right now, some
715-
// of the attributes are duplicated, e.g. a TARGET dummy
716-
// argument has the target attribute both on its declare
717-
// operation and on the entry block argument.
718-
// In case of host associated use, the declare operation
719-
// is the only carrier of the variable attributes,
720-
// so we have to collect them here.
721-
attributes |= getAttrsFromVariable(varIf);
722-
isCapturedInInternalProcedure |=
723-
varIf.isCapturedInInternalProcedure();
724-
if (varIf.isHostAssoc()) {
725-
// Do not track past such DeclareOp, because it does not
726-
// currently provide any useful information. The host associated
727-
// access will end up dereferencing the host association tuple,
728-
// so we may as well stop right now.
729-
v = defOp->getResult(0);
730-
// TODO: if the host associated variable is a dummy argument
731-
// of the host, I think, we can treat it as SourceKind::Argument
732-
// for the purpose of alias analysis inside the internal
733-
// procedure.
734-
type = SourceKind::HostAssoc;
735-
breakFromLoop = true;
736-
return;
737-
}
703+
auto varIf = llvm::cast<fir::FortranVariableOpInterface>(defOp);
704+
// While going through a declare operation collect
705+
// the variable attributes from it. Right now, some
706+
// of the attributes are duplicated, e.g. a TARGET dummy
707+
// argument has the target attribute both on its declare
708+
// operation and on the entry block argument.
709+
// In case of host associated use, the declare operation
710+
// is the only carrier of the variable attributes,
711+
// so we have to collect them here.
712+
attributes |= getAttrsFromVariable(varIf);
713+
isCapturedInInternalProcedure |=
714+
varIf.isCapturedInInternalProcedure();
715+
if (varIf.isHostAssoc()) {
716+
// Do not track past such DeclareOp, because it does not
717+
// currently provide any useful information. The host associated
718+
// access will end up dereferencing the host association tuple,
719+
// so we may as well stop right now.
720+
v = defOp->getResult(0);
721+
// TODO: if the host associated variable is a dummy argument
722+
// of the host, I think, we can treat it as SourceKind::Argument
723+
// for the purpose of alias analysis inside the internal procedure.
724+
type = SourceKind::HostAssoc;
725+
breakFromLoop = true;
726+
return;
738727
}
739728
if (getLastInstantiationPoint) {
740729
// Fetch only the innermost instantiation point.

flang/lib/Optimizer/Analysis/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ add_flang_library(FIRAnalysis
66
FIRDialect
77
FIRSupport
88
HLFIRDialect
9-
FIRCodeGen
109

1110
LINK_LIBS
1211
FIRBuilder
1312
FIRDialect
1413
FIRSupport
1514
HLFIRDialect
16-
FIRCodeGen
1715

1816
MLIR_DEPS
1917
MLIRIR

flang/test/Analysis/AliasAnalysis/fircg-as-sources.fir

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)