[LLVMdev] Marking implicit registers as "trashed"

Tim Northover t.p.northover at gmail.com
Mon Dec 22 09:18:16 PST 2014


> The 'Uses = [...]' and 'Defs = [...]', but I would like something like
> 'Trash = [...]' to say that the register is changed, but the change is
> meaningless.
>
> Does anyone have any suggestions as to how I should approach this kind of
> semantic?

This is expressed by a Def that isn't actually used by anything,
usually expressed <def,dead> in debug printouts. So as long as you
don't try to make use of those flags during ISel you should be fine.

For example, most x86 instructions set flags so when you compile this
with "llc -print-after-all":

define i32 @foo(i32 %l, i32 %r) {
  %res = mul i32 %l, %r
  ret i32 %res
}

You'll see an instruction like this:

    %vreg2<def,tied1> = IMUL32rr %vreg2<tied0>, %vreg1, %EFLAGS<imp-def,dead>

Cheers.

Tim.



More information about the llvm-dev mailing list