From 41fba3c107a5bc99065f3bf8b9f5b9d52eab2d98 Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Tue, 5 Jul 2022 12:55:36 -0400 Subject: [Metadata] Add 'exclude' metadata to add the exclude flags on globals This patchs adds a new metadata kind `exclude` which implies that the global variable should be given the necessary flags during code generation to not be included in the final executable. This is done using the ``SHF_EXCLUDE`` flag on ELF for example. This should make it easier to specify this flag on a variable without needing to explicitly check the section name in the target backend. Depends on D129053 D129052 Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D129151 --- llvm/lib/Transforms/Utils/ModuleUtils.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'llvm/lib/Transforms/Utils/ModuleUtils.cpp') diff --git a/llvm/lib/Transforms/Utils/ModuleUtils.cpp b/llvm/lib/Transforms/Utils/ModuleUtils.cpp index a3529bf..4dcba65 100644 --- a/llvm/lib/Transforms/Utils/ModuleUtils.cpp +++ b/llvm/lib/Transforms/Utils/ModuleUtils.cpp @@ -281,6 +281,7 @@ void llvm::embedBufferInModule(Module &M, MemoryBufferRef Buf, MDString::get(Ctx, SectionName)}; MD->addOperand(llvm::MDNode::get(Ctx, MDVals)); + GV->setMetadata(LLVMContext::MD_exclude, llvm::MDNode::get(Ctx, {})); appendToCompilerUsed(M, GV); } -- cgit v1.1