mirror of
https://github.com/RPCSX/llvm.git
synced 2025-03-03 10:27:09 +00:00
Remove personality for declarations in CloneModule.
Personality is copied as part of copyFunctionAttributes, but it is invalid on a declaration. Remove the personality attribute it the function body is not cloned. Also add a verifier run over output modules in the llvm-split tool. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264667 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
574e4b288d
commit
2b6ba77f19
@ -126,6 +126,8 @@ std::unique_ptr<Module> llvm::CloneModule(
|
||||
if (!ShouldCloneDefinition(&*I)) {
|
||||
// Skip after setting the correct linkage for an external reference.
|
||||
F->setLinkage(GlobalValue::ExternalLinkage);
|
||||
// Personality function is not valid on a declaration.
|
||||
F->setPersonalityFn(nullptr);
|
||||
continue;
|
||||
}
|
||||
if (!I->isDeclaration()) {
|
||||
|
18
test/tools/llvm-split/personality.ll
Normal file
18
test/tools/llvm-split/personality.ll
Normal file
@ -0,0 +1,18 @@
|
||||
; Test that "personality" attributes are correctly updated when cloning modules.
|
||||
; RUN: llvm-split -o %t %s
|
||||
; RUN: llvm-dis -o - %t0 | FileCheck --check-prefix=CHECK0 %s
|
||||
; RUN: llvm-dis -o - %t1 | FileCheck --check-prefix=CHECK1 %s
|
||||
|
||||
; CHECK0: define void @foo()
|
||||
; CHECK1: declare void @foo()
|
||||
define void @foo() {
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK0: declare void @bar()
|
||||
; CHECK0-NOT: personality
|
||||
; CHECK1: define void @bar() personality i8* bitcast (void ()* @foo to i8*)
|
||||
define void @bar() personality i8* bitcast (void ()* @foo to i8*)
|
||||
{
|
||||
ret void
|
||||
}
|
@ -14,6 +14,7 @@
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/IRReader/IRReader.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
@ -61,6 +62,7 @@ int main(int argc, char **argv) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
verifyModule(*MPart);
|
||||
WriteBitcodeToFile(MPart.get(), Out->os());
|
||||
|
||||
// Declare success.
|
||||
|
Loading…
x
Reference in New Issue
Block a user