llvm.org GIT mirror llvm / 668e541
Handle a COPY with undef source operand in LowerCopy() 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. Review: Matthias Braun https://reviews.llvm.org/D32892 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302877 91177308-0d34-0410-b5e6-96231b3b80d8 Jonas Paulsson 3 years ago
2 changed file(s) with 17 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
141141 MachineOperand &DstMO = MI->getOperand(0);
142142 MachineOperand &SrcMO = MI->getOperand(1);
143143
144 if (SrcMO.getReg() == DstMO.getReg()) {
145 DEBUG(dbgs() << "identity copy: " << *MI);
144 bool IdentityCopy = (SrcMO.getReg() == DstMO.getReg());
145 if (IdentityCopy || SrcMO.isUndef()) {
146 DEBUG(dbgs() << (IdentityCopy ? "identity copy: " : "undef copy: ") << *MI);
146147 // No need to insert an identity copy instruction, but replace with a KILL
147148 // if liveness is changed.
148149 if (SrcMO.isUndef() || MI->getNumOperands() > 2) {
0 # RUN: llc -mtriple=s390x-linux-gnu -mcpu=z13 -run-pass=postrapseudos -o - %s | FileCheck %s
1 #
2 # Test that a COPY with an undef source operand gets handled like an identity
3 # copy rather than lowered into a target instruction with the undef flag
4 # dropped.
5 ---
6 # CHECK-LABEL: name: undef_copy
7 # CHECK: %r13d = KILL undef %r0d, implicit killed %r12q, implicit-def %r12q
8 name: undef_copy
9 tracksRegLiveness: true
10 body: |
11 bb.0:
12 liveins: %r12q
13 %r13d = COPY undef %r0d, implicit killed %r12q, implicit-def %r12q