From bb4ee27a31695bb06bfe56d442b30b25ac88d7cd Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 9 Jun 2024 23:14:15 -0700 Subject: [PATCH] [MC] Remove the last MCFragment::getPrevNode use. NFC --- llvm/lib/MC/MCAssembler.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index c56d28bb70e730..a7157e7a37b439 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -1094,9 +1094,11 @@ bool MCAssembler::relaxBoundaryAlign(MCAsmLayout &Layout, uint64_t AlignedOffset = Layout.getFragmentOffset(&BF); uint64_t AlignedSize = 0; - for (const MCFragment *F = BF.getLastFragment(); F != &BF; - F = F->getPrevNode()) + for (const MCFragment *F = BF.getNextNode();; F = F->getNextNode()) { AlignedSize += computeFragmentSize(Layout, *F); + if (F == BF.getLastFragment()) + break; + } Align BoundaryAlignment = BF.getAlignment(); uint64_t NewSize = needPadding(AlignedOffset, AlignedSize, BoundaryAlignment)