[RDF] Clear the renamable flag when copy propagating reserved registers

llvm-svn: 323831
This commit is contained in:
Krzysztof Parzyszek 2018-01-30 23:19:44 +00:00
parent dbdda6a1e7
commit 119856430e
2 changed files with 25 additions and 2 deletions

View File

@ -18,6 +18,7 @@
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
@ -100,10 +101,11 @@ NodeId CopyPropagation::getLocalReachingDef(RegisterRef RefRR,
bool CopyPropagation::run() {
scanBlock(&DFG.getMF().front());
MachineRegisterInfo &MRI = DFG.getMF().getRegInfo();
if (trace()) {
dbgs() << "Copies:\n";
for (auto I : Copies) {
for (NodeId I : Copies) {
dbgs() << "Instr: " << *DFG.addr<StmtNode*>(I).Addr->getCode();
dbgs() << " eq: {";
for (auto J : CopyMap[I])
@ -130,7 +132,7 @@ bool CopyPropagation::run() {
return 0;
};
for (auto C : Copies) {
for (NodeId C : Copies) {
#ifndef NDEBUG
if (HasLimit && CpCount >= CpLimit)
break;
@ -179,6 +181,8 @@ bool CopyPropagation::run() {
unsigned NewReg = MinPhysReg(SR);
Op.setReg(NewReg);
Op.setSubReg(0);
if (MRI.isReserved(NewReg))
Op.setIsRenamable(false);
DFG.unlinkUse(UA, false);
if (AtCopy != 0) {
UA.Addr->linkToDef(UA.Id, DFG.addr<DefNode*>(AtCopy));

View File

@ -0,0 +1,19 @@
# RUN: llc -march=hexagon -run-pass hexagon-rdf-opt %s -o - | FileCheck %s
# Check that r29 gets propagated into the A2_addi, and that the renamable
# flag is cleared.
# CHECK: renamable %r28 = COPY %r29
# CHECK-NOT: renamable
---
name: fred
tracksRegLiveness: true
body: |
bb.0:
renamable %r28 = COPY %r29
%r0 = A2_addi renamable %r28, 1
J2_jumpr %r31, implicit-def %pc, implicit %r0
...