[PATCH] D70116: [RISCV] add subtargets initialized with target feature

Kuan Hsu Chen (Zakk) via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 27 04:20:13 PST 2019


khchen added a comment.

In D70116#1761492 <https://reviews.llvm.org/D70116#1761492>, @lenary wrote:

> So am I right in thinking that neither `foo` nor `foo2` will trigger the `ABI_Unknown` issue, and the issue is only coming from hand-written assembly files?
>
> Actually, you may need to specify `-target-abi` in the top of the `subtarget-features-std-ext.ll` file.


Sorry I didn't explain clearly,
The problem is caused by when I try to enable LTO and it need to pass `mabi` to LTO code generator (mabi is not encoded in bitcode)
like we compile below case with `llc example.c -mtriple=riscv32 -mabi=ilp32f`.

  define float @foo(i32 %a) nounwind #0 {
    %conv = sitofp i32 %a to float
    ret float %conv
  }
  
  define float @foo2(i32 %a) nounwind #1{
    %conv = sitofp i32 %a to float
    ret float %conv
  }
  
  attributes #0 = { "target-features"="+f"}
  attributes #1 = { "target-features"="+f"}

and they will show two error messages `Hard-float 'f' ABI can't be used for a target that doesn't support the F instruction set extension`.
so there is no any issue in `subtarget-features-std-ext.ll` without -target-abi.

I think the root cause is backend shares the ABI parsing and checking function (`computeTargetABI`) in codegen and MC layer when instance RISCVAsmBackend (note: IR function is not available at this point)
ref. https://github.com/llvm/llvm-project/commit/fea4957177315f83746dca90cb4c9013eb465c46

so this patch is workable, but it's not useful for LTO, not useful enough to support per function feature in backend, and then I'm not sure it's worth to upstream this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70116





More information about the llvm-commits mailing list