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

    <tr>
        <th>Summary</th>
        <td>
            OpenCL kernel (.cl) to RiscV assembly : "LLVM ERROR: Unsupported 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>
          Alexix24
      </td>
    </tr>
</table>

<pre>
    Hi,

I'm trying to build an OpenCL kernel (.cl) for a RiscV target using clang/llvm, but I'm facing a core dumped error when using llc. 

- My OpenCL kernel (addVectors.cl):
```
__kernel void addVectors(__global const float *a, __global const float *b, __global float *c) {
    int gid = get_global_id(0);
    c[gid] = a[gid] + b[gid];
}
```

- .cl to .ll with clang (seems to work fine):
```
clang -c -emit-llvm -target riscv64 -o addVectors.ll addVectors.cl
```

- .ll to .s (riscv assembly) using llc (doesn't work):
```
llc addVectors.ll -o addVectors.s
```

**LLVM error:**
```
LLVM ERROR: Unsupported calling convention
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: llc addVectors.ll -o addVectors.s
1.      Running pass 'Function Pass Manager' on module 'addVectors.ll'.
2.      Running pass 'RISCV DAG->DAG Pattern Instruction Selection' on function '@addVectors'
 #0 0x00007fe529c3fd01 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3fd01)
 #1 0x00007fe529c3da3e llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3da3e)
 #2 0x00007fe529c40236 (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe40236)
 #3 0x00007fe528642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007fe5286969fc __pthread_kill_implementation ./nptl/./nptl/pthread_kill.c:44:76
 #5 0x00007fe5286969fc __pthread_kill_internal ./nptl/./nptl/pthread_kill.c:78:10
 #6 0x00007fe5286969fc pthread_kill ./nptl/./nptl/pthread_kill.c:89:10
 #7 0x00007fe528642476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007fe5286287f3 abort ./stdlib/./stdlib/abort.c:81:7
 #9 0x00007fe529b7a723 (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xd7a723)
#10 0x00007fe529b7a556 (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xd7a556)
#11 0x00007fe52c1bee62 (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x33bee62)
#12 0x00007fe52a40475d llvm::SelectionDAGISel::LowerArguments(llvm::Function const&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x160475d)
#13 0x00007fe52a456516 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x1656516)
#14 0x00007fe52a455557 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x1655557)
#15 0x00007fe529fc628e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x11c628e)
#16 0x00007fe529d7a390 llvm::FPPassManager::runOnFunction(llvm::Function&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xf7a390)
#17 0x00007fe529d81983 llvm::FPPassManager::runOnModule(llvm::Module&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xf81983)
#18 0x00007fe529d7af36 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xf7af36)
#19 0x0000000000410223 main (/usr/lib/llvm-14/bin/llc+0x410223)
#20 0x00007fe528629d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#21 0x00007fe528629e40 call_init ./csu/../csu/libc-start.c:128:20
#22 0x00007fe528629e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#23 0x000000000040b065 _start (/usr/lib/llvm-14/bin/llc+0x40b065)
Aborted (core dumped)
```

Thanks !
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0mN9v46gWx_8a8nKUyAb_fMiDO5nMVmo1Vbt3Xi2MicMtwRHgafvfX4HTxGSy3W7uziia2sD5ng8HOICpMaJTnC9ReoPS1YwOdtvrZSX5q3jFyazp27flHwLhLyhaoaga_79FON-B1W9CdWB7aAYhW6AKvu-5-nIHz1wrLgHhYsEkwiVseg0UHoVhP8BS3XELg3HGTFLVIbyW8ucO4S_QDBZG9Q1lrgEF1msO7bDb8xa41r2Gly1XB3sp2QKmaHO4f_sVg7btD85sr80IhMihOcqiw8-_1vXB5mcvWjhZIVzUdSf7hkpgvTIWNrKnFhCuqMP-q8omqDwWMxcTlN-MTgEAhLLQiRYQWUHH7cGiFi3CReSBJ40ZSm860aJ05dvTySu-geb4ejRC-epid99DtmDSDeNCSngRdjuOioub4XxnXNVLr59hIxT_IHij1ZzBnO-EnbshhflhtLUw7GeWwLyfRNX5C0fmQ0g5QhoH5vWAGsN3jXxz4TzOB1fd9twohHPrwT9gdu1DoJDQfICEsPvd3f24H-el8-GLLtr4dl8fH78_IlLBf5QZ9vteW94Co1L6tdCrn1xZ0avR4uHua_X0FczQ7IQFCs3QgebOyMVha-3eeJdrhNedsNuhWbB-d1xM_s98r_v_cmYRXgtjBm4QXgNVLQjF5NBysFsOTFOzhYayZ6sp44vR_ZOl7NkvvGPwogWKygfdd5rugOpu2HFlHQR8Mo6xE3gclHL93VPjxjJfD4q5XsODK7ininZcI5xDr2DXt4PkrlWgjnB-oMSXFB9vn778gFX1bY7I11X1DR6otVwruFXG6mH09sQl908HV5t3DIRzlETTxZ8f1h7CJILoNYqiKN_wFJeMbNooBh9wUiFSmTczPjxooawP4Z8upggXp0aavtS9sZrTHcKZSxFCWZ8ScOHGTTQIr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