aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-06-27 22:27:14 -0700
committerFangrui Song <i@maskray.me>2024-06-27 22:27:14 -0700
commitfcffb2c0240bb3a08b3e14486ea6abd23fa2c44f (patch)
tree93c8556b0fa8c117e43126ad08f37461f1a9fb09 /llvm/lib
parentfadc72235ed59eba8538d803fba5c79cd9cda5e9 (diff)
downloadllvm-fcffb2c0240bb3a08b3e14486ea6abd23fa2c44f.zip
llvm-fcffb2c0240bb3a08b3e14486ea6abd23fa2c44f.tar.gz
llvm-fcffb2c0240bb3a08b3e14486ea6abd23fa2c44f.tar.bz2
[MC] Replace one nullable getCurrentSectionOnly with CurFrag
We will implement getCurrentSectionOnly with `CurFrag->getParent()`, which is non-null. Eliminate a nullable use.
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/MCELFStreamer.cpp4
-rw-r--r--llvm/lib/MC/MCObjectStreamer.cpp3
2 files changed, 4 insertions, 3 deletions
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;
}