summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp35
1 files changed, 14 insertions, 21 deletions
diff --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
index 2ba27af43a9..90cf11c4622 100644
--- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -130,8 +130,7 @@ void promoteTypeIds(Module &M, StringRef ModuleId) {
}
GO.addMetadata(
LLVMContext::MD_type,
- *MDNode::get(M.getContext(),
- ArrayRef<Metadata *>{MD->getOperand(0), I->second}));
+ *MDNode::get(M.getContext(), {MD->getOperand(0), I->second}));
}
}
}
@@ -216,10 +215,8 @@ void splitAndWriteThinLTOBitcode(
// Returns whether a global has attached type metadata. Such globals may
// participate in CFI or whole-program devirtualization, so they need to
// appear in the merged module instead of the thin LTO module.
- auto HasTypeMetadata = [&](const GlobalObject *GO) {
- SmallVector<MDNode *, 1> MDs;
- GO->getMetadata(LLVMContext::MD_type, MDs);
- return !MDs.empty();
+ auto HasTypeMetadata = [](const GlobalObject *GO) {
+ return GO->hasMetadata(LLVMContext::MD_type);
};
// Collect the set of virtual functions that are eligible for virtual constant
@@ -337,14 +334,15 @@ void splitAndWriteThinLTOBitcode(
continue;
auto *F = cast<Function>(A.getAliasee());
- SmallVector<Metadata *, 4> Elts;
- Elts.push_back(MDString::get(Ctx, A.getName()));
- Elts.push_back(MDString::get(Ctx, F->getName()));
- Elts.push_back(ConstantAsMetadata::get(
- llvm::ConstantInt::get(Type::getInt8Ty(Ctx), A.getVisibility())));
- Elts.push_back(ConstantAsMetadata::get(
- llvm::ConstantInt::get(Type::getInt8Ty(Ctx), A.isWeakForLinker())));
+ Metadata *Elts[] = {
+ MDString::get(Ctx, A.getName()),
+ MDString::get(Ctx, F->getName()),
+ ConstantAsMetadata::get(
+ ConstantInt::get(Type::getInt8Ty(Ctx), A.getVisibility())),
+ ConstantAsMetadata::get(
+ ConstantInt::get(Type::getInt8Ty(Ctx), A.isWeakForLinker())),
+ };
FunctionAliases.push_back(MDTuple::get(Ctx, Elts));
}
@@ -361,11 +359,8 @@ void splitAndWriteThinLTOBitcode(
if (!F || F->use_empty())
return;
- SmallVector<Metadata *, 2> Elts;
- Elts.push_back(MDString::get(Ctx, Name));
- Elts.push_back(MDString::get(Ctx, Alias));
-
- Symvers.push_back(MDTuple::get(Ctx, Elts));
+ Symvers.push_back(MDTuple::get(
+ Ctx, {MDString::get(Ctx, Name), MDString::get(Ctx, Alias)}));
});
if (!Symvers.empty()) {
@@ -418,10 +413,8 @@ void splitAndWriteThinLTOBitcode(
// Returns whether this module needs to be split because it uses type metadata.
bool requiresSplit(Module &M) {
- SmallVector<MDNode *, 1> MDs;
for (auto &GO : M.global_objects()) {
- GO.getMetadata(LLVMContext::MD_type, MDs);
- if (!MDs.empty())
+ if (GO.hasMetadata(LLVMContext::MD_type))
return true;
}
OpenPOWER on IntegriCloud