@@ -60,7 +60,15 @@ void AliasAnalysis::Source::print(llvm::raw_ostream &os) const {
6060 attributes.Dump (os, EnumToString);
6161}
6262
63- bool AliasAnalysis::Source::isPointerReference (mlir::Type ty) {
63+ bool AliasAnalysis::isRecordWithPointerComponent (mlir::Type ty) {
64+ auto eleTy = fir::dyn_cast_ptrEleTy (ty);
65+ if (!eleTy)
66+ return false ;
67+ // TO DO: Look for pointer components
68+ return mlir::isa<fir::RecordType>(eleTy);
69+ }
70+
71+ bool AliasAnalysis::isPointerReference (mlir::Type ty) {
6472 auto eleTy = fir::dyn_cast_ptrEleTy (ty);
6573 if (!eleTy)
6674 return false ;
@@ -86,15 +94,7 @@ bool AliasAnalysis::Source::isBoxData() const {
8694 origin.isData ;
8795}
8896
89- bool AliasAnalysis::Source::isRecordWithPointerComponent () const {
90- auto eleTy = fir::dyn_cast_ptrEleTy (valueType);
91- if (!eleTy)
92- return false ;
93- // TO DO: Look for pointer components
94- return mlir::isa<fir::RecordType>(eleTy);
95- }
96-
97- AliasResult AliasAnalysis::alias (Value lhs, Value rhs) {
97+ AliasResult AliasAnalysis::alias (mlir::Value lhs, mlir::Value rhs) {
9898 // TODO: alias() has to be aware of the function scopes.
9999 // After MLIR inlining, the current implementation may
100100 // not recognize non-aliasing entities.
@@ -111,6 +111,7 @@ AliasResult AliasAnalysis::alias(Value lhs, Value rhs) {
111111 // it aliases with everything
112112 if (lhsSrc.kind >= SourceKind::Indirect ||
113113 rhsSrc.kind >= SourceKind::Indirect) {
114+ LLVM_DEBUG (llvm::dbgs () << " aliasing because of indirect access\n " );
114115 return AliasResult::MayAlias;
115116 }
116117
@@ -169,10 +170,12 @@ AliasResult AliasAnalysis::alias(Value lhs, Value rhs) {
169170 // Box for POINTER component inside an object of a derived type
170171 // may alias box of a POINTER object, as well as boxes for POINTER
171172 // components inside two objects of derived types may alias.
172- if ((src1->isRecordWithPointerComponent () && src2->isTargetOrPointer ()) ||
173- (src2->isRecordWithPointerComponent () && src1->isTargetOrPointer ()) ||
174- (src1->isRecordWithPointerComponent () &&
175- src2->isRecordWithPointerComponent ())) {
173+ if ((isRecordWithPointerComponent (src1->valueType ) &&
174+ src2->isTargetOrPointer ()) ||
175+ (isRecordWithPointerComponent (src2->valueType ) &&
176+ src1->isTargetOrPointer ()) ||
177+ (isRecordWithPointerComponent (src1->valueType ) &&
178+ isRecordWithPointerComponent (src2->valueType ))) {
176179 LLVM_DEBUG (llvm::dbgs () << " aliasing because of pointer components\n " );
177180 return AliasResult::MayAlias;
178181 }
@@ -310,7 +313,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
310313
311314 // TODO: Take followBoxData into account when setting the pointer
312315 // attribute
313- if (Source:: isPointerReference (ty))
316+ if (isPointerReference (ty))
314317 attributes.set (Attribute::Pointer);
315318 global = llvm::cast<fir::AddrOfOp>(op).getSymbol ();
316319 breakFromLoop = true ;
@@ -387,7 +390,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
387390 if (fir::valueHasFirAttribute (v, fir::getTargetAttrName ()))
388391 attributes.set (Attribute::Target);
389392
390- if (Source:: isPointerReference (ty))
393+ if (isPointerReference (ty))
391394 attributes.set (Attribute::Pointer);
392395 }
393396
0 commit comments