This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][NFC] Move ilp32e/rv32e checks to AsmParser and TargetLowering
Needs ReviewPublic

Authored by eopXD on Dec 15 2021, 11:23 PM.

Details

Reviewers
asb

Diff Detail

Event Timeline

eopXD created this revision.Dec 15 2021, 11:23 PM
eopXD requested review of this revision.Dec 15 2021, 11:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 15 2021, 11:23 PM
asb added a comment.Dec 16 2021, 1:11 AM

Could you please add a test case or test cases that highlight the behavioural change?

eopXD updated this revision to Diff 394798.Dec 16 2021, 2:45 AM

Update code.

eopXD added a comment.EditedDec 16 2021, 2:47 AM

Hi @asb,

I think this patch only addresses the TODO and has no behavioral change.
Test case is already covered under llvm/test/MC/RISCV/target-abi-invalid.s.

I think this patch only addresses the TODO and has no behavioral change.

I suggest renaming the title to "[RISCV][NFC] Move ilp32e/rv32e checks to AsmParser and TargetLowering", to make it clearer that this is just a refactoring.

Test case is already covered under llvm/test/MC/RISCV/target-abi-invalid.s.

The new error message in RISCVISelLowering.cpp isn't yet covered by tests but that line currently isn't reachable due to the report_fatal_error in line 52. It's not ideal that this can't have test coverage. @asb thoughts?

The new error message in RISCVISelLowering.cpp isn't yet covered by tests but that line currently isn't reachable due to the report_fatal_error in line 52. It's not ideal that this can't have test coverage. @asb thoughts?

I was assuming that it would be a bad idea to remove the report_fatal_error because code generation would still occur (despite the error message) and possibly crash in unpleasant ways but maybe that's not significantly different from the other error conditions above where that also happens.

jrtc27 added inline comments.Dec 16 2021, 6:25 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
72 ↗(On Diff #394798)

This is clearly wrong, just copy-pasted from the RVI cases

eopXD retitled this revision from [RISCV][ABI] Have ABI checks for ilp32e under AsmParser and TargetLowering to [RISCV][NFC] Move ilp32e/rv32e checks to AsmParser and TargetLowering.Dec 16 2021, 8:26 AM
eopXD updated this revision to Diff 394890.Dec 16 2021, 8:28 AM
eopXD marked an inline comment as done.

Delete redundant code.

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
72 ↗(On Diff #394798)

Yes you are right. I think the code I added here is redundant. Just deleted.

asb added inline comments.Dec 30 2021, 4:57 AM
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
55

This code path can be exercised through a test like those in test/CodeGen/RISCV/target-abi-invalid.ll (e.g. targeting riscv32 -mattr=+e and without setting the ABI to ilp32e). With ilp32e ABI support not yet landed but some support for command-line options etc, the current state of affairs is a bit weird. But I think it would be better to add a test case to taret-abi-invalid.ll rather than removing this logic.

eopXD updated this revision to Diff 407859.Feb 11 2022, 6:09 AM

Rebase and add testcase.

eopXD added inline comments.Feb 11 2022, 6:20 AM
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
55

Yeah, I have added a test for this. We would have to wait for ilp32e to land before this patch.