summaryrefslogtreecommitdiff
path: root/test/Transforms/ConstantMerge
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-01-11 00:13:08 +0000
committerBill Wendling <isanbard@gmail.com>2012-01-11 00:13:08 +0000
commit37b94c6b4e605c522164bcafc58ea1e1afb50cc0 (patch)
tree70979afa0d13ea1f8c04a6dfea8a4b40e2cd2e67 /test/Transforms/ConstantMerge
parentdcc296d420d064e4cedfc80abc8df6bfb0b35b03 (diff)
downloadllvm-37b94c6b4e605c522164bcafc58ea1e1afb50cc0.tar.gz
llvm-37b94c6b4e605c522164bcafc58ea1e1afb50cc0.tar.bz2
llvm-37b94c6b4e605c522164bcafc58ea1e1afb50cc0.tar.xz
If the global variable is removed by the linker, then don't constant merge it
with other symbols. An object in the __cfstring section is suppoed to be filled with CFString objects, which have a pointer to ___CFConstantStringClassReference followed by a pointer to a __cstring. If we allow the object in the __cstring section to be merged with another global, then it could end up in any section. Because the linker is going to remove these symbols in the final executable, we shouldn't bother to merge them. <rdar://problem/10564621> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147899 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/ConstantMerge')
-rw-r--r--test/Transforms/ConstantMerge/linker-private.ll23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/Transforms/ConstantMerge/linker-private.ll b/test/Transforms/ConstantMerge/linker-private.ll
new file mode 100644
index 0000000000..eba7880e8a
--- /dev/null
+++ b/test/Transforms/ConstantMerge/linker-private.ll
@@ -0,0 +1,23 @@
+; RUN: opt < %s -constmerge -S | FileCheck %s
+; <rdar://problem/10564621>
+
+%0 = type opaque
+%struct.NSConstantString = type { i32*, i32, i8*, i32 }
+
+; CHECK: @.str3 = linker_private unnamed_addr constant [1 x i8] zeroinitializer, align 1
+
+@isLogVisible = global i8 0, align 1
+@__CFConstantStringClassReference = external global [0 x i32]
+@.str3 = linker_private unnamed_addr constant [1 x i8] zeroinitializer, align 1
+@_unnamed_cfstring_4 = private constant %struct.NSConstantString { i32* getelementptr inbounds ([0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* getelementptr inbounds ([1 x i8]* @.str3, i32 0, i32 0), i32 0 }, section "__DATA,__cfstring"
+@null.array = weak_odr constant [1 x i8] zeroinitializer, align 1
+
+define linkonce_odr void @bar() nounwind ssp align 2 {
+entry:
+ %stack = alloca i8*, align 4
+ %call = call %0* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to %0* (i8*, i8*, %0*)*)(i8* null, i8* null, %0* bitcast (%struct.NSConstantString* @_unnamed_cfstring_4 to %0*))
+ store i8* getelementptr inbounds ([1 x i8]* @null.array, i32 0, i32 0), i8** %stack, align 4
+ ret void
+}
+
+declare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind