summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-03-27 15:26:56 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-03-27 15:26:56 +0000
commit24a669d225f9cacf1cd3846e333f9690a06d1e1c (patch)
treeb470c3e65a0da9bb79b4696506dbe4fda36bf3fa /llvm/test
parentfd2b75948df6e27820fb0e086e4c2bbb4fc9bd28 (diff)
downloadbcm5719-llvm-24a669d225f9cacf1cd3846e333f9690a06d1e1c.tar.gz
bcm5719-llvm-24a669d225f9cacf1cd3846e333f9690a06d1e1c.zip
Prevent alias from pointing to weak aliases.
This adds back r204781. Original message: Aliases are just another name for a position in a file. As such, the regular symbol resolutions are not applied. For example, given define void @my_func() { ret void } @my_alias = alias weak void ()* @my_func @my_alias2 = alias void ()* @my_alias We produce without this patch: .weak my_alias my_alias = my_func .globl my_alias2 my_alias2 = my_alias That is, in the resulting ELF file my_alias, my_func and my_alias are just 3 names pointing to offset 0 of .text. That is *not* the semantics of IR linking. For example, linking in a @my_alias = alias void ()* @other_func would require the strong my_alias to override the weak one and my_alias2 would end up pointing to other_func. There is no way to represent that with aliases being just another name, so the best solution seems to be to just disallow it, converting a miscompile into an error. llvm-svn: 204934
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/X86/dllexport-x86_64.ll2
-rw-r--r--llvm/test/CodeGen/X86/dllexport.ll2
-rw-r--r--llvm/test/Feature/aliases.ll2
-rw-r--r--llvm/test/Transforms/GlobalOpt/alias-resolve.ll15
4 files changed, 13 insertions, 8 deletions
diff --git a/llvm/test/CodeGen/X86/dllexport-x86_64.ll b/llvm/test/CodeGen/X86/dllexport-x86_64.ll
index 1fadfec2543..a38c2d8f8ab 100644
--- a/llvm/test/CodeGen/X86/dllexport-x86_64.ll
+++ b/llvm/test/CodeGen/X86/dllexport-x86_64.ll
@@ -65,7 +65,7 @@ define weak_odr dllexport void @weak1() {
@alias2 = dllexport alias void()* @f1
; CHECK: .globl alias3
-; CHECK: alias3 = alias
+; CHECK: alias3 = notExported
@alias3 = dllexport alias void()* @alias
; CHECK: .weak weak_alias
diff --git a/llvm/test/CodeGen/X86/dllexport.ll b/llvm/test/CodeGen/X86/dllexport.ll
index 7f0dadb6a2e..1b34d238693 100644
--- a/llvm/test/CodeGen/X86/dllexport.ll
+++ b/llvm/test/CodeGen/X86/dllexport.ll
@@ -80,7 +80,7 @@ define weak_odr dllexport void @weak1() {
@alias2 = dllexport alias void()* @f1
; CHECK: .globl _alias3
-; CHECK: _alias3 = _alias
+; CHECK: _alias3 = _notExported
@alias3 = dllexport alias void()* @alias
; CHECK: .weak _weak_alias
diff --git a/llvm/test/Feature/aliases.ll b/llvm/test/Feature/aliases.ll
index 7ffa5f26013..7fe9d0b374e 100644
--- a/llvm/test/Feature/aliases.ll
+++ b/llvm/test/Feature/aliases.ll
@@ -14,7 +14,7 @@
define i32 @foo_f() {
ret i32 0
}
-@bar_f = alias weak %FunTy* @foo_f
+@bar_f = alias weak_odr %FunTy* @foo_f
@bar_ff = alias i32()* @bar_f
@bar_i = alias internal i32* @bar
diff --git a/llvm/test/Transforms/GlobalOpt/alias-resolve.ll b/llvm/test/Transforms/GlobalOpt/alias-resolve.ll
index 64e3d88af8a..2d5a956d14b 100644
--- a/llvm/test/Transforms/GlobalOpt/alias-resolve.ll
+++ b/llvm/test/Transforms/GlobalOpt/alias-resolve.ll
@@ -1,14 +1,17 @@
; RUN: opt < %s -globalopt -S | FileCheck %s
@foo1 = alias void ()* @foo2
-; CHECK: @foo1 = alias void ()* @foo2
+; CHECK: @foo1 = alias void ()* @bar2
-@foo2 = alias weak void()* @bar1
-; CHECK: @foo2 = alias weak void ()* @bar2
+@foo2 = alias void()* @bar1
+; CHECK: @foo2 = alias void ()* @bar2
@bar1 = alias void ()* @bar2
; CHECK: @bar1 = alias void ()* @bar2
+@weak1 = alias weak void ()* @bar2
+; CHECK: @weak1 = alias weak void ()* @bar2
+
define void @bar2() {
ret void
}
@@ -17,14 +20,16 @@ define void @bar2() {
define void @baz() {
entry:
call void @foo1()
-; CHECK: call void @foo2()
+; CHECK: call void @bar2()
call void @foo2()
-; CHECK: call void @foo2()
+; CHECK: call void @bar2()
call void @bar1()
; CHECK: call void @bar2()
+ call void @weak1()
+; CHECK: call void @weak1()
ret void
}
OpenPOWER on IntegriCloud