[llvm-bugs] [Bug 51161] New: `-mattr` should be encoded in the IR for LTO's sake

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 22 01:14:18 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51161

            Bug ID: 51161
           Summary: `-mattr` should be encoded in the IR for LTO's sake
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: twd2.me at gmail.com
                CC: llvm-bugs at lists.llvm.org, smithp352 at googlemail.com

Created attachment 25046
  --> https://bugs.llvm.org/attachment.cgi?id=25046&action=edit
The diagnostic information.

When compiling the following code with LTO:

```
$ cat test.c
void _start()
{
    asm volatile (
        ".balign 4\n\t"
        "c.nop\n\t"
        ".balign 4\n\t"
        "c.nop"
    );
}

$ clang -march=rv64imac -O2 -flto -mno-relax -c test.c
$ ld.lld test.o
```

lld fails with `unable to write nop sequence of 2 bytes`.
The diagnostic information is attached.

It looks like to be due to the `HasStdExtC` check failure in
`RISCVAsmBackend::writeNopData`.
And, if I use `ld.lld -mllvm -mattr=+c test.o`, lld can generate proper machine
code.
According to Nick Desaulniers [1], `-mattr` should be encoded in the IR for
LTO's sake.

My LLVM version: commit 1b61d837b9d0 ("[Inline] Add test for PR50589 (NFC)")
[1]
https://lore.kernel.org/linux-riscv/CAKwvOdmNji0AbYUiOSfb5cLD+g7YCpXk4oDupa8gTfgzYmxvBg@mail.gmail.com/

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210722/25fa689a/attachment.html>


More information about the llvm-bugs mailing list