@@ -60,7 +60,15 @@ void AliasAnalysis::Source::print(llvm::raw_ostream &os) const {
60
60
attributes.Dump (os, EnumToString);
61
61
}
62
62
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) {
64
72
auto eleTy = fir::dyn_cast_ptrEleTy (ty);
65
73
if (!eleTy)
66
74
return false ;
@@ -86,15 +94,7 @@ bool AliasAnalysis::Source::isBoxData() const {
86
94
origin.isData ;
87
95
}
88
96
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) {
98
98
// TODO: alias() has to be aware of the function scopes.
99
99
// After MLIR inlining, the current implementation may
100
100
// not recognize non-aliasing entities.
@@ -111,6 +111,7 @@ AliasResult AliasAnalysis::alias(Value lhs, Value rhs) {
111
111
// it aliases with everything
112
112
if (lhsSrc.kind >= SourceKind::Indirect ||
113
113
rhsSrc.kind >= SourceKind::Indirect) {
114
+ LLVM_DEBUG (llvm::dbgs () << " aliasing because of indirect access\n " );
114
115
return AliasResult::MayAlias;
115
116
}
116
117
@@ -169,10 +170,12 @@ AliasResult AliasAnalysis::alias(Value lhs, Value rhs) {
169
170
// Box for POINTER component inside an object of a derived type
170
171
// may alias box of a POINTER object, as well as boxes for POINTER
171
172
// 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 ))) {
176
179
LLVM_DEBUG (llvm::dbgs () << " aliasing because of pointer components\n " );
177
180
return AliasResult::MayAlias;
178
181
}
@@ -310,7 +313,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
310
313
311
314
// TODO: Take followBoxData into account when setting the pointer
312
315
// attribute
313
- if (Source:: isPointerReference (ty))
316
+ if (isPointerReference (ty))
314
317
attributes.set (Attribute::Pointer);
315
318
global = llvm::cast<fir::AddrOfOp>(op).getSymbol ();
316
319
breakFromLoop = true ;
@@ -387,7 +390,7 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
387
390
if (fir::valueHasFirAttribute (v, fir::getTargetAttrName ()))
388
391
attributes.set (Attribute::Target);
389
392
390
- if (Source:: isPointerReference (ty))
393
+ if (isPointerReference (ty))
391
394
attributes.set (Attribute::Pointer);
392
395
}
393
396
0 commit comments