[PATCH] D102925: [RISCV] Add wrong arch attribute objfile test.

Jessica Clarke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 22 10:39:06 PDT 2021


jrtc27 added a comment.

In D102925#2775509 <https://reviews.llvm.org/D102925#2775509>, @khchen wrote:

> I got the similar IR during LTO because the clang driver would not pass the -mattr option to lto code generator.
>
> example:
>
>   $(clang) -target riscv64-unknown-linux-gnu -flto -O3 gmain.cpp.o -c main.cpp
>   $(clang) -target riscv64-unknown-linux-gnu -flto -O3 gmain.cpp.o -o Builtins
>
> In addition, backend will adjust the target-features according to function attribute [1][2], 
> it means the generated function would have +a,+c,+d,+f,+m instructions,
> Why do you think the arch value in object file should still be `rv64i2p0`?
>
> [1] https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp#L76
> [2] https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp#L172

Because the target features only apply to that function. See https://godbolt.org/z/as618Kz4z and note that different functions have different target-features, but *only* rv64i2p0 should be present in the output. There are two choices here:

1. Each module records its -march= string and those get combined for the attributes section
2. Only the -march= passed at link time is used for the attributes section

I think 2 is just asking for trouble and we'll end up with people linking without specifying the right -march string (could even be using external libraries that may have been compiled with different extensions to their code) and the solution has to be 1.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102925/new/

https://reviews.llvm.org/D102925



More information about the llvm-commits mailing list