aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authordyung <douglas.yung@sony.com>2025-05-27 17:43:59 -0400
committerGitHub <noreply@github.com>2025-05-27 17:43:59 -0400
commit0354491bea04beb6d1db44f8ca522bfc597ab0d3 (patch)
treeaf58417712c8b130413a7dc9b6eb72c33b5fd178 /clang/lib/CodeGen/CodeGenModule.cpp
parent04a96c6900c8c32627eba1d75ab28312781df43f (diff)
downloadllvm-0354491bea04beb6d1db44f8ca522bfc597ab0d3.zip
llvm-0354491bea04beb6d1db44f8ca522bfc597ab0d3.tar.gz
llvm-0354491bea04beb6d1db44f8ca522bfc597ab0d3.tar.bz2
Avoid emitting a linker options section in the compiler if it is empty. (#139821)
Recently in some of our internal testing, we noticed that the compiler was sometimes generating an empty linker.options section which seems unnecessary. This proposed change causes the compiler to simply omit emitting the linker.options section if it is empty.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 039507b..6d2c705 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3275,9 +3275,11 @@ void CodeGenModule::EmitModuleLinkOptions() {
LinkerOptionsMetadata.append(MetadataArgs.begin(), MetadataArgs.end());
// Add the linker options metadata flag.
- auto *NMD = getModule().getOrInsertNamedMetadata("llvm.linker.options");
- for (auto *MD : LinkerOptionsMetadata)
- NMD->addOperand(MD);
+ if (!LinkerOptionsMetadata.empty()) {
+ auto *NMD = getModule().getOrInsertNamedMetadata("llvm.linker.options");
+ for (auto *MD : LinkerOptionsMetadata)
+ NMD->addOperand(MD);
+ }
}
void CodeGenModule::EmitDeferred() {