diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-06-03 02:41:57 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-06-03 02:41:57 +0000 |
commit | 2d21b25393a461fbf8ab824889a6c56e1dd0b1cb (patch) | |
tree | 2a66d16ed61fd38a800d76e014bf585fbc454f05 /test/Verifier | |
parent | 27bd9b361bf11cd6dfe4ea3932adc6afadcf4a86 (diff) | |
download | llvm-2d21b25393a461fbf8ab824889a6c56e1dd0b1cb.tar.gz llvm-2d21b25393a461fbf8ab824889a6c56e1dd0b1cb.tar.bz2 llvm-2d21b25393a461fbf8ab824889a6c56e1dd0b1cb.tar.xz |
Allow alias to point to an arbitrary ConstantExpr.
This patch changes GlobalAlias to point to an arbitrary ConstantExpr and it is
up to MC (or the system assembler) to decide if that expression is valid or not.
This reduces our ability to diagnose invalid uses and how early we can spot
them, but it also lets us do things like
@test5 = alias inttoptr(i32 sub (i32 ptrtoint (i32* @test2 to i32),
i32 ptrtoint (i32* @bar to i32)) to i32*)
An important implication of this patch is that the notion of aliased global
doesn't exist any more. The alias has to encode the information needed to
access it in its metadata (linkage, visibility, type, etc).
Another consequence to notice is that getSection has to return a "const char *".
It could return a NullTerminatedStringRef if there was such a thing, but when
that was proposed the decision was to just uses "const char*" for that.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210062 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Verifier')
-rw-r--r-- | test/Verifier/alias.ll | 15 | ||||
-rw-r--r-- | test/Verifier/bitcast-alias-address-space.ll | 10 |
2 files changed, 25 insertions, 0 deletions
diff --git a/test/Verifier/alias.ll b/test/Verifier/alias.ll index e3636bc701..ff02a37bab 100644 --- a/test/Verifier/alias.ll +++ b/test/Verifier/alias.ll @@ -10,3 +10,18 @@ declare void @f() @ga = alias i32* @g ; CHECK: Alias must point to a definition ; CHECK-NEXT: @ga + + +@test2_a = alias i32* @test2_b +@test2_b = alias i32* @test2_a +; CHECK: Aliases cannot form a cycle +; CHECK-NEXT: i32* @test2_a +; CHECK-NEXT: Aliases cannot form a cycle +; CHECK-NEXT: i32* @test2_b + + +@test3_a = global i32 42 +@test3_b = alias weak i32* @test3_a +@test3_c = alias i32* @test3_b +; CHECK: Alias cannot point to a weak alias +; CHECK-NEXT: i32* @test3_c diff --git a/test/Verifier/bitcast-alias-address-space.ll b/test/Verifier/bitcast-alias-address-space.ll new file mode 100644 index 0000000000..d9794d9e33 --- /dev/null +++ b/test/Verifier/bitcast-alias-address-space.ll @@ -0,0 +1,10 @@ +; RUN: not llvm-as -disable-output %s 2>&1 | FileCheck %s + +; CHECK: error: invalid cast opcode for cast from 'i32 addrspace(2)*' to 'i32 addrspace(1)*' + +target datalayout = "e-p:32:32:32-p1:16:16:16-p2:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n8:16:32" + + +@data = addrspace(2) global i32 27 + +@illegal_alias_data = alias bitcast (i32 addrspace(2)* @data to i32 addrspace(1)*) |