This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Support ABI checking with per function target-features
ClosedPublic

Authored by khchen on Nov 28 2019, 8:04 PM.

Details

Summary

This is subsequent patch of https://reviews.llvm.org/D70116.

This is one of patches for enabling LTO support in RISCV, in some time LTO code generator will handle below case with -mabi=ilp32f, it's similar to llc example.c -mtriple=riscv32 -mabi=ilp32f.

define float @foo(i32 %a) nounwind #0 {
...
}

attributes #0 = { "target-features"="+f"}
  1. at this moment we assume one compilation unit only have same abi.
  2. The target-features is per function attribute, and the original checking is at

too early stage so backned can't get the function attribute at that times.

so I think maybe moving the checking to RISCVTargetLowering is a good idea.

  1. if users don't specific -mattr, the default target-feature come from IR attribute.
  2. fix https://reviews.llvm.org/D70116 failed case

Diff Detail

Event Timeline

khchen created this revision.Nov 28 2019, 8:04 PM
khchen edited the summary of this revision. (Show Details)Nov 28 2019, 10:13 PM
This comment was removed by khchen.
khchen updated this revision to Diff 231503.Nov 29 2019, 2:37 AM
khchen updated this revision to Diff 231533.Nov 29 2019, 6:47 AM
khchen edited the summary of this revision. (Show Details)
khchen updated this revision to Diff 231548.Nov 29 2019, 8:28 AM
khchen edited the summary of this revision. (Show Details)

update summary.

khchen edited the summary of this revision. (Show Details)Jan 14 2020, 12:18 AM

Hi @lenary,
This patch is necessary for enabling LTO
backend does this mismatch checking before getSubtargetImpl which reads the target-feature info from IR function attribute, and it will reset the target-abi if mismatching happen.
because I don't want to break this mismatch checking feature, so I move this checking later than getSubtargetImpl execution.

lenary added inline comments.Jan 14 2020, 5:53 AM
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
200

I'm not sure we should be using errs() here directly, should we perhaps be using report_fatal_error here?

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
59

I don't think we should be changing the ABI here if the user already chose one explicitly.

asb added inline comments.Jan 14 2020, 6:35 AM
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
200

I implemented the RISCVBaseInfo checking using report_fatal_error initially, but moved to complaining via errs() after feedback that this better matched what other backends do in this case.

khchen marked an inline comment as done.Jan 14 2020, 7:47 PM
khchen added inline comments.
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
59

I follow the same behavior to changing the ABI. please see https://github.com/llvm/llvm-project/blob/master/llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp#L59-L68. If we want to change the original behavior maybe it should be another patch?

lenary accepted this revision.Jan 15 2020, 12:37 AM

LGTM!

This revision is now accepted and ready to land.Jan 15 2020, 12:37 AM
This revision was automatically updated to reflect the committed changes.

@khchen We have a load of EXPENSIVE_CHECKS RISCV MC + asm failures, a lot of which appear to be related to these changes to RISCVAsmParser please can you take a look?

First appeared:
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/21599/

Current:
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/21630/steps/test-check-all/logs/stdio

khchen added a comment.EditedJan 16 2020, 6:10 PM

@khchen We have a load of EXPENSIVE_CHECKS RISCV MC + asm failures, a lot of which appear to be related to these changes to RISCVAsmParser please can you take a look?

First appeared:
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/21599/

Current:
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/21630/steps/test-check-all/logs/stdio

Sorry, this is my bug.
I revert it https://reviews.llvm.org/rGcef838e65f9a2aeecf5e19431077bc16b01a79fb
It passed LLVM_ENABLE_EXPENSIVE_CHECKS on linux so I didn't catch it, Sorry again.
The root cause is std::string::back shall not be called on empty strings.

khchen updated this revision to Diff 238687.Jan 16 2020, 7:03 PM

I fixed bug here, but I'm not sure this small fixed should be another commit or not.
@lenary, do you have any suggestion?

thanks.

khchen reopened this revision.Jan 16 2020, 7:03 PM
This revision is now accepted and ready to land.Jan 16 2020, 7:03 PM
khchen requested review of this revision.Jan 16 2020, 7:03 PM
lenary accepted this revision.Jan 22 2020, 3:28 AM

LGTM. Let's re-land this.

This revision is now accepted and ready to land.Jan 22 2020, 3:28 AM
This revision was automatically updated to reflect the committed changes.