19
19
#include " mlir/IR/BuiltinOps.h"
20
20
#include " mlir/IR/Value.h"
21
21
#include " mlir/Interfaces/SideEffectInterfaces.h"
22
+ #include " flang/Optimizer/CodeGen/CGOps.h"
22
23
#include " llvm/ADT/TypeSwitch.h"
23
24
#include " llvm/Support/Casting.h"
24
25
#include " llvm/Support/Debug.h"
@@ -578,7 +579,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
578
579
followBoxData = true ;
579
580
approximateSource = true ;
580
581
})
581
- .Case <fir::EmboxOp, fir::ReboxOp>([&](auto op) {
582
+ .Case <fir::EmboxOp, fir::ReboxOp, fir::cg::XEmboxOp, fir::cg::XReboxOp >([&](auto op) {
582
583
if (followBoxData) {
583
584
v = op->getOperand (0 );
584
585
defOp = v.getDefiningOp ();
@@ -591,6 +592,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
591
592
Operation *loadMemrefOp = op.getMemref ().getDefiningOp ();
592
593
bool isDeclareOp =
593
594
llvm::isa_and_present<fir::DeclareOp>(loadMemrefOp) ||
595
+ llvm::isa_and_present<fir::cg::XDeclareOp>(loadMemrefOp) ||
594
596
llvm::isa_and_present<hlfir::DeclareOp>(loadMemrefOp);
595
597
if (isDeclareOp &&
596
598
llvm::isa<omp::TargetOp>(loadMemrefOp->getParentOp ())) {
@@ -652,7 +654,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
652
654
global = llvm::cast<fir::AddrOfOp>(op).getSymbol ();
653
655
breakFromLoop = true ;
654
656
})
655
- .Case <hlfir::DeclareOp, fir::DeclareOp>([&](auto op) {
657
+ .Case <hlfir::DeclareOp, fir::DeclareOp, fir::cg::XDeclareOp >([&](auto op) {
656
658
bool isPrivateItem = false ;
657
659
if (omp::BlockArgOpenMPOpInterface argIface =
658
660
dyn_cast<omp::BlockArgOpenMPOpInterface>(op->getParentOp ())) {
@@ -686,30 +688,32 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
686
688
return ;
687
689
}
688
690
}
689
- auto varIf = llvm::cast<fir::FortranVariableOpInterface>(defOp);
690
- // While going through a declare operation collect
691
- // the variable attributes from it. Right now, some
692
- // of the attributes are duplicated, e.g. a TARGET dummy
693
- // argument has the target attribute both on its declare
694
- // operation and on the entry block argument.
695
- // In case of host associated use, the declare operation
696
- // is the only carrier of the variable attributes,
697
- // so we have to collect them here.
698
- attributes |= getAttrsFromVariable (varIf);
699
- isCapturedInInternalProcedure |=
700
- varIf.isCapturedInInternalProcedure ();
701
- if (varIf.isHostAssoc ()) {
702
- // Do not track past such DeclareOp, because it does not
703
- // currently provide any useful information. The host associated
704
- // access will end up dereferencing the host association tuple,
705
- // so we may as well stop right now.
706
- v = defOp->getResult (0 );
707
- // TODO: if the host associated variable is a dummy argument
708
- // of the host, I think, we can treat it as SourceKind::Argument
709
- // for the purpose of alias analysis inside the internal procedure.
710
- type = SourceKind::HostAssoc;
711
- breakFromLoop = true ;
712
- return ;
691
+ auto varIf = llvm::dyn_cast<fir::FortranVariableOpInterface>(defOp);
692
+ if (varIf){
693
+ // While going through a declare operation collect
694
+ // the variable attributes from it. Right now, some
695
+ // of the attributes are duplicated, e.g. a TARGET dummy
696
+ // argument has the target attribute both on its declare
697
+ // operation and on the entry block argument.
698
+ // In case of host associated use, the declare operation
699
+ // is the only carrier of the variable attributes,
700
+ // so we have to collect them here.
701
+ attributes |= getAttrsFromVariable (varIf);
702
+ isCapturedInInternalProcedure |=
703
+ varIf.isCapturedInInternalProcedure ();
704
+ if (varIf.isHostAssoc ()) {
705
+ // Do not track past such DeclareOp, because it does not
706
+ // currently provide any useful information. The host associated
707
+ // access will end up dereferencing the host association tuple,
708
+ // so we may as well stop right now.
709
+ v = defOp->getResult (0 );
710
+ // TODO: if the host associated variable is a dummy argument
711
+ // of the host, I think, we can treat it as SourceKind::Argument
712
+ // for the purpose of alias analysis inside the internal procedure.
713
+ type = SourceKind::HostAssoc;
714
+ breakFromLoop = true ;
715
+ return ;
716
+ }
713
717
}
714
718
if (getLastInstantiationPoint) {
715
719
// Fetch only the innermost instantiation point.
0 commit comments