On 04/20/2013 02:04 PM, Reed Kotler wrote:> On 04/20/2013 01:30 PM, reed kotler wrote: >> Can I create a "naked" function that has only inline assembler and no >> return IR for example? >> >> If I create just a function will an empty basic block, it's core dumps. >> >> I'm debugging it now. > > Seems that you have to have at least a return instruction. > > Is that a bug? > > Why can't I do the return myself if it's all inline assembly code.It's not hard for me to suppress the return in "naked" functions.
Hello Reed, Basic blocks need to end with a terminator instruction. There is an "unreachable" terminator instruction, whose documentation says: "the presence of this instruction indicates some higher level knowledge that the end of the block cannot be reached." (see include/llvm/IR/Instructions.h). I've been able to suppress the return using this. I'm not completely clear if this would be the right use for your scenario. Pete On Sat, Apr 20, 2013 at 2:16 PM, Reed Kotler <rkotler at mips.com> wrote:> On 04/20/2013 02:04 PM, Reed Kotler wrote: > >> On 04/20/2013 01:30 PM, reed kotler wrote: >> >>> Can I create a "naked" function that has only inline assembler and no >>> return IR for example? >>> >>> If I create just a function will an empty basic block, it's core dumps. >>> >>> I'm debugging it now. >>> >> >> Seems that you have to have at least a return instruction. >> >> Is that a bug? >> >> Why can't I do the return myself if it's all inline assembly code. >> > > It's not hard for me to suppress the return in "naked" functions. > > > > > ______________________________**_________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/**mailman/listinfo/llvmdev<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130422/4f7a8965/attachment.html>
On Mon, Apr 22, 2013 at 8:09 AM, Pete Couperus <pjcoup at gmail.com> wrote:> Hello Reed, > > Basic blocks need to end with a terminator instruction. > There is an "unreachable" terminator instruction, whose documentation says: > "the presence of this instruction indicates some higher level knowledge > that the end of the block cannot be reached." > (see include/llvm/IR/Instructions.h). > I've been able to suppress the return using this. I'm not completely > clear if this would be the right use for your scenario. >This is the right thing to do. If your inline assembly always transfers code out of the block, then the end of the block is indeed unreachable. You do need to ensure that the asm expression has the "sideeffect" attribute so that it doesn't get optimized away. -Joe -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130422/3284c136/attachment.html>