[llvm] ce0bb31 - [DX] [NFC] Move hasSection check up
Chris Bieneman via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 3 13:55:03 PDT 2022
Author: Chris Bieneman
Date: 2022-08-03T15:54:53-05:00
New Revision: ce0bb316eb0c7cc944d0636b362b4bf20295f76e
URL: https://github.com/llvm/llvm-project/commit/ce0bb316eb0c7cc944d0636b362b4bf20295f76e
DIFF: https://github.com/llvm/llvm-project/commit/ce0bb316eb0c7cc944d0636b362b4bf20295f76e.diff
LOG: [DX] [NFC] Move hasSection check up
Juming out earlier if the global doesn't have a section is just a
cleaner early out.
Added:
Modified:
llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp b/llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp
index ad1f6b3cf2b68..3c45d0d5e0088 100644
--- a/llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp
+++ b/llvm/lib/Target/DirectX/DirectXAsmPrinter.cpp
@@ -40,14 +40,12 @@ class DXILAsmPrinter : public AsmPrinter {
} // 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);
More information about the llvm-commits
mailing list