diff options
| author | Matthias Braun <matze@braunis.de> | 2015-08-18 18:54:27 +0000 |
|---|---|---|
| committer | Matthias Braun <matze@braunis.de> | 2015-08-18 18:54:27 +0000 |
| commit | d55bcf2646dc43a7108a375e2fd83de03476f34f (patch) | |
| tree | 38c5623a3122665a6e6878c8931b8cd23b0f8d7e /llvm/lib/CodeGen | |
| parent | 2f02ea462c6346ff301084cd17b27b2c7c750786 (diff) | |
| download | bcm5719-llvm-d55bcf2646dc43a7108a375e2fd83de03476f34f.tar.gz bcm5719-llvm-d55bcf2646dc43a7108a375e2fd83de03476f34f.zip | |
MachineRegisterInfo: Introduce isPhysRegUsed()
This method checks whether a physical regiser or any of its aliases are
used in the function.
Using this function in SIRegisterInfo::findUnusedReg() should also fix
this reported failure:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150803/292143.html
http://reviews.llvm.org/rL242173#inline-533
The report doesn't come with a testcase and I don't know enough about
AMDGPU to create one myself.
llvm-svn: 245329
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/ExecutionDepsFix.cpp | 13 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/MachineRegisterInfo.cpp | 12 |
2 files changed, 18 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/ExecutionDepsFix.cpp b/llvm/lib/CodeGen/ExecutionDepsFix.cpp index cbc3b80a6a5..c77f0f0c47c 100644 --- a/llvm/lib/CodeGen/ExecutionDepsFix.cpp +++ b/llvm/lib/CodeGen/ExecutionDepsFix.cpp @@ -733,13 +733,12 @@ bool ExeDepsFix::runOnMachineFunction(MachineFunction &mf) { // completely. bool anyregs = false; const MachineRegisterInfo &MRI = mf.getRegInfo(); - for (TargetRegisterClass::const_iterator I = RC->begin(), E = RC->end(); - I != E && !anyregs; ++I) - for (MCRegAliasIterator AI(*I, TRI, true); AI.isValid(); ++AI) - if (!MRI.reg_nodbg_empty(*AI)) { - anyregs = true; - break; - } + for (unsigned Reg : *RC) { + if (MRI.isPhysRegUsed(Reg)) { + anyregs = true; + break; + } + } if (!anyregs) return false; // Initialize the AliasMap on the first use. diff --git a/llvm/lib/CodeGen/MachineRegisterInfo.cpp b/llvm/lib/CodeGen/MachineRegisterInfo.cpp index d3704efb631..574eefe67dd 100644 --- a/llvm/lib/CodeGen/MachineRegisterInfo.cpp +++ b/llvm/lib/CodeGen/MachineRegisterInfo.cpp @@ -489,3 +489,15 @@ bool MachineRegisterInfo::isPhysRegModified(unsigned PhysReg) const { } return false; } + +bool MachineRegisterInfo::isPhysRegUsed(unsigned PhysReg) const { + if (UsedPhysRegMask.test(PhysReg)) + return true; + const TargetRegisterInfo *TRI = getTargetRegisterInfo(); + for (MCRegAliasIterator AliasReg(PhysReg, TRI, true); AliasReg.isValid(); + ++AliasReg) { + if (!reg_nodbg_empty(*AliasReg)) + return true; + } + return false; +} |

