<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/148147>148147</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            RISC-V backend does not support PreserveMost calling convention
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          CaiWeiran
      </td>
    </tr>
</table>

<pre>
    The RISC-V backend currently does not support the `PreserveMost` calling convention. Attempting to compile code that uses it results in a fatal error:

> fatal error: error in backend: Unsupported calling convention

A minimal example can be seen on Compiler Explorer: 
https://godbolt.org/z/h7e5WT7eM

This issue raises a few questions:

* Should the RISC-V backend implement support for `PreserveMost`, similar to x86, ARM, and AArch64?
* Alternatively, should the frontend (or mid-end) automatically lower unsupported calling conventions like `PreserveMost` to a more compatible one such as `C`?

It would be helpful to clarify whether support is planned or if users should explicitly avoid using this calling convention on RISC-V targets.

Thanks!
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8U82O4zYMfhr5Qkxgy_HPHHxw0zWwhwGK3Wn3TNt0rI4suRKVTPr0hZxsp8gEBQzIIEDy-yN6r46GqBHFL6L4NcHAs3XNAdUPUg5N0tvx0rzOBN--fj88_QE9Dm9kRhiCc2RYX2C05MFYBh_W1ToGnglEmf7myJM70Yv1LMoUBtRamSMM1pzIsLJmBy0zLSvHMlsY7LIqTTDYkYBnZAiePCgGRz5o9qAMIEzIqIGcs07krUi3L_9yV7_-xI4b5Fj73dxA0vgAz3VUC4syaomj3nFZIx400BN4IgPWwOEK08GX91VbR9s2kbYz8-ojItkJ2R3t2FvNO-uOQnZ_C9nNFRU_Xit6ue55nZUH5X0gcKgiUYSJzvBXIB_R-A9ysoXvsw163LS9c0JFjAuZDwMm6x4YIOQBvFqURhfFfq_LWGm_vcQHzQht64a53Iu8u-1sNZMzyOpE-rK1f4CYnDUc1wtZWweLGp-ixvIZMLBdkFXU9wLanslB-F_dPWj19jAzbAFhsY62bCCrXhNYQ-DDMAP62HOI3K6Y0_Yrw3nD2BPMpNcp6C1ZGp2aLnCeiWdy_yqlPKwajaERYlamGDjnf_Kk91WrQcWQ48mqEYLfkhqN-8wiRuNmDaM7EvvdT6PRvHkhs2Rs8vE5f8aEmqwqpJQyrWUyN0jFMNQ5DsVzleZ5OVBayxxxqvqpz-oyUY1MZZFWWZbWMpNyl1OGMi_Kos7LssJe7FNaUOmd1qclZi7ZktVk-zrbV4nGnrTfjlxKQ-dr7oSU8eZdE5ue-nD0Yp9q5dl_jGHFmpq7yH06-f_69kCaJDjd3J2H4jn0u8EuQnZx2-15Wp39kwYWstsweiG7G4lTI_8JAAD__zKvldA">