This is an archive of the discontinued LLVM Phabricator instance.

[flang][OpenMP] Fix pointer variables in atomic read/write
ClosedPublic

Authored by peixin on May 17 2022, 7:43 AM.

Details

Summary

For pointer variables, using getSymbolAddress cannot get the coorect
address for atomic read/write operands. Use genExprAddr to fix it.

Diff Detail

Event Timeline

peixin created this revision.May 17 2022, 7:43 AM
peixin requested review of this revision.May 17 2022, 7:43 AM

Hi Peixin, thank you for this patch. I like the name change from numbered testcases to descriptive testcases, however can we please decouple that change from this change (as an NFC)? Right now it is hard to see the change in generated IR after this fix.

Hi Peixin, thank you for this patch. I like the name change from numbered testcases to descriptive testcases, however can we please decouple that change from this change (as an NFC)? Right now it is hard to see the change in generated IR after this fix.

Good point. Thanks for the notice. It is truly not easy to review when I look back to this patch now :). Will decouple the change. I should also add some comments/descriptions in the test case for what kind of IR it should generate with this pathc.

peixin updated this revision to Diff 431236.May 22 2022, 6:10 AM
peixin edited the summary of this revision. (Show Details)

As @shraiysh suggested, decouple the previous patch and add some comments in the test cases to describe what IR should be generated after this patch.

shraiysh added inline comments.May 23 2022, 8:00 PM
flang/test/Lower/OpenMP/atomic-write.f90
49

Shouldn't this be the following?

%[[PTR_VAL:.*]] = fir.load %[[VAL_1]] : !fir.ref<!fir.ptr<i32>>
omp.atomic.write %[[PTR_VAL]] = %[[VAL_3]]   : !fir.ptr<i32>, i32
peixin updated this revision to Diff 431636.May 24 2022, 3:59 AM
peixin edited the summary of this revision. (Show Details)
peixin added inline comments.May 24 2022, 4:12 AM
flang/test/Lower/OpenMP/atomic-write.f90
49

Right. I forgot to check tco. The previous fix fails to run tco. I had thought the codegen can handle this. Now fixed this.

shraiysh accepted this revision.May 26 2022, 7:42 AM
shraiysh added 1 blocking reviewer(s): NimishMishra.

@NimishMishra this LGTM, but as you are the author of the atomic read and write lowering, please check this patch. (adding you as a blocking reviewer)

This revision is now accepted and ready to land.May 27 2022, 7:08 PM
This revision was automatically updated to reflect the committed changes.
flang/test/Lower/OpenMP/atomic-write.f90