llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.8k stars 11.91k forks source link

ppc64le MC assembler does not recognize symbols in certain instructions #44499

Open d-parks opened 4 years ago

d-parks commented 4 years ago
Bugzilla Link 45154
Version 9.0
OS Linux
CC @DougGregor,@zygoloid

Extended Description

Given the following pruned down assembly source generated from XLC: [dparks@gsn1 tmp]$ cat t.s .set r0,0; .set SP,1; .set RTOC,2; .set r3,3; .set r4,4 .set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 .set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 .set fp0,0; .set fp1,1; .set fp2,2; .set fp3,3; .set fp4,4 .set BO_ALWAYS,20; .set BO_ALWAYS_1,21; .set BO_ALWAYS_2,22 .set CR0_LT,0; .set CR0_GT,1; .set CR0_EQ,2; .set CR0_SO,3

    .file   "t.c"
    .globl  f
    .type   f,@function
    .size   f,40
    .localentry     f,8
    .extern .TOC.

    .section        ".text","ax"
    .align  5

.LC.The_Code: f: addis RTOC,r12,.TOC.-$@ha addi RTOC,RTOC,.TOC.-$+4@l addis r3,RTOC,.LC.toc@toc@ha ld r3,.LC.toc@toc@l(r3) lfd fp1,0(r3) bclr BO_ALWAYS,CR0_LT

    .section        ".toc","wa"
    .align  3

.LC.toc: .tc d[TC],d

    .ident  "Mon Mar  9 08:34:47 2020 .IBM XL C/C++ for Linux, Version 16.1.1.3."

    .comm   d,8,8

[dparks@gsn1 tmp]$

The source assembles correctly with both xlc and gcc: [dparks@gsn1 tmp]$ xlc --version IBM XL C/C++ for Linux, V16.1.1 (Community Edition)

[dparks@gsn1 tmp]$ xlc -c t.s [dparks@gsn1 tmp]$ gcc --version gcc (GCC) 9.2.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [dparks@gsn1 tmp]$ gcc -c t.s [dparks@gsn1 tmp]$ But fails with the following errors when assembled with clang: [dparks@gsn1 tmp]$ /home/sw/thirdparty/llvm/linuxpower/9.0-openmp/bin/clang --version clang version 9.0.0 (/home//git/official/llvm/tools/clang 45898f3be1d37727502cd6342b14c19e7c94bfae) (/home//git/official/llvm 5364ee5faec778f1ddf86b6b4b8452df7db191c5) Target: powerpc64le-unknown-linux-gnu Thread model: posix InstalledDir: /home/sw/thirdparty/llvm/linuxpower/9.0-openmp/bin [dparks@gsn1 tmp]$ [dparks@gsn1 tmp]$ /home/sw/thirdparty/llvm/linuxpower/9.0-openmp/bin/clang -c t.s t.s:22:30: error: invalid memory operand ld r3,.LC.toc@toc@l(r3) ^ t.s:23:19: error: invalid memory operand lfd fp1,0(r3) ^ [dparks@gsn1 tmp]$ I've also run in to the same problem with store instructions.
llvmbot commented 3 months ago

@llvm/issue-subscribers-backend-powerpc

Author: David Parks (d-parks)

| | | | --- | --- | | Bugzilla Link | [45154](https://llvm.org/bz45154) | | Version | 9.0 | | OS | Linux | | CC | @DougGregor,@zygoloid | ## Extended Description Given the following pruned down assembly source generated from XLC: [dparks@gsn1 tmp]$ cat t.s .set r0,0; .set SP,1; .set RTOC,2; .set r3,3; .set r4,4 .set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 .set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 .set fp0,0; .set fp1,1; .set fp2,2; .set fp3,3; .set fp4,4 .set BO_ALWAYS,20; .set BO_ALWAYS_1,21; .set BO_ALWAYS_2,22 .set CR0_LT,0; .set CR0_GT,1; .set CR0_EQ,2; .set CR0_SO,3 .file "t.c" .globl f .type f,@function .size f,40 .localentry f,8 .extern .TOC. .section ".text","ax" .align 5 .LC.The_Code: f: addis RTOC,r12,.TOC.-$@ha addi RTOC,RTOC,.TOC.-$+4@l addis r3,RTOC,.LC.toc@toc@ha ld r3,.LC.toc@toc@l(r3) lfd fp1,0(r3) bclr BO_ALWAYS,CR0_LT .section ".toc","wa" .align 3 .LC.toc: .tc d[TC],d .ident "Mon Mar 9 08:34:47 2020 .IBM XL C/C++ for Linux, Version 16.1.1.3." .comm d,8,8 [dparks@gsn1 tmp]$ The source assembles correctly with both xlc and gcc: [dparks@gsn1 tmp]$ xlc --version IBM XL C/C++ for Linux, V16.1.1 (Community Edition) <snip> [dparks@gsn1 tmp]$ xlc -c t.s [dparks@gsn1 tmp]$ gcc --version gcc (GCC) 9.2.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [dparks@gsn1 tmp]$ gcc -c t.s [dparks@gsn1 tmp]$ But fails with the following errors when assembled with clang: [dparks@gsn1 tmp]$ /home/sw/thirdparty/llvm/linuxpower/9.0-openmp/bin/clang --version clang version 9.0.0 (/home/<DELETED>/git/official/llvm/tools/clang 45898f3be1d37727502cd6342b14c19e7c94bfae) (/home/<DELETED>/git/official/llvm 5364ee5faec778f1ddf86b6b4b8452df7db191c5) Target: powerpc64le-unknown-linux-gnu Thread model: posix InstalledDir: /home/sw/thirdparty/llvm/linuxpower/9.0-openmp/bin [dparks@gsn1 tmp]$ [dparks@gsn1 tmp]$ /home/sw/thirdparty/llvm/linuxpower/9.0-openmp/bin/clang -c t.s t.s:22:30: error: invalid memory operand ld r3,.LC.toc@toc@l(r3) ^ t.s:23:19: error: invalid memory operand lfd fp1,0(r3) ^ [dparks@gsn1 tmp]$ I've also run in to the same problem with store instructions.