Skip to content

[flang] Adding a couple of tests to the alias analysis #125917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion flang/test/Analysis/AliasAnalysis/alias-analysis-2.fir
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
// CHECK-DAG: arg2.load#0 <-> arg2.addr#0: MustAlias
// CHECK-DAG: boxp1.addr#0 <-> arg2.addr#0: MayAlias

// TODO: Can the address in a pointer alias the address of a pointer, even when the
// pointer has no box. Should this be NoAlias?
// T3: CHECK-DAG: p1.addr#0 <-> p1.tgt#0: MayAlias
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want "T3" and "T4" to appear in comments when landing upstream?

I wrote those just to guide discussion of #117785.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shoot no. I missed that. I will post a new review.


// The addresses stored in two different pointers can alias, even if one has no
// box. In this program, they happen to be the same address.
// T4: CHECK-DAG: p1.tgt#0 <-> boxp1.addr#0: MayAlias

func.func @_QFPtest(%arg0: !fir.ref<f32> {fir.bindc_name = "v1", fir.target}, %arg1: !fir.ref<f32> {fir.bindc_name = "v2", fir.target}, %arg2: !fir.ref<!fir.box<!fir.ptr<f32>>> ) attributes {test.ptr = "func"} {

%1 = fir.alloca !fir.ptr<f32> {test.ptr = "p1.addr"}
Expand All @@ -63,7 +71,7 @@ func.func @_QFPtest(%arg0: !fir.ref<f32> {fir.bindc_name = "v1", fir.target}, %a
fir.store %6 to %4 : !fir.ref<!fir.ptr<f32>>

%0 = fir.alloca !fir.box<!fir.ptr<f32>> {bindc_name = "p1", uniq_name = "_QFtestEp1"}
%7 = fir.load %1 : !fir.ref<!fir.ptr<f32>>
%7 = fir.load %1 {test.ptr="p1.tgt"} : !fir.ref<!fir.ptr<f32>>
%8 = fir.embox %7 : (!fir.ptr<f32>) -> !fir.box<!fir.ptr<f32>>
fir.store %8 to %0 : !fir.ref<!fir.box<!fir.ptr<f32>>>

Expand Down