[DX] [NFC] Move hasSection check up
authorChris Bieneman <chris.bieneman@me.com>
Wed, 3 Aug 2022 17:09:07 +0000 (12:09 -0500)
committerChris Bieneman <chris.bieneman@me.com>
Wed, 3 Aug 2022 20:54:53 +0000 (15:54 -0500)
Juming out earlier if the global doesn't have a section is just a
cleaner early out.

llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp

index ad1f6b3..3c45d0d 100644 (file)
@@ -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);