This is an archive of the discontinued LLVM Phabricator instance.

Handle a COPY with undef source operand in LowerCopy().
ClosedPublic

Authored by jonpa on May 5 2017, 12:00 AM.

Details

Reviewers
MatzeB
Summary

Llvm-stress discovered that a COPY may end up in ExpandPostRA::LowerCopy() with an undef source operand. It is not possible for the target to handle this, as this flag is not passed to TII->copyPhysReg().

This patch solves this by treating such a COPY as an identity COPY, as Matthias suggested on llvm-dev.

Reduces llvm-stress test case is also included.

Diff Detail

Event Timeline

jonpa created this revision.May 5 2017, 12:00 AM
jonpa added a comment.May 8 2017, 11:35 PM

ping!

Matthias, this is per you suggestion - what do you think?

MatzeB edited edge metadata.May 9 2017, 9:31 AM

ping!

This is barely one workday old (in my timezone).

Matthias, this is per you suggestion - what do you think?

The code changes look good to me, but this would better be tested with a .mir test.

jonpa updated this revision to Diff 98413.May 10 2017, 1:22 AM

This is barely one workday old (in my timezone).

Sorry - got carried away since I was working a little over the weekend :-)

The code changes look good to me, but this would better be tested with a .mir test.

Thanks. I changed the test.

Btw, I wonder what the best way to test that the machine-verifier passes? Currently I just do a CHECK for some expected string. Is this what "not llc" might be used for?

I was thinking more about a minimal test that just focused on that one transformation that postrapseudos should do. Whether you also run the verifier or not shouldn't matter at that point. Should look something like this (I haven't actually tested this though, so you may need some tweaks):

# RUN: llc -mtriple=s390x-linux-gnu -mcpu=z13 -verify-machineinstrs -run-pass=postrapseudos -o - %s | FileCheck %s
---
# CHECK-LABEL: name: undef_copy
# CHECK: %r13d = KILL undef %r0d, implicit killed %r12q, implicit-def %r12q
name: undef_copy
tracksRegLiveness: true
body: |
  bb.0:
    liveins: %r12q
    %r13d = COPY undef %r0d, implicit killed %r12q, implicit-def %r12q
jonpa updated this revision to Diff 98587.May 11 2017, 12:06 AM

Ah, I see.

Your test seemed to work fine (without the machine verifier) :-)

MatzeB accepted this revision.May 11 2017, 10:26 AM

LGTM

This revision is now accepted and ready to land.May 11 2017, 10:26 AM
jonpa closed this revision.May 11 2017, 11:49 PM

r302877