[PATCH] Implement getNoopForMachoTarget for SPARC

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Sep 2 08:15:21 PDT 2014


On 2 September 2014 03:18, Joerg Sonnenberger <joerg at britannica.bec.de> wrote:
> On Mon, Sep 01, 2014 at 10:07:46PM -0700, Owen Anderson wrote:
>> Why are you using MachO on a SPARC target?
>
> See mail from me a bit ago -- because MC uses that function to ensure
> that an empty function gets at least one instruction.


Than logic looks broken. Maybe we should fix it instead? For example:

./bin/llc ~/llvm/llvm/test/CodeGen/PowerPC/empty-functions.ll -o
--disable-fp-elim

produces

------------------------------------------
func:                                   # @func
.cfi_startproc
# BB#0:                                 # %entry
pushq %rbp
.Ltmp0:
.cfi_def_cfa_offset 16
.Ltmp1:
.cfi_offset %rbp, -16
movq %rsp, %rbp
.Ltmp2:
.cfi_def_cfa_register %rbp
nop                             # avoids zero-length function
.Ltmp3:

-------------------------------------------------

the function is not empty.

For what it is worth, given

void f(void) {
  __builtin_unreachable();
}

gcc produces

f:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
.cfi_endproc

Cheers,
Rafael



More information about the llvm-commits mailing list