[PATCH] D18486: Remove personality for declarations in CloneModule.
Evgeniy Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 28 14:16:01 PDT 2016
eugenis retitled this revision from "Update personality for declarations in CloneModule." to "Remove personality for declarations in CloneModule.
".
eugenis updated the summary for this revision.
eugenis updated this revision to Diff 51841.
Repository:
rL LLVM
http://reviews.llvm.org/D18486
Files:
lib/Transforms/Utils/CloneModule.cpp
test/tools/llvm-split/personality.ll
tools/llvm-split/llvm-split.cpp
Index: tools/llvm-split/llvm-split.cpp
===================================================================
--- tools/llvm-split/llvm-split.cpp
+++ tools/llvm-split/llvm-split.cpp
@@ -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 @@
exit(1);
}
+ verifyModule(*MPart);
WriteBitcodeToFile(MPart.get(), Out->os());
// Declare success.
Index: test/tools/llvm-split/personality.ll
===================================================================
--- /dev/null
+++ test/tools/llvm-split/personality.ll
@@ -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
+}
Index: lib/Transforms/Utils/CloneModule.cpp
===================================================================
--- lib/Transforms/Utils/CloneModule.cpp
+++ lib/Transforms/Utils/CloneModule.cpp
@@ -126,6 +126,8 @@
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()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18486.51841.patch
Type: text/x-patch
Size: 1877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160328/e82e845a/attachment.bin>
More information about the llvm-commits
mailing list