From ecbca9f5fb7d7613d2b94982c4825eb0d33d6842 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 5 Feb 2022 19:04:23 +0100 Subject: Vendor import of llvm-project main llvmorg-14-init-18294-gdb01b123d012, the last commit before the upstream release/14.x branch was created. --- llvm/lib/Transforms/Utils/ModuleUtils.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (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 7c9ab7f6ca2c..d6a6be2762c7 100644 --- a/llvm/lib/Transforms/Utils/ModuleUtils.cpp +++ b/llvm/lib/Transforms/Utils/ModuleUtils.cpp @@ -264,3 +264,16 @@ void VFABI::setVectorVariantNames( CI->addFnAttr( Attribute::get(M->getContext(), MappingsAttrName, Buffer.str())); } + +void llvm::embedBufferInModule(Module &M, MemoryBufferRef Buf, + StringRef SectionName) { + // Embed the buffer into the module. + Constant *ModuleConstant = ConstantDataArray::get( + M.getContext(), makeArrayRef(Buf.getBufferStart(), Buf.getBufferSize())); + GlobalVariable *GV = new GlobalVariable( + M, ModuleConstant->getType(), true, GlobalValue::PrivateLinkage, + ModuleConstant, "llvm.embedded.object"); + GV->setSection(SectionName); + + appendToCompilerUsed(M, GV); +} -- cgit v1.2.3