[PATCH] D159552: Testing
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 9 13:02:54 PDT 2023
rnk created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
rnk requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Testing Phab upload
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D159552
Files:
llvm/lib/CodeGen/BranchFolding.cpp
llvm/lib/CodeGen/BranchFolding.h
Index: llvm/lib/CodeGen/BranchFolding.h
===================================================================
--- llvm/lib/CodeGen/BranchFolding.h
+++ llvm/lib/CodeGen/BranchFolding.h
@@ -160,6 +160,8 @@
MachineBasicBlock *SuccBB,
MachineBasicBlock *PredBB);
+ unsigned HashEndOfMBB(const MachineBasicBlock &MBB) const;
+
/// Remove all blocks with hash CurHash from MergePotentials, restoring
/// branches at ends of blocks as appropriate.
void RemoveBlocksWithHash(unsigned CurHash, MachineBasicBlock* SuccBB,
Index: llvm/lib/CodeGen/BranchFolding.cpp
===================================================================
--- llvm/lib/CodeGen/BranchFolding.cpp
+++ llvm/lib/CodeGen/BranchFolding.cpp
@@ -289,12 +289,20 @@
}
/// HashEndOfMBB - Hash the last instruction in the MBB.
-static unsigned HashEndOfMBB(const MachineBasicBlock &MBB) {
+unsigned BranchFolder::HashEndOfMBB(const MachineBasicBlock &MBB) const {
+ unsigned LastInstrHash = 0;
MachineBasicBlock::const_iterator I = MBB.getLastNonDebugInstr(false);
- if (I == MBB.end())
- return 0;
+ if (I != MBB.end())
+ LastInstrHash = HashMachineInstr(*I);
- return HashMachineInstr(*I);
+ // Avoid trying to tail merge across EH scopes.
+ unsigned EHScope = 0;
+ if (!EHScopeMembership.empty()) {
+ assert(EHScopeMembership.count(&MBB));
+ EHScope = EHScopeMembership.find(&MBB)->second;
+ llvm::errs() << "EHScope for " << printMBBReference(MBB) << ": " << EHScope << '\n';
+ }
+ return LastInstrHash + EHScope;
}
/// Whether MI should be counted as an instruction when calculating common tail.
@@ -1051,6 +1059,8 @@
// a compile-time infinite loop repeatedly doing and undoing the same
// transformations.)
+ llvm::errs() << "after TryTailMergeBlocks\n";
+
for (MachineFunction::iterator I = std::next(MF.begin()), E = MF.end();
I != E; ++I) {
if (I->pred_size() < 2) continue;
@@ -1150,6 +1160,7 @@
MergePotentials.begin()->getBlock() != PredBB)
FixTail(MergePotentials.begin()->getBlock(), IBB, TII);
}
+ llvm::errs() << "after after TryTailMergeBlocks\n";
return MadeChange;
}
@@ -1216,6 +1227,8 @@
// If it is dead, remove it.
if (MBB.pred_empty() && !MBB.isMachineBlockAddressTaken()) {
+ LLVM_DEBUG(dbgs() << "OptimizeBlock removed predecessors of "
+ << printMBBReference(MBB) << '\n');
RemoveDeadBlock(&MBB);
MadeChange = true;
++NumDeadBlocks;
@@ -1350,7 +1363,7 @@
// points to this block. Blocks with their addresses taken shouldn't be
// optimized away.
if (IsEmptyBlock(MBB) && !MBB->isEHPad() && !MBB->hasAddressTaken() &&
- SameEHScope) {
+ SameEHScope && !MBB->hasEHPadSuccessor()) {
salvageDebugInfoFromEmptyBlock(TII, *MBB);
// Dead block? Leave for cleanup later.
if (MBB->pred_empty()) return MadeChange;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159552.557653.patch
Type: text/x-patch
Size: 2951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20231009/1443c641/attachment-0001.bin>
More information about the llvm-commits
mailing list