mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[Cloning] Teach CloneModule about personality functions
CloneModule didn't take into account that it needed to remap the value using values in the module. This fixes PR23992. llvm-svn: 241122
This commit is contained in:
parent
4759e1d16f
commit
cd7100d557
@ -99,7 +99,11 @@ Module *llvm::CloneModule(const Module *M, ValueToValueMapTy &VMap) {
|
||||
|
||||
SmallVector<ReturnInst*, 8> Returns; // Ignore returns cloned.
|
||||
CloneFunctionInto(F, I, VMap, /*ModuleLevelChanges=*/true, Returns);
|
||||
|
||||
}
|
||||
|
||||
if (I->hasPersonalityFn())
|
||||
F->setPersonalityFn(MapValue(I->getPersonalityFn(), VMap));
|
||||
}
|
||||
|
||||
// And aliases
|
||||
|
@ -415,4 +415,39 @@ TEST_F(CloneFunc, DebugIntrinsics) {
|
||||
}
|
||||
}
|
||||
|
||||
class CloneModule : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
SetupModule();
|
||||
CreateOldModule();
|
||||
CreateNewModule();
|
||||
}
|
||||
|
||||
void SetupModule() { OldM = new Module("", C); }
|
||||
|
||||
void CreateOldModule() {
|
||||
IRBuilder<> IBuilder(C);
|
||||
|
||||
auto *FuncType = FunctionType::get(Type::getVoidTy(C), false);
|
||||
auto *PersFn = Function::Create(FuncType, GlobalValue::ExternalLinkage,
|
||||
"persfn", OldM);
|
||||
auto *F =
|
||||
Function::Create(FuncType, GlobalValue::PrivateLinkage, "f", OldM);
|
||||
F->setPersonalityFn(PersFn);
|
||||
auto *Entry = BasicBlock::Create(C, "", F);
|
||||
IBuilder.SetInsertPoint(Entry);
|
||||
IBuilder.CreateRetVoid();
|
||||
}
|
||||
|
||||
void CreateNewModule() { NewM = llvm::CloneModule(OldM); }
|
||||
|
||||
LLVMContext C;
|
||||
Module *OldM;
|
||||
Module *NewM;
|
||||
};
|
||||
|
||||
TEST_F(CloneModule, Verify) {
|
||||
EXPECT_FALSE(verifyModule(*NewM));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user