This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Generate correct ELF abi flag when empty .ll file has target-abi attribute

Authored by Yunzezhu on Aug 18 2022, 11:27 PM.



In patch target abi value is get from .ll file's target-abi attribute and set in RISCVAsmPrinter::emitFunctionEntryLabel function .
In this problem, an api mismatch error may be caused by failing to call function RISCVAsmPrinter::emitFunctionEntryLabel to set target-abi to correct one when the .ll is empty or a module has no function.
This patch move setting target-abi part to function RISCVAsmPrinter::emitStartOfAsmFile, make sure all .ll file and module in LTO read target-abi from module flag and set, with or without function.

Signed-off-by: xiaojing.zhang <>
Signed-off-by: jianxin.lai <>

Diff Detail

Event Timeline

Yunzezhu created this revision.Aug 18 2022, 11:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2022, 11:27 PM
Yunzezhu requested review of this revision.Aug 18 2022, 11:27 PM
StephenFan added inline comments.Aug 19 2022, 2:46 AM

The curly braces could be deleted?

Yunzezhu edited the summary of this revision. (Show Details)Aug 22 2022, 1:49 AM
Yunzezhu updated this revision to Diff 454675.Aug 22 2022, 7:12 PM

Deleted curly braces

luismarques accepted this revision.Aug 24 2022, 11:56 AM

LGTM. Thanks!


Nit: if this test file is just going to contain the flags check for the foreseeable future then there's not much point in overriding the CHECK prefix.

This revision is now accepted and ready to land.Aug 24 2022, 11:56 AM
jrtc27 added inline comments.Aug 24 2022, 1:03 PM

Inconsistent spacing in {}

Yunzezhu updated this revision to Diff 455780.Aug 25 2022, 8:11 PM

Deleted unnecessary check prefix.
Added space in attributes flag.

Thank you all! I will commit this patch for @Yunzezhu.