mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
Cloning: Also clone global variable attached metadata.
llvm-svn: 285161
This commit is contained in:
parent
870852fa93
commit
f4cf97ceb0
@ -119,6 +119,11 @@ std::unique_ptr<Module> llvm::CloneModule(
|
||||
}
|
||||
if (I->hasInitializer())
|
||||
GV->setInitializer(MapValue(I->getInitializer(), VMap));
|
||||
|
||||
SmallVector<std::pair<unsigned, MDNode *>, 1> MDs;
|
||||
I->getAllMetadata(MDs);
|
||||
for (auto MD : MDs)
|
||||
GV->addMetadata(MD.first, *MapMetadata(MD.second, VMap));
|
||||
}
|
||||
|
||||
// Similarly, copy over function bodies now...
|
||||
|
@ -403,6 +403,11 @@ protected:
|
||||
void SetupModule() { OldM = new Module("", C); }
|
||||
|
||||
void CreateOldModule() {
|
||||
auto GV = new GlobalVariable(
|
||||
*OldM, Type::getInt32Ty(C), false, GlobalValue::ExternalLinkage,
|
||||
ConstantInt::get(Type::getInt32Ty(C), 1), "gv");
|
||||
GV->addMetadata(LLVMContext::MD_type, *MDNode::get(C, {}));
|
||||
|
||||
DIBuilder DBuilder(*OldM);
|
||||
IRBuilder<> IBuilder(C);
|
||||
|
||||
@ -459,4 +464,9 @@ TEST_F(CloneModule, Subprogram) {
|
||||
EXPECT_EQ(SP->getFile()->getFilename(), "filename.c");
|
||||
EXPECT_EQ(SP->getLine(), (unsigned)4);
|
||||
}
|
||||
|
||||
TEST_F(CloneModule, GlobalMetadata) {
|
||||
GlobalVariable *NewGV = NewM->getGlobalVariable("gv");
|
||||
EXPECT_NE(nullptr, NewGV->getMetadata(LLVMContext::MD_type));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user