<div dir="ltr">It looks like LLVM correctly expanded your operation into a call to a runtime library function. The bug seems to be that your backend is not lowering the `call` instruction, causing compilation to fail.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 29, 2016 at 10:15 AM, Alex Susu via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Hello.<br>
Could you please tell me how can I make my new back end (inspired from BPF LLVM back end) select runtime libc calls like memset, etc from LLVM IR intrinsics.<br>
More exactly, I'm getting the following error:<br>
LLVM ERROR: Cannot select: t18: ch,glue = ConnexISD::CALL t16, TargetExternalSymbol:i64'memse<wbr>t', Register:i64 %R1, Register:i64 %R2, Register:i64 %R3, t16:1<br>
This happens after I:<br>
- edited method ConnexTargetLowering::ConnexTa<wbr>rgetLowering() from file lib/Target/Connex/ConnexISelLo<wbr>wering.cpp and registered the RTLIB calls like this:<br>
// Inspired from lib/Target/ARM/ARMISelLowering<wbr>.cpp, constructor ARMTargetLowering()<br>
static const struct {<br>
const RTLIB::Libcall Op;<br>
const char *const Name;<br>
const CallingConv::ID CC;<br>
const ISD::CondCode Cond;<br>
} MemOpsLibraryCalls[] = {<br>
// Memory operations<br>
{ RTLIB::MEMMOVE, "memmove", CallingConv::C, ISD::SETCC_INVALID },<br>
{ RTLIB::MEMSET, "memset", CallingConv::C, ISD::SETCC_INVALID },<br>
};<br>
<br>
for (const auto &LC : MemOpsLibraryCalls) {<br>
setLibcallName(LC.Op, LC.Name);<br>
setLibcallCallingConv(LC.Op, LC.CC);<br>
if (LC.Cond != ISD::SETCC_INVALID)<br>
setCmpLibcallCC(LC.Op, LC.Cond);<br>
}<br>
<br>
- added files<br>
lib/Target/Connex/ConnexSelect<wbr>ionDAGInfo.cpp, .h inspiring from lib/Target/ARM/ARMSelectionDAG<wbr>Info.* - I can provide, if required, excerpts from these source files.<br>
<br>
<br>
Note that I had some success to make opt avoid generating these calls in LLVM IR, which obviously avoids instruction selection also, by following advice from:<br>
- <a href="http://lists.llvm.org/pipermail/llvm-dev/2012-May/050122.html" rel="noreferrer" target="_blank">http://lists.llvm.org/pipermai<wbr>l/llvm-dev/2012-May/050122.<wbr>html</a> : "How do I disable that feature? I've tried -fno-builtin and/or -ffreestanding with no success. clang (as well as gcc) requires that freestanding environment provides memcpy, memmove, memset and memcmp."<br>
- (<a href="http://stackoverflow.com/questions/27511899/llvm-intrinsic-functions" rel="noreferrer" target="_blank">http://stackoverflow.com/ques<wbr>tions/27511899/llvm-intrinsic-<wbr>functions</a>: "So to prevent (at least the memset) intrinsics in your code don't run instcombine on your IR. However, instcombine is a mighty opt pass that realy shortens the code.")<br>
<br>
<br>
Thank you,<br>
Alex<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div>