[llvm] r264667 - Remove personality for declarations in CloneModule.
Evgeniy Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 28 14:37:02 PDT 2016
Author: eugenis
Date: Mon Mar 28 16:37:02 2016
New Revision: 264667
URL: http://llvm.org/viewvc/llvm-project?rev=264667&view=rev
Log:
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.
Added:
llvm/trunk/test/tools/llvm-split/personality.ll
Modified:
llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
llvm/trunk/tools/llvm-split/llvm-split.cpp
Modified: llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneModule.cpp?rev=264667&r1=264666&r2=264667&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneModule.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneModule.cpp Mon Mar 28 16:37:02 2016
@@ -126,6 +126,8 @@ std::unique_ptr<Module> llvm::CloneModul
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()) {
Added: llvm/trunk/test/tools/llvm-split/personality.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-split/personality.ll?rev=264667&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-split/personality.ll (added)
+++ llvm/trunk/test/tools/llvm-split/personality.ll Mon Mar 28 16:37:02 2016
@@ -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
+}
Modified: llvm/trunk/tools/llvm-split/llvm-split.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-split/llvm-split.cpp?rev=264667&r1=264666&r2=264667&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-split/llvm-split.cpp (original)
+++ llvm/trunk/tools/llvm-split/llvm-split.cpp Mon Mar 28 16:37:02 2016
@@ -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.
More information about the llvm-commits
mailing list