[PATCH] D62543: [MIR-Canon] Add support for rewriting VRegs that are typed but don't have an RC.
Puyan Lotfi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 18:28:59 PDT 2019
plotfi updated this revision to Diff 202088.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62543/new/
https://reviews.llvm.org/D62543
Files:
llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
llvm/test/CodeGen/MIR/AArch64/addrspace-memoperands.mir
Index: llvm/test/CodeGen/MIR/AArch64/addrspace-memoperands.mir
===================================================================
--- llvm/test/CodeGen/MIR/AArch64/addrspace-memoperands.mir
+++ llvm/test/CodeGen/MIR/AArch64/addrspace-memoperands.mir
@@ -1,4 +1,5 @@
# RUN: llc -mtriple=aarch64-none-linux-gnu -run-pass none -o - %s | FileCheck %s
+# RUN: llc -mtriple=aarch64-none-linux-gnu -run-pass mir-canonicalizer -o - %s
--- |
Index: llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
===================================================================
--- llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
+++ llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
@@ -317,6 +317,13 @@
return Changed;
}
+static bool vregTypesMatch(const MachineRegisterInfo &MRI, unsigned VReg0,
+ unsigned VReg1) {
+ return (MRI.getRegClassOrNull(VReg0) &&
+ (MRI.getRegClassOrNull(VReg0) == MRI.getRegClassOrNull(VReg1))) ||
+ (MRI.getType(VReg0) == MRI.getType(VReg1));
+}
+
static bool propagateLocalCopies(MachineBasicBlock *MBB) {
bool Changed = false;
MachineRegisterInfo &MRI = MBB->getParent()->getRegInfo();
@@ -341,7 +348,7 @@
continue;
if (!TargetRegisterInfo::isVirtualRegister(Src))
continue;
- if (MRI.getRegClass(Dst) != MRI.getRegClass(Src))
+ if (!vregTypesMatch(MRI, Dst, Src))
continue;
for (auto UI = MRI.use_begin(Dst); UI != MRI.use_end(); ++UI) {
@@ -500,14 +507,15 @@
return virtualVRegNumber;
}
- unsigned createVirtualRegister(const TargetRegisterClass *RC) {
+ unsigned createVirtualRegister(MachineRegisterInfo &MRI, unsigned VReg) {
std::string S;
raw_string_ostream OS(S);
OS << "namedVReg" << (virtualVRegNumber & ~0x80000000);
OS.flush();
virtualVRegNumber++;
-
- return MRI.createVirtualRegister(RC, OS.str());
+ if (auto RC = MRI.getRegClassOrNull(VReg))
+ return MRI.createVirtualRegister(RC, OS.str());
+ return MRI.createGenericVirtualRegister(MRI.getType(VReg), OS.str());
}
};
} // namespace
@@ -557,7 +565,7 @@
continue;
}
- auto Rename = NVC.createVirtualRegister(MRI.getRegClass(Reg));
+ auto Rename = NVC.createVirtualRegister(MRI, Reg);
if (VRegRenameMap.find(Reg) == VRegRenameMap.end()) {
LLVM_DEBUG(dbgs() << "Mapping vreg ";);
@@ -741,7 +749,7 @@
MachineInstr &MI = *MII++;
Changed = true;
unsigned vRegToRename = MI.getOperand(0).getReg();
- auto Rename = NVC.createVirtualRegister(MRI.getRegClass(vRegToRename));
+ auto Rename = NVC.createVirtualRegister(MRI, vRegToRename);
std::vector<MachineOperand *> RenameMOs;
for (auto &MO : MRI.reg_operands(vRegToRename)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62543.202088.patch
Type: text/x-patch
Size: 2704 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190530/95757063/attachment.bin>
More information about the llvm-commits
mailing list