[LLVMdev] Hit a snag while attempting to write a backend - any advice?

Tim Northover t.p.northover at gmail.com
Thu Mar 21 06:09:12 PDT 2013

Hi Lee,

> let isReturn = 1, isTerminator = 1, isBarrier = 1 in
> {
> def RET : BitscuitInst<(outs),(ins),"JMP\tR6",[(Bitscuit_return)]>;
> def JMP : BitscuitInst<(outs), (ins jmptarget:$dst),"JMP\t$dst",[(br
> bb:$dst)]>;
> }

Ah! It looks like the isReturn is to blame then. LLVM is presumably
going through adding an implicit use of any register that will hold a
return value to instructions that will actually return. This would
prevent it from removing instructions that actually define R0 as dead
code (it's "used" by the RET and should certainly be defined by the
time the function does return).

Since you've marked *any* JMP as a return, they all seem to get the
extra R0, even if the instructions that actually define it hasn't been
executed yet. I'd make isReturn only apply to the RET (and probably
add an "isBranch" to all of them for good measure).


More information about the llvm-dev mailing list