From fcffb2c0240bb3a08b3e14486ea6abd23fa2c44f Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 27 Jun 2024 22:27:14 -0700 Subject: [MC] Replace one nullable getCurrentSectionOnly with CurFrag We will implement getCurrentSectionOnly with `CurFrag->getParent()`, which is non-null. Eliminate a nullable use. --- llvm/lib/MC/MCELFStreamer.cpp | 4 ++-- llvm/lib/MC/MCObjectStreamer.cpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp index bf3edcc..b88a572 100644 --- a/llvm/lib/MC/MCELFStreamer.cpp +++ b/llvm/lib/MC/MCELFStreamer.cpp @@ -628,8 +628,8 @@ void MCELFStreamer::finishImpl() { } // Ensure the last section gets aligned if necessary. - MCSection *CurSection = getCurrentSectionOnly(); - setSectionAlignmentForBundling(getAssembler(), CurSection); + if (MCFragment *F = getCurrentFragment()) + setSectionAlignmentForBundling(getAssembler(), F->getParent()); finalizeCGProfile(); emitFrames(nullptr); diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index 6dddaa4..cd5e049 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -143,7 +143,8 @@ void MCObjectStreamer::emitFrames(MCAsmBackend *MAB) { } MCFragment *MCObjectStreamer::getCurrentFragment() const { - assert(CurFrag->getParent() == getCurrentSection().first); + assert(!getCurrentSection().first || + CurFrag->getParent() == getCurrentSection().first); return CurFrag; } -- cgit v1.1