diff options
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
| -rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 7ebe10e9b445..eb4e09ea3a26 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -4973,52 +4973,3 @@ void llvm::EmbedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf, llvm::ConstantArray::get(ATy, UsedArray), "llvm.compiler.used"); NewUsed->setSection("llvm.metadata"); } - -static void appendToCompilerUsed(Module &M, ArrayRef<GlobalValue *> Values) { - GlobalVariable *GV = M.getGlobalVariable("llvm.compiler.used"); - SmallPtrSet<Constant *, 16> InitAsSet; - SmallVector<Constant *, 16> Init; - if (GV) { - if (GV->hasInitializer()) { - auto *CA = cast<ConstantArray>(GV->getInitializer()); - for (auto &Op : CA->operands()) { - Constant *C = cast_or_null<Constant>(Op); - if (InitAsSet.insert(C).second) - Init.push_back(C); - } - } - GV->eraseFromParent(); - } - - Type *Int8PtrTy = llvm::Type::getInt8PtrTy(M.getContext()); - for (auto *V : Values) { - Constant *C = ConstantExpr::getPointerBitCastOrAddrSpaceCast(V, Int8PtrTy); - if (InitAsSet.insert(C).second) - Init.push_back(C); - } - - if (Init.empty()) - return; - - ArrayType *ATy = ArrayType::get(Int8PtrTy, Init.size()); - GV = new llvm::GlobalVariable(M, ATy, false, GlobalValue::AppendingLinkage, - ConstantArray::get(ATy, Init), - "llvm.compiler.used"); - GV->setSection("llvm.metadata"); -} - -void llvm::EmbedBufferInModule(llvm::Module &M, llvm::MemoryBufferRef Buf, - StringRef SectionName) { - ArrayRef<char> ModuleData = - ArrayRef<char>(Buf.getBufferStart(), Buf.getBufferSize()); - - // Embed the buffer into the module. - llvm::Constant *ModuleConstant = - llvm::ConstantDataArray::get(M.getContext(), ModuleData); - llvm::GlobalVariable *GV = new llvm::GlobalVariable( - M, ModuleConstant->getType(), true, llvm::GlobalValue::PrivateLinkage, - ModuleConstant, "llvm.embedded.object"); - GV->setSection(SectionName); - - appendToCompilerUsed(M, GV); -} |
