diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-16 19:35:39 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-16 19:35:39 +0000 |
commit | 27c076ae40ec65d1a9462d41f3709b305e641fa1 (patch) | |
tree | e834e8217541ca69c12a38d44fb365e9720933de /test/Assembler | |
parent | 33b37c7b12314d292c9074806f38aeaa6a707085 (diff) | |
download | llvm-27c076ae40ec65d1a9462d41f3709b305e641fa1.tar.gz llvm-27c076ae40ec65d1a9462d41f3709b305e641fa1.tar.bz2 llvm-27c076ae40ec65d1a9462d41f3709b305e641fa1.tar.xz |
Fix most of PR10367.
This patch changes the design of GlobalAlias so that it doesn't take a
ConstantExpr anymore. It now points directly to a GlobalObject, but its type is
independent of the aliasee type.
To avoid changing all alias related tests in this patches, I kept the common
syntax
@foo = alias i32* @bar
to mean the same as now. The cases that used to use cast now use the more
general syntax
@foo = alias i16, i32* @bar.
Note that GlobalAlias now behaves a bit more like GlobalVariable. We
know that its type is always a pointer, so we omit the '*'.
For the bitcode, a nice surprise is that we were writing both identical types
already, so the format change is minimal. Auto upgrade is handled by looking
through the casts and no new fields are needed for now. New bitcode will
simply have different types for Alias and Aliasee.
One last interesting point in the patch is that replaceAllUsesWith becomes
smart enough to avoid putting a ConstantExpr in the aliasee. This seems better
than checking and updating every caller.
A followup patch will delete getAliasedGlobal now that it is redundant. Another
patch will add support for an explicit offset.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209007 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Assembler')
-rw-r--r-- | test/Assembler/2009-04-25-AliasGEP.ll | 8 | ||||
-rw-r--r-- | test/Assembler/addrspacecast-alias.ll | 5 | ||||
-rw-r--r-- | test/Assembler/alias-addrspace.ll | 6 | ||||
-rw-r--r-- | test/Assembler/alias-to-alias.ll | 5 | ||||
-rw-r--r-- | test/Assembler/alias-to-alias2.ll | 7 | ||||
-rw-r--r-- | test/Assembler/alias-type.ll | 6 |
6 files changed, 27 insertions, 10 deletions
diff --git a/test/Assembler/2009-04-25-AliasGEP.ll b/test/Assembler/2009-04-25-AliasGEP.ll deleted file mode 100644 index 6d07208def..0000000000 --- a/test/Assembler/2009-04-25-AliasGEP.ll +++ /dev/null @@ -1,8 +0,0 @@ -; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis -; PR4066 -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin9" - %struct.i2c_device_id = type { } -@w83l785ts_id = internal constant [0 x %struct.i2c_device_id] zeroinitializer, align 1 ; <[0 x %struct.i2c_device_id]*> [#uses=1] - -@__mod_i2c_device_table = alias getelementptr ([0 x %struct.i2c_device_id]* @w83l785ts_id, i32 0, i32 0) ; <%struct.i2c_device_id*> [#uses=0] diff --git a/test/Assembler/addrspacecast-alias.ll b/test/Assembler/addrspacecast-alias.ll index 6623a25d18..052a1414ea 100644 --- a/test/Assembler/addrspacecast-alias.ll +++ b/test/Assembler/addrspacecast-alias.ll @@ -1,6 +1,7 @@ -; RUN: llvm-as -disable-output %s +; RUN: llvm-as < %s | llvm-dis | FileCheck %s ; Test that global aliases are allowed to be constant addrspacecast @i = internal addrspace(1) global i8 42 -@ia = alias internal i8 addrspace(2)* addrspacecast (i8 addrspace(1)* @i to i8 addrspace(2)*) +@ia = alias internal addrspace(2) i8 addrspace(3)*, i8 addrspace(1)* @i +; CHECK: @ia = alias internal addrspace(2) i8 addrspace(3)*, i8 addrspace(1)* @i diff --git a/test/Assembler/alias-addrspace.ll b/test/Assembler/alias-addrspace.ll new file mode 100644 index 0000000000..6d378e45fa --- /dev/null +++ b/test/Assembler/alias-addrspace.ll @@ -0,0 +1,6 @@ +; RUN: not llvm-as %s 2>&1 | FileCheck %s + +@foo = global i32 42 +@bar = alias internal addrspace(1) i32* @foo + +CHECK: error: A type is required if addrspace is given diff --git a/test/Assembler/alias-to-alias.ll b/test/Assembler/alias-to-alias.ll new file mode 100644 index 0000000000..1ea99bbb69 --- /dev/null +++ b/test/Assembler/alias-to-alias.ll @@ -0,0 +1,5 @@ +; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s +; CHECK: Alias must point to function or variable + +@b1 = alias i32* @c1 +@c1 = alias i32* @b1 diff --git a/test/Assembler/alias-to-alias2.ll b/test/Assembler/alias-to-alias2.ll new file mode 100644 index 0000000000..a8a0196f43 --- /dev/null +++ b/test/Assembler/alias-to-alias2.ll @@ -0,0 +1,7 @@ +; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s +; CHECK: error: Alias is pointed by alias b1 + +@g = global i32 42 + +@b1 = alias i32* @c1 +@c1 = alias i32* @g diff --git a/test/Assembler/alias-type.ll b/test/Assembler/alias-type.ll new file mode 100644 index 0000000000..ead3e95243 --- /dev/null +++ b/test/Assembler/alias-type.ll @@ -0,0 +1,6 @@ +; RUN: not llvm-as %s 2>&1 | FileCheck %s + +@foo = global i32 42 +@bar = alias i32 @foo + +CHECK: error: An alias must have pointer type |