From 4314268128be6d54c9a7f0709680e5a5b40f3ab3 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Sun, 9 Jan 2011 03:05:53 +0000 Subject: Replace TargetRegisterInfo::printReg with a PrintReg class that also works without a TRI instance. Print virtual registers numbered from 0 instead of the arbitrary FirstVirtualRegister. The first virtual register is printed as %vreg0. TRI::NoRegister is printed as %noreg. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123107 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineBasicBlock.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'lib/CodeGen/MachineBasicBlock.cpp') diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index 31d12eb..97aee99 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -166,17 +166,6 @@ void MachineBasicBlock::dump() const { print(dbgs()); } -static inline void OutputReg(raw_ostream &os, unsigned RegNo, - const TargetRegisterInfo *TRI = 0) { - if (RegNo != 0 && TargetRegisterInfo::isPhysicalRegister(RegNo)) { - if (TRI) - os << " %" << TRI->get(RegNo).Name; - else - os << " %physreg" << RegNo; - } else - os << " %reg" << RegNo; -} - StringRef MachineBasicBlock::getName() const { if (const BasicBlock *LBB = getBasicBlock()) return LBB->getName(); @@ -214,7 +203,7 @@ void MachineBasicBlock::print(raw_ostream &OS, SlotIndexes *Indexes) const { if (Indexes) OS << '\t'; OS << " Live Ins:"; for (livein_iterator I = livein_begin(),E = livein_end(); I != E; ++I) - OutputReg(OS, *I, TRI); + OS << PrintReg(*I, TRI); OS << '\n'; } // Print the preds of this block according to the CFG. -- cgit v1.1 From 668c9e31df3e7c216c57559c69667273f7b0404d Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Thu, 13 Jan 2011 00:57:35 +0000 Subject: Add missing space in debug output git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123351 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineBasicBlock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/CodeGen/MachineBasicBlock.cpp') diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index 97aee99..813fad2 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -203,7 +203,7 @@ void MachineBasicBlock::print(raw_ostream &OS, SlotIndexes *Indexes) const { if (Indexes) OS << '\t'; OS << " Live Ins:"; for (livein_iterator I = livein_begin(),E = livein_end(); I != E; ++I) - OS << PrintReg(*I, TRI); + OS << ' ' << PrintReg(*I, TRI); OS << '\n'; } // Print the preds of this block according to the CFG. -- cgit v1.1 From 64f865ceca4cdd39fcac3d958071be118cb9c1d3 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Thu, 13 Jan 2011 18:41:05 +0000 Subject: Teach MachineBasicBlock::getFirstTerminator to ignore debug values. It will still return an iterator that points to the first terminator or end(), but there may be DBG_VALUE instructions following the first terminator. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123384 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineBasicBlock.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'lib/CodeGen/MachineBasicBlock.cpp') diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index 813fad2..b590444 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -155,11 +155,22 @@ MachineBasicBlock::SkipPHIsAndLabels(MachineBasicBlock::iterator I) { } MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() { - iterator I = end(); - while (I != begin() && (--I)->getDesc().isTerminator()) - ; /*noop */ - if (I != end() && !I->getDesc().isTerminator()) ++I; - return I; + iterator B = begin(), I = end(); + iterator Term = I; + while (I != B) { + --I; + // Ignore any debug values after the first terminator. + if (I->isDebugValue()) + continue; + // Stop once we see a non-debug non-terminator. + if (!I->getDesc().isTerminator()) + break; + // Earliest terminator so far. + Term = I; + } + // Return the first terminator, or end(). + // Everything after Term is terminators and debug values. + return Term; } void MachineBasicBlock::dump() const { -- cgit v1.1 From a851fd8cd8e5c256651b3afeb8ebd539c28dfda7 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Thu, 13 Jan 2011 19:27:50 +0000 Subject: Speculatively revert r123384 to make llvm-gcc-i386-linux-selfhost buildbot happy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123389 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineBasicBlock.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'lib/CodeGen/MachineBasicBlock.cpp') diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index b590444..813fad2 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -155,22 +155,11 @@ MachineBasicBlock::SkipPHIsAndLabels(MachineBasicBlock::iterator I) { } MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() { - iterator B = begin(), I = end(); - iterator Term = I; - while (I != B) { - --I; - // Ignore any debug values after the first terminator. - if (I->isDebugValue()) - continue; - // Stop once we see a non-debug non-terminator. - if (!I->getDesc().isTerminator()) - break; - // Earliest terminator so far. - Term = I; - } - // Return the first terminator, or end(). - // Everything after Term is terminators and debug values. - return Term; + iterator I = end(); + while (I != begin() && (--I)->getDesc().isTerminator()) + ; /*noop */ + if (I != end() && !I->getDesc().isTerminator()) ++I; + return I; } void MachineBasicBlock::dump() const { -- cgit v1.1 From 4f28c1c71450c711e96aa283de53739d8b4504cd Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Thu, 13 Jan 2011 21:28:52 +0000 Subject: Teach frame lowering to ignore debug values after the terminators. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123399 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineBasicBlock.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/CodeGen/MachineBasicBlock.cpp') diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index 813fad2..ad1ab28 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -162,6 +162,18 @@ MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() { return I; } +MachineBasicBlock::iterator MachineBasicBlock::getLastNonDebugInstr() { + iterator B = begin(), I = end(); + while (I != B) { + --I; + if (I->isDebugValue()) + continue; + return I; + } + // The block is all debug values. + return end(); +} + void MachineBasicBlock::dump() const { print(dbgs()); } -- cgit v1.1 From 09befe90360effa077b1934c0e85e5b7abe00a9c Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 14 Jan 2011 01:17:53 +0000 Subject: Try again to teach getFirstTerminator() about debug values. Fix some callers to better deal with debug values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123419 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineBasicBlock.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'lib/CodeGen/MachineBasicBlock.cpp') diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index ad1ab28..3696387 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -155,11 +155,22 @@ MachineBasicBlock::SkipPHIsAndLabels(MachineBasicBlock::iterator I) { } MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() { - iterator I = end(); - while (I != begin() && (--I)->getDesc().isTerminator()) - ; /*noop */ - if (I != end() && !I->getDesc().isTerminator()) ++I; - return I; + iterator B = begin(), I = end(); + iterator Term = I; + while (I != B) { + --I; + // Ignore any debug values after the first terminator. + if (I->isDebugValue()) + continue; + // Stop once we see a non-debug non-terminator. + if (!I->getDesc().isTerminator()) + break; + // Earliest terminator so far. + Term = I; + } + // Return the first terminator, or end(). + // Everything after Term is terminators and debug values. + return Term; } MachineBasicBlock::iterator MachineBasicBlock::getLastNonDebugInstr() { -- cgit v1.1 From b6436e5be19937b622fabd87d1547b8fc7553c11 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 14 Jan 2011 02:12:54 +0000 Subject: Revert r123419. It still breaks llvm-gcc-i386-linux-selfhost. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123423 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineBasicBlock.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'lib/CodeGen/MachineBasicBlock.cpp') diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index 3696387..ad1ab28 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -155,22 +155,11 @@ MachineBasicBlock::SkipPHIsAndLabels(MachineBasicBlock::iterator I) { } MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() { - iterator B = begin(), I = end(); - iterator Term = I; - while (I != B) { - --I; - // Ignore any debug values after the first terminator. - if (I->isDebugValue()) - continue; - // Stop once we see a non-debug non-terminator. - if (!I->getDesc().isTerminator()) - break; - // Earliest terminator so far. - Term = I; - } - // Return the first terminator, or end(). - // Everything after Term is terminators and debug values. - return Term; + iterator I = end(); + while (I != begin() && (--I)->getDesc().isTerminator()) + ; /*noop */ + if (I != end() && !I->getDesc().isTerminator()) ++I; + return I; } MachineBasicBlock::iterator MachineBasicBlock::getLastNonDebugInstr() { -- cgit v1.1 From 04223909b74fd0634ba26d434fa7fdf2f3c7444f Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 14 Jan 2011 06:33:45 +0000 Subject: Try for the third time to teach getFirstTerminator() about debug values. This time let's rephrase to trick gcc-4.3 into not miscompiling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123432 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineBasicBlock.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/CodeGen/MachineBasicBlock.cpp') diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index ad1ab28..95b8f86 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -156,9 +156,10 @@ MachineBasicBlock::SkipPHIsAndLabels(MachineBasicBlock::iterator I) { MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() { iterator I = end(); - while (I != begin() && (--I)->getDesc().isTerminator()) + while (I != begin() && ((--I)->getDesc().isTerminator() || I->isDebugValue())) ; /*noop */ - if (I != end() && !I->getDesc().isTerminator()) ++I; + while (I != end() && !I->getDesc().isTerminator()) + ++I; return I; } -- cgit v1.1 From cb6404711b7fe6f583480adce8d7e9d5e4b99ae6 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 4 Feb 2011 19:33:11 +0000 Subject: Add LiveIntervals::getLastSplitPoint(). A live range cannot be split everywhere in a basic block. A split must go before the first terminator, and if the variable is live into a landing pad, the split must happen before the call that can throw. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124894 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineBasicBlock.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/CodeGen/MachineBasicBlock.cpp') diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index 95b8f86..ccbff0a 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -175,6 +175,16 @@ MachineBasicBlock::iterator MachineBasicBlock::getLastNonDebugInstr() { return end(); } +const MachineBasicBlock *MachineBasicBlock::getLandingPadSuccessor() const { + // A block with a landing pad successor only has one other successor. + if (succ_size() > 2) + return 0; + for (const_succ_iterator I = succ_begin(), E = succ_end(); I != E; ++I) + if ((*I)->isLandingPad()) + return *I; + return 0; +} + void MachineBasicBlock::dump() const { print(dbgs()); } -- cgit v1.1