Skip to content

Commit 4425b51

Browse files
committed
X86AsmBackend: Remove some computeFragmentSize calls
The function was brittle as it performed only one iteration, which might not converge. The reverted be5a845 mentioned that !NDEBUG and NDEBUG builds evaluated fragment offsets at different times. * X86AsmBackend::finishLayout performed only one iteration, which might not converge. In addition, the removed `#ifndef NDEBUG` code (disabled by default) in X86AsmBackend::finishLayout was problematic, as !NDEBUG and NDEBUG builds evaluated fragment offsets at different times before this patch.
1 parent 38b12d4 commit 4425b51

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -916,9 +916,6 @@ void X86AsmBackend::finishLayout(MCAssembler const &Asm) const {
916916
continue;
917917
}
918918

919-
#ifndef NDEBUG
920-
const uint64_t OrigOffset = Asm.getFragmentOffset(F);
921-
#endif
922919
const uint64_t OrigSize = Asm.computeFragmentSize(F);
923920

924921
// To keep the effects local, prefer to relax instructions closest to
@@ -949,14 +946,6 @@ void X86AsmBackend::finishLayout(MCAssembler const &Asm) const {
949946
if (F.getKind() == MCFragment::FT_BoundaryAlign)
950947
cast<MCBoundaryAlignFragment>(F).setSize(RemainingSize);
951948

952-
#ifndef NDEBUG
953-
const uint64_t FinalOffset = Asm.getFragmentOffset(F);
954-
const uint64_t FinalSize = Asm.computeFragmentSize(F);
955-
assert(OrigOffset + OrigSize == FinalOffset + FinalSize &&
956-
"can't move start of next fragment!");
957-
assert(FinalSize == RemainingSize && "inconsistent size computation?");
958-
#endif
959-
960949
// If we're looking at a boundary align, make sure we don't try to pad
961950
// its target instructions for some following directive. Doing so would
962951
// break the alignment of the current boundary align.
@@ -971,10 +960,8 @@ void X86AsmBackend::finishLayout(MCAssembler const &Asm) const {
971960
}
972961

973962
// The layout is done. Mark every fragment as valid.
974-
for (MCSection &Section : Asm) {
963+
for (MCSection &Section : Asm)
975964
Asm.getFragmentOffset(*Section.curFragList()->Tail);
976-
Asm.computeFragmentSize(*Section.curFragList()->Tail);
977-
}
978965
}
979966

980967
unsigned X86AsmBackend::getMaximumNopSize(const MCSubtargetInfo &STI) const {

0 commit comments

Comments
 (0)