diff options
author | Chris Ye <yechunliang@gmail.com> | 2020-01-16 11:40:44 +0000 |
---|---|---|
committer | Jeremy Morse <jeremy.morse@sony.com> | 2020-01-16 11:58:09 +0000 |
commit | 75188b01e9af3a89639d84be912f84610d6885ba (patch) | |
tree | b8d60839ddcde7e38693e0e90f4af3726d4cdfd8 /llvm/lib/CodeGen/MachineVerifier.cpp | |
parent | 8a3446746098ba29348bb8f85357dd0b466a6d6e (diff) | |
download | llvm-75188b01e9af3a89639d84be912f84610d6885ba.zip llvm-75188b01e9af3a89639d84be912f84610d6885ba.tar.gz llvm-75188b01e9af3a89639d84be912f84610d6885ba.tar.bz2 |
[PHIEliminate] Move dbg values after phi and label
If there are DBG_VALUEs between phi and label (after phi and before label),
DBG_VALUE will block PHI lowering after the LABEL. Moving all DBG_VALUEs
after Labels in the function ScheduleDAGSDNodes::EmitSchedule to avoid
impacting PHI lowering.
before:
PHI
DBG_VALUE
LABEL
after: (move DBG_VALUE after label)
PHI
LABEL
DBG_VALUE
then: (phi lowering after label)
LABEL
COPY
DBG_VALUE
Fixes the issue: https://bugs.llvm.org/show_bug.cgi?id=43859
Differential Revision: https://reviews.llvm.org/D70597
Diffstat (limited to 'llvm/lib/CodeGen/MachineVerifier.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineVerifier.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp index 6c0402d..24fb330 100644 --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -273,6 +273,7 @@ namespace { void markReachable(const MachineBasicBlock *MBB); void calcRegsPassed(); void checkPHIOps(const MachineBasicBlock &MBB); + void checkPHIDbg(const MachineBasicBlock &MBB); void calcRegsRequired(); void verifyLiveVariables(); @@ -2262,11 +2263,31 @@ void MachineVerifier::checkPHIOps(const MachineBasicBlock &MBB) { } } +// Check there must be no DBG_VALUEs between PHIs and LABELs, so that +// the PHIs could lower after LABELs successfully without dbg barriers. +void MachineVerifier::checkPHIDbg(const MachineBasicBlock &MBB) { + + // Quick exit for basic blocks without PHIs. + if (MBB.empty() || !MBB.front().isPHI()) + return; + + MachineBasicBlock &MBB2 = const_cast<MachineBasicBlock &>(MBB); + MachineBasicBlock::iterator LastPHIIt = + std::prev(MBB2.SkipPHIsAndLabels(MBB2.begin())); + // Backward to skip debug if the lastPHIIt is DBG_VALUE, the LastPHIIt + // should be the same if no DBG_VALUEs between PHIs and LABELs. + if (LastPHIIt != skipDebugInstructionsBackward( + std::prev(MBB2.SkipPHIsLabelsAndDebug(MBB2.begin())), MBB2.begin())) + report("Unexpected DBG_VALUEs between PHI and LABEL", &MBB2); +} + void MachineVerifier::visitMachineFunctionAfter() { calcRegsPassed(); - for (const MachineBasicBlock &MBB : *MF) + for (const MachineBasicBlock &MBB : *MF) { checkPHIOps(MBB); + checkPHIDbg(MBB); + } // Now check liveness info if available calcRegsRequired(); |