diff options
author | Puyan Lotfi <puyan@puyan.org> | 2019-05-31 06:02:38 +0000 |
---|---|---|
committer | Puyan Lotfi <puyan@puyan.org> | 2019-05-31 06:02:38 +0000 |
commit | 0d63cef180ccc6f5afab824cc784949acb137713 (patch) | |
tree | 444beaa5cd3d5ac30b80792700cd11f90d08cb02 /llvm/lib/CodeGen/MIRCanonicalizerPass.cpp | |
parent | 30935ef0bcdc7703eb2199e3fc5095198497e889 (diff) | |
download | bcm5719-llvm-0d63cef180ccc6f5afab824cc784949acb137713.tar.gz bcm5719-llvm-0d63cef180ccc6f5afab824cc784949acb137713.zip |
[MIR-Canon] Skip the first N vreg names lazily.
This consolidates the vreg skip code into one function (SkipVRegs()).
SkipVRegs() now knows if it should skip as if it is the first initialization or
subsequent skips.
The first skip is also done the first time createVirtualRegister is called by
the cursor instead of by the cursor's constructor. This prevents verifier
errors on machine functions that have no vregs (where the verifier will
complain that there are vregs when the function uses none).
Differential Revision: https://reviews.llvm.org/D62717
llvm-svn: 362195
Diffstat (limited to 'llvm/lib/CodeGen/MIRCanonicalizerPass.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MIRCanonicalizerPass.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp b/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp index d36c0c89ba0..a4097232d7d 100644 --- a/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp +++ b/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp @@ -483,18 +483,14 @@ class NamedVRegCursor { 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 @@ public: } unsigned createVirtualRegister(unsigned VReg) { + if (!virtualVRegNumber) + SkipVRegs(); std::string S; raw_string_ostream OS(S); OS << "namedVReg" << (virtualVRegNumber & ~0x80000000); |