This is an archive of the discontinued LLVM Phabricator instance.

Fix use-after-kill in TailDuplication
Needs ReviewPublic

Authored by loladiro on Nov 13 2014, 10:10 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

If a register that was the result of a PHI instruction is killed in
the same basic block, TailDuplication sill tries to insert a COPY
at the end of the new basic block, causing a verifier failure like so (i.e. when run with llc -fast-isel -O3 -verify-machineinstrs):

*** Bad machine code: Using a killed virtual register ***
- function:    julia_anonymous1421
- basic block: BB#4 isf (0x17d84d0)
- instruction: %vreg12<def> = COPY %vreg7; GR64:%vreg12,%vreg7
- operand 1:   %vreg7

*** Bad machine code: Using a killed virtual register ***
- function:    julia_anonymous1421
- basic block: BB#6 notf (0x17d8630)
- instruction: %vreg14<def> = COPY %vreg6; GR64:%vreg14,%vreg6
- operand 1:   %vreg6
LLVM ERROR: Found 2 machine code errors.

Diff Detail

Event Timeline

loladiro updated this revision to Diff 16198.Nov 13 2014, 10:10 PM
loladiro retitled this revision from to Fix use-after-kill in TailDuplication.
loladiro updated this object.
loladiro edited the test plan for this revision. (Show Details)
loladiro set the repository for this revision to rL LLVM.
loladiro added a subscriber: Unknown Object (MLST).
loladiro added a subscriber: pete.Jun 1 2015, 10:49 AM

Looks like this was fixed in rL236782. @pete, I don't really know this code, do you think this still has any applicability or is this done?

pete added a comment.Jun 1 2015, 10:55 AM

I think you're right that my patch fixed it, but yours is useful too.

I haven't looked too closely, but if you really are able to avoid adding entries to the Copies vector, then you are potentially reducing the work this pass does and speeding it up. You might even avoid creating useless copy instructions that DCE would later remove. So i'd try land this change too if you can.

Cheers,
Pete