[OpenMP][AArch64] ompt/synchronization/[masked.c | master.c] fail due to possibly wrong codegen
On AArch64, ompt/synchronization/master.c and ompt/synchronization/masked.c both fail in similar ways in current main:
# | /GitHub/llvm/llvm-project/openmp/runtime/test/ompt/synchronization/masked.c:38:11: error: CHECK: expected string not found in input
# | // CHECK: {{^}}[[MASTER_ID]]: current_address={{.*}}[[RETURN_ADDRESS_END]]
# | ^
# | <stdin>:8:120: note: scanning from here
# | 281474976710658: ompt_event_masked_end: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0xaaaaaf8260d0
# | ^
# | <stdin>:8:120: note: with "MASTER_ID" equal to "281474976710658"
# | 281474976710658: ompt_event_masked_end: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0xaaaaaf8260d0
# | ^
# | <stdin>:8:120: note: with "RETURN_ADDRESS_END" equal to "0xaaaaaf8260d0"
# | 281474976710658: ompt_event_masked_end: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0xaaaaaf8260d0
# | ^
# | <stdin>:9:13: note: possible intended match here
# | 281474976710658: current_address=0xaaaaaf8260d8 or 0xaaaaaf8260d4
When looking at the disassembly, there is a spurious branch instruction that isn't supposed to be there:
ce8: 91364000 add x0, x0, #0xd90
cec: 97ffff19 bl 950 <__kmpc_end_master@plt>
cf0: 14000001 b cf4 <main.omp_outlined+0xd4>
cf4: d503201f nop
cf8: 14000001 b cfc <main.omp_outlined+0xdc>
cfc: d0000088 adrp x8, 12000 <__gmon_start__@Base>
d00: f9404d08 ldr x8, [x8, #152]
I'd expect the code to fallthrough from the nop (label) to the adrp. Instead, there's a branch to the adrp instruction.
@llvm/issue-subscribers-openmp
Author: Carlos Eduardo Seo (ceseo)
# | /GitHub/llvm/llvm-project/openmp/runtime/test/ompt/synchronization/masked.c:38:11: error: CHECK: expected string not found in input
# | // CHECK: {{^}}[[MASTER_ID]]: current_address={{.*}}[[RETURN_ADDRESS_END]]
# | ^
# | <stdin>:8:120: note: scanning from here
# | 281474976710658: ompt_event_masked_end: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0xaaaaaf8260d0
# | ^
# | <stdin>:8:120: note: with "MASTER_ID" equal to "281474976710658"
# | 281474976710658: ompt_event_masked_end: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0xaaaaaf8260d0
# | ^
# | <stdin>:8:120: note: with "RETURN_ADDRESS_END" equal to "0xaaaaaf8260d0"
# | 281474976710658: ompt_event_masked_end: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0xaaaaaf8260d0
# | ^
# | <stdin>:9:13: note: possible intended match here
# | 281474976710658: current_address=0xaaaaaf8260d8 or 0xaaaaaf8260d4
When looking at the disassembly, there is a spurious branch instruction that isn't supposed to be there:
ce8: 91364000 add x0, x0, #<!-- -->0xd90
cec: 97ffff19 bl 950 <__kmpc_end_master@<!-- -->plt>
cf0: 14000001 b cf4 <main.omp_outlined+0xd4>
cf4: d503201f nop
cf8: 14000001 b cfc <main.omp_outlined+0xdc>
cfc: d0000088 adrp x8, 12000 <__gmon_start__@<!-- -->Base>
d00: f9404d08 ldr x8, [x8, #<!-- -->152]
I'd expect the code to fallthrough from the nop (label) to the adrp. Instead, there's a branch to the adrp instruction.
@llvm/issue-subscribers-backend-aarch64
Author: Carlos Eduardo Seo (ceseo)
# | /GitHub/llvm/llvm-project/openmp/runtime/test/ompt/synchronization/masked.c:38:11: error: CHECK: expected string not found in input
# | // CHECK: {{^}}[[MASTER_ID]]: current_address={{.*}}[[RETURN_ADDRESS_END]]
# | ^
# | <stdin>:8:120: note: scanning from here
# | 281474976710658: ompt_event_masked_end: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0xaaaaaf8260d0
# | ^
# | <stdin>:8:120: note: with "MASTER_ID" equal to "281474976710658"
# | 281474976710658: ompt_event_masked_end: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0xaaaaaf8260d0
# | ^
# | <stdin>:8:120: note: with "RETURN_ADDRESS_END" equal to "0xaaaaaf8260d0"
# | 281474976710658: ompt_event_masked_end: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0xaaaaaf8260d0
# | ^
# | <stdin>:9:13: note: possible intended match here
# | 281474976710658: current_address=0xaaaaaf8260d8 or 0xaaaaaf8260d4
When looking at the disassembly, there is a spurious branch instruction that isn't supposed to be there:
ce8: 91364000 add x0, x0, #<!-- -->0xd90
cec: 97ffff19 bl 950 <__kmpc_end_master@<!-- -->plt>
cf0: 14000001 b cf4 <main.omp_outlined+0xd4>
cf4: d503201f nop
cf8: 14000001 b cfc <main.omp_outlined+0xdc>
cfc: d0000088 adrp x8, 12000 <__gmon_start__@<!-- -->Base>
d00: f9404d08 ldr x8, [x8, #<!-- -->152]
I'd expect the code to fallthrough from the nop (label) to the adrp. Instead, there's a branch to the adrp instruction.
Add our OMPT expert @jprotze here
Is this fixed with a3c0f70, or did you see the issue on non-darwin platform?
Is this fixed with a3c0f70, or did you see the issue on non-darwin platform?
It's Linux. If I apply the same rationale from Darwin, the tests pass. But looking at the disassembly above, I think there still is a codegen problem specific to AArch64 (one unnecessary branch instruction being generated).
What we could do for now is to apply the same fix for Linux here and add a FIXME comment pointing to this issue so whoever is working on AArch64 backend can take a look and see if it is a real bug. Does that sound reasonable?
Since the testcase workaround fixed the problem, I'll close this. When I have a better understanding about the weird codegen observed here, I'll open a new issue against the AArch64 backend.