summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2015-07-16 17:42:21 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2015-07-16 17:42:21 +0000
commit9b0fe61047845f26d5f183ae98db02e4130b37f5 (patch)
tree6bc259bf5dc10d64fa4670911fe0497b935a7ecf /llvm/test
parentdf7cd313d9f6ff822b6b2313d1df64b9e81af35b (diff)
downloadbcm5719-llvm-9b0fe61047845f26d5f183ae98db02e4130b37f5.tar.gz
bcm5719-llvm-9b0fe61047845f26d5f183ae98db02e4130b37f5.zip
Internalize: internalize comdat members as a group, and drop comdat on such members.
Internalizing an individual comdat group member without also internalizing the other members of the comdat can break comdat semantics. For example, if a module contains a reference to an internalized comdat member, and the linker chooses a comdat group from a different object file, this will break the reference to the internalized member. This change causes the internalizer to only internalize comdat members if all other members of the comdat are not externally visible. Once a comdat group has been fully internalized, there is no need to apply comdat rules to its members; later optimization passes (e.g. globaldce) can legally drop individual members of the comdat. So we drop the comdat attribute from all comdat members. Differential Revision: http://reviews.llvm.org/D10679 llvm-svn: 242423
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/Internalize/comdat.ll52
1 files changed, 52 insertions, 0 deletions
diff --git a/llvm/test/Transforms/Internalize/comdat.ll b/llvm/test/Transforms/Internalize/comdat.ll
new file mode 100644
index 00000000000..8217dd603a1
--- /dev/null
+++ b/llvm/test/Transforms/Internalize/comdat.ll
@@ -0,0 +1,52 @@
+; RUN: opt < %s -internalize -internalize-public-api-list c1 -internalize-public-api-list c2 -internalize-public-api-list c3 -internalize-public-api-list c4 -S | FileCheck %s
+
+$c1 = comdat any
+$c2 = comdat any
+$c3 = comdat any
+$c4 = comdat any
+
+; CHECK: @c1_c = global i32 0, comdat($c1)
+@c1_c = global i32 0, comdat($c1)
+
+; CHECK: @c2_b = internal global i32 0{{$}}
+@c2_b = global i32 0, comdat($c2)
+
+; CHECK: @c3 = global i32 0, comdat{{$}}
+@c3 = global i32 0, comdat
+
+; CHECK: @c4_a = internal global i32 0, comdat($c4)
+@c4_a = internal global i32 0, comdat($c4)
+
+; CHECK: @c1_d = alias i32* @c1_c
+@c1_d = alias i32* @c1_c
+
+; CHECK: @c2_c = internal alias i32* @c2_b
+@c2_c = alias i32* @c2_b
+
+; CHECK: @c4 = alias i32* @c4_a
+@c4 = alias i32* @c4_a
+
+; CHECK: define void @c1() comdat {
+define void @c1() comdat {
+ ret void
+}
+
+; CHECK: define void @c1_a() comdat($c1) {
+define void @c1_a() comdat($c1) {
+ ret void
+}
+
+; CHECK: define internal void @c2() {
+define internal void @c2() comdat {
+ ret void
+}
+
+; CHECK: define internal void @c2_a() {
+define void @c2_a() comdat($c2) {
+ ret void
+}
+
+; CHECK: define void @c3_a() comdat($c3) {
+define void @c3_a() comdat($c3) {
+ ret void
+}
OpenPOWER on IntegriCloud