From ce0bb316eb0c7cc944d0636b362b4bf20295f76e Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Wed, 3 Aug 2022 12:09:07 -0500 Subject: [PATCH] [DX] [NFC] Move hasSection check up Juming out earlier if the global doesn't have a section is just a cleaner early out. --- llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp b/llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp index ad1f6b3..3c45d0d 100644 --- a/llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp +++ b/llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp @@ -40,14 +40,12 @@ public: } // namespace void DXILAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) { - // If there is no initializer or the section is implicit, do nothing - if (!GV->hasInitializer() || GV->hasImplicitSection()) + // If there is no initializer, or no explicit section do nothing + if (!GV->hasInitializer() || GV->hasImplicitSection() || !GV->hasSection()) return; // Skip the LLVM metadata if (GV->getSection() == "llvm.metadata") return; - if (!GV->hasSection()) - return; SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM); MCSection *TheSection = getObjFileLowering().SectionForGlobal(GV, GVKind, TM); OutStreamer->switchSection(TheSection); -- 2.7.4