Skip to content

Commit 4c19b89

Browse files
committed
[NFC][ARM] Comments and lambdas
Add some comments in LowOverheadLoops and make some lambda variables explicit arguments instead of capturing.
1 parent 98ef7e2 commit 4c19b89

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -921,14 +921,17 @@ void LowOverheadLoop::Validate(ARMBasicBlockUtils *BBUtils) {
921921
if (Revert)
922922
return;
923923

924-
auto ValidateRanges = [this, &BBUtils]() {
924+
// Check branch target ranges: WLS[TP] can only branch forwards and LE[TP]
925+
// can only jump back.
926+
auto ValidateRanges = [](MachineInstr *Start, MachineInstr *End,
927+
ARMBasicBlockUtils *BBUtils, MachineLoop &ML) {
925928
if (!End->getOperand(1).isMBB())
926929
report_fatal_error("Expected LoopEnd to target basic block");
927930

928931
// TODO Maybe there's cases where the target doesn't have to be the header,
929932
// but for now be safe and revert.
930933
if (End->getOperand(1).getMBB() != ML.getHeader()) {
931-
LLVM_DEBUG(dbgs() << "ARM Loops: LoopEnd is not targetting header.\n");
934+
LLVM_DEBUG(dbgs() << "ARM Loops: LoopEnd is not targeting header.\n");
932935
return false;
933936
}
934937

@@ -950,7 +953,10 @@ void LowOverheadLoop::Validate(ARMBasicBlockUtils *BBUtils) {
950953
return true;
951954
};
952955

953-
auto FindStartInsertionPoint = [this]() -> MachineInstr* {
956+
// Find a suitable position to insert the loop start instruction. It needs to
957+
// be able to safely define LR.
958+
auto FindStartInsertionPoint = [](MachineInstr *Start,
959+
ReachingDefAnalysis &RDA) -> MachineInstr* {
954960
// We can define LR because LR already contains the same value.
955961
if (Start->getOperand(0).getReg() == ARM::LR)
956962
return Start;
@@ -983,8 +989,8 @@ void LowOverheadLoop::Validate(ARMBasicBlockUtils *BBUtils) {
983989
return RDA.isSafeToDefRegAt(Start, ARM::LR) ? Start : nullptr;
984990
};
985991

986-
InsertPt = FindStartInsertionPoint();
987-
Revert = !ValidateRanges() || !InsertPt;
992+
InsertPt = FindStartInsertionPoint(Start, RDA);
993+
Revert = !ValidateRanges(Start, End, BBUtils, ML) || !InsertPt;
988994
CannotTailPredicate = !ValidateTailPredicate(InsertPt);
989995

990996
LLVM_DEBUG(if (!InsertPt)

0 commit comments

Comments
 (0)