llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[Flang][OpenMP] SPEC CPU 2017 603.bwaves crashes when linked using lld

Open ceseo opened this issue 2 years ago • 5 comments

Using the most recent Flang + OpenMP on AArch64, 603.bwaves (fpspeed) segfaults in a __kmpc_global_thread_num call.

This happens in an OMP PARALLEL DO PRIVATE clause.

Looking at the disassemble, looks like a wrong relocation:

(gdb) disassemble
Dump of assembler code for function __kmpc_global_thread_num@plt:
   0x0000aaaaaaac8fe0 <+0>:     adrp    x16, 0xaaaaaaae9000
   0x0000aaaaaaac8fe4 <+4>:     ldr     x17, [x16, #2752]
=> 0x0000aaaaaaac8fe8 <+8>:     add     x16, x16, #0xac0
   0x0000aaaaaaac8fec <+12>:    br      x17

It's branching to an invalid address. So I'm not sure if this is an OpenMP or lld bug.

I'm trying to create a small reproducer for this and will update this issue if I can manage that.

ceseo avatar Dec 13 '23 13:12 ceseo

Correction: this also fails with GNU ld, but at a different point (much earlier). It is still a wrong relocation, though:

Dump of assembler code for function __kmpc_global_thread_num@plt:
=> 0x0000aaaaaaaab6c0 <+0>:     adrp    x16, 0xaaaaaaad8000 <[email protected]>
   0x0000aaaaaaaab6c4 <+4>:     ldr     x17, [x16, #48]
   0x0000aaaaaaaab6c8 <+8>:     add     x16, x16, #0x30
   0x0000aaaaaaaab6cc <+12>:    br      x17

ceseo avatar Dec 13 '23 14:12 ceseo

603.bwaves_s used to pass. And passes for me with a build from commit 3c6efe5fdbca07ada9a2710d68efdb07064044c2. I have built with -O3 optimisation.

kiranchandramohan avatar Dec 13 '23 14:12 kiranchandramohan

603.bwaves_s used to pass. And passes for me with a build from commit 3c6efe5. I have built with -O3 optimisation.

AArch64 or X86?

ceseo avatar Dec 13 '23 14:12 ceseo

AArch64

kiranchandramohan avatar Dec 13 '23 15:12 kiranchandramohan

I'm closing this. It was a linking issue in my environment.

ceseo avatar Dec 14 '23 20:12 ceseo