|
1 | | -! Test case is taken from Fujitsu test suite: |
| 1 | +! The initial version of the test case was taken from Fujitsu test suite: |
2 | 2 | ! https://github.com/fujitsu/compiler-test-suite/blob/main/Fortran/0614/0614_0005.f |
3 | 3 | ! Fujitsu test suite is ARM-focused open source test suite: |
4 | 4 | ! https://github.com/fujitsu/compiler-test-suite |
5 | | -! It fails on ARM platform if we turn on local alias analysis |
6 | | -! for -O2 or higher optimization. |
7 | | -! See: https://github.com/llvm/llvm-project/pull/139682 |
| 5 | +! The original version does not explicitly state that the Cray pointer |
| 6 | +! from sub2 can alias, leading to miscompilation on the ARM platform |
| 7 | +! because Flang assumes that Cray pointers never alias. |
| 8 | +! This version includes the target attribute for the variable 'a', |
| 9 | +! which prevents miscompilation on ARM platforms. |
| 10 | +! See https://github.com/llvm/llvm-project/issues/141928 for more details. |
| 11 | + |
| 12 | +module mymodule |
| 13 | +contains |
| 14 | + subroutine sub2(a,b) |
| 15 | + integer, target:: a(10) |
| 16 | + integer b(10),pa,pb |
| 17 | + pointer (p1 ,pa) |
| 18 | + pointer (p2 ,pb) |
| 19 | + |
| 20 | + p1 = loc(a(1)) |
| 21 | + p2 = loc(b(1)) |
| 22 | + |
| 23 | + do i = 1,9 |
| 24 | + pa = pa + a(i+1) |
| 25 | + p1 = p1 + 4 |
| 26 | + end do |
| 27 | + |
| 28 | + b(1:10) = a(1:10) + b(1:10) |
| 29 | + |
| 30 | + return |
| 31 | + end |
| 32 | +end module mymodule |
8 | 33 |
|
9 | 34 | program main |
| 35 | + use mymodule |
10 | 36 | structure /str1/ |
11 | 37 | integer*4 ia(10)/10,9,8,7,6,5,4,3,2,1/ |
12 | 38 | integer*4 ib(10)/1,2,3,4,5,6,7,8,9,10/ |
@@ -72,20 +98,3 @@ subroutine sub(a,b) |
72 | 98 | return |
73 | 99 | end |
74 | 100 |
|
75 | | - subroutine sub2(a,b) |
76 | | - integer a(10),b(10),pa,pb |
77 | | - pointer (p1 ,pa) |
78 | | - pointer (p2 ,pb) |
79 | | - |
80 | | - p1 = loc(a(1)) |
81 | | - p2 = loc(b(1)) |
82 | | - |
83 | | - do i = 1,9 |
84 | | - pa = pa + a(i+1) |
85 | | - p1 = p1 + 4 |
86 | | - end do |
87 | | - |
88 | | - b(1:10) = a(1:10) + b(1:10) |
89 | | - |
90 | | - return |
91 | | - end |
|
0 commit comments