[PATCH] D62717: [MIR-Canon] Skip the first N vreg names lazily.
Puyan Lotfi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 30 22:48:17 PDT 2019
plotfi updated this revision to Diff 202373.
plotfi added a comment.
using initializer list.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62717/new/
https://reviews.llvm.org/D62717
Files:
llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
llvm/test/CodeGen/MIR/AArch64/multiple-lhs-operands.mir
Index: llvm/test/CodeGen/MIR/AArch64/multiple-lhs-operands.mir
===================================================================
--- llvm/test/CodeGen/MIR/AArch64/multiple-lhs-operands.mir
+++ llvm/test/CodeGen/MIR/AArch64/multiple-lhs-operands.mir
@@ -2,6 +2,9 @@
# This test ensures that the MIR parser can parse multiple register machine
# operands before '='.
+# This tests that a MIR file with no vregs does not get altered by mir-canon.
+# RUN: llc -mtriple=aarch64 -o - -run-pass mir-canonicalizer -verify-machineinstrs %s
+
--- |
declare void @foo()
Index: llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
===================================================================
--- llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
+++ llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
@@ -483,18 +483,14 @@
unsigned virtualVRegNumber;
public:
- NamedVRegCursor(MachineRegisterInfo &MRI) : MRI(MRI) {
- unsigned VRegGapIndex = 0;
- const unsigned VR_GAP = (++VRegGapIndex * 1000);
-
- unsigned I = MRI.createIncompleteVirtualRegister();
- const unsigned E = (((I + VR_GAP) / VR_GAP) + 1) * VR_GAP;
-
- virtualVRegNumber = E;
- }
+ NamedVRegCursor(MachineRegisterInfo &MRI) : MRI(MRI), virtualVRegNumber(0) {}
void SkipVRegs() {
unsigned VRegGapIndex = 1;
+ if (!virtualVRegNumber) {
+ VRegGapIndex = 0;
+ virtualVRegNumber = MRI.createIncompleteVirtualRegister();
+ }
const unsigned VR_GAP = (++VRegGapIndex * 1000);
unsigned I = virtualVRegNumber;
@@ -511,6 +507,8 @@
}
unsigned createVirtualRegister(unsigned VReg) {
+ if (!virtualVRegNumber)
+ SkipVRegs();
std::string S;
raw_string_ostream OS(S);
OS << "namedVReg" << (virtualVRegNumber & ~0x80000000);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62717.202373.patch
Type: text/x-patch
Size: 1743 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190531/1e7ffd4e/attachment.bin>
More information about the llvm-commits
mailing list