https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119737

            Bug ID: 119737
           Summary: GCN/C++ vs. 'as': 'LLVM ERROR: Size expression must be
                    absolute.'
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tschwinge at gcc dot gnu.org
                CC: ams at gcc dot gnu.org
  Target Milestone: ---
            Target: GCN

We've got cases of GCN/C++ offloading code (XFAILed test cases soon to appear),
where we fail assembly due to:

    LLVM ERROR: Size expression must be absolute.
    [...]
    x86_64-pc-linux-gnu-accel-amdgcn-amdhsa-gcc: internal compiler error:
Aborted signal terminated program as
    [...]
    gcn mkoffload: fatal error:
[...]/x86_64-pc-linux-gnu-accel-amdgcn-amdhsa-gcc returned 4 exit status

That's with optimizations enabled, but not for '-O0'.

The issue is, '[...].xamdgcn-amdhsa.mkoffload.2.s':

    [...]
            .text
            .align  256
            .type   main._omp_fn.0,@function
    main._omp_fn.0:
    [...]
            s_getpc_b64     s[12:13]
            s_add_u32       s12, s12, __cxa_throw@rel32@lo+4
            s_addc_u32      s13, s13, __cxa_throw@rel32@hi+4
            s_swappc_b64    s[18:19], s[12:13]
    .LFE0:
            .section        .fake_gcc_except_table,"e",@progbits
    .LLSDA0:
            .byte   0xff
    [...]
            .byte   0
            .section        .text.unlikely
            .size   main._omp_fn.0, .-main._omp_fn.0
    [...]

That is, we emit 'main._omp_fn.0' into '.text', and after its program code,
emit (fake) exception handling data into '.fake_gcc_except_table', then switch
to '.section .text.unlikely', and that way indeed have following a bogus
'.size'.

If I manually patch that latter one to switch (back) to '.section .text', the
code assembles fine.

The '.fake_gcc_except_table' points to commit
r15-7543-g2b9bdb2d286e6872f4195ba2e710130cf6b2805d "GCN: Set 'UI_TARGET' for
'TARGET_EXCEPT_UNWIND_INFO' [PR94282, PR113331]",
<https://inbox.sourceware.org/8734gg89nq....@euler.schwinge.ddns.net>, but I've
not yet seen any similar issues, or any other issues related to that, in fact.

Given that 'main._omp_fn.0' ends with a 'noreturn' call to '__cxa_throw', that
might explain the '.text.unlikely' -- but why the mismatch between '.text' and
'.text.unlikely'?

I've not yet looked into creating a non-offloading, GCN target test case.

Reply via email to