Alex Susu via llvm-dev
2016-Sep-28 21:15 UTC
[llvm-dev] Supporting RTLIB calls (memset, memcpy, etc)
Hello. 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. More exactly, I'm getting the following error: LLVM ERROR: Cannot select: t18: ch,glue = ConnexISD::CALL t16, TargetExternalSymbol:i64'memset', Register:i64 %R1, Register:i64 %R2, Register:i64 %R3, t16:1 This happens after I: - edited method ConnexTargetLowering::ConnexTargetLowering() from file lib/Target/Connex/ConnexISelLowering.cpp and registered the RTLIB calls like this: // Inspired from lib/Target/ARM/ARMISelLowering.cpp, constructor ARMTargetLowering() static const struct { const RTLIB::Libcall Op; const char *const Name; const CallingConv::ID CC; const ISD::CondCode Cond; } MemOpsLibraryCalls[] = { // Memory operations { RTLIB::MEMMOVE, "memmove", CallingConv::C, ISD::SETCC_INVALID }, { RTLIB::MEMSET, "memset", CallingConv::C, ISD::SETCC_INVALID }, }; for (const auto &LC : MemOpsLibraryCalls) { setLibcallName(LC.Op, LC.Name); setLibcallCallingConv(LC.Op, LC.CC); if (LC.Cond != ISD::SETCC_INVALID) setCmpLibcallCC(LC.Op, LC.Cond); } - added files lib/Target/Connex/ConnexSelectionDAGInfo.cpp, .h inspiring from lib/Target/ARM/ARMSelectionDAGInfo.* - I can provide, if required, excerpts from these source files. 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: - http://lists.llvm.org/pipermail/llvm-dev/2012-May/050122.html : "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." - (http://stackoverflow.com/questions/27511899/llvm-intrinsic-functions: "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.") Thank you, Alex
Dylan McKay via llvm-dev
2016-Sep-29 06:26 UTC
[llvm-dev] Supporting RTLIB calls (memset, memcpy, etc)
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. On Thu, Sep 29, 2016 at 10:15 AM, Alex Susu via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hello. > 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. > More exactly, I'm getting the following error: > LLVM ERROR: Cannot select: t18: ch,glue = ConnexISD::CALL t16, > TargetExternalSymbol:i64'memset', Register:i64 %R1, Register:i64 %R2, > Register:i64 %R3, t16:1 > This happens after I: > - edited method ConnexTargetLowering::ConnexTargetLowering() from > file lib/Target/Connex/ConnexISelLowering.cpp and registered the RTLIB > calls like this: > // Inspired from lib/Target/ARM/ARMISelLowering.cpp, constructor > ARMTargetLowering() > static const struct { > const RTLIB::Libcall Op; > const char *const Name; > const CallingConv::ID CC; > const ISD::CondCode Cond; > } MemOpsLibraryCalls[] = { > // Memory operations > { RTLIB::MEMMOVE, "memmove", CallingConv::C, ISD::SETCC_INVALID }, > { RTLIB::MEMSET, "memset", CallingConv::C, ISD::SETCC_INVALID }, > }; > > for (const auto &LC : MemOpsLibraryCalls) { > setLibcallName(LC.Op, LC.Name); > setLibcallCallingConv(LC.Op, LC.CC); > if (LC.Cond != ISD::SETCC_INVALID) > setCmpLibcallCC(LC.Op, LC.Cond); > } > > - added files > lib/Target/Connex/ConnexSelectionDAGInfo.cpp, .h inspiring > from lib/Target/ARM/ARMSelectionDAGInfo.* - I can provide, if required, > excerpts from these source files. > > > 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: > - http://lists.llvm.org/pipermail/llvm-dev/2012-May/050122.html : > "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." > - (http://stackoverflow.com/questions/27511899/llvm-intrinsic- > functions: "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.") > > > Thank you, > Alex > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160929/bad340ed/attachment.html>