2009-09-11 08:04:14 +08:00
|
|
|
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
|
|
|
|
|
|
|
|
; Verify that over-indexed getelementptrs are folded.
|
|
|
|
@A = external global [2 x [3 x [5 x [7 x i32]]]]
|
|
|
|
@B = global i32* getelementptr ([2 x [3 x [5 x [7 x i32]]]]* @A, i64 0, i64 0, i64 2, i64 1, i64 7523)
|
2010-09-03 06:35:33 +08:00
|
|
|
; CHECK: @B = global i32* getelementptr ([2 x [3 x [5 x [7 x i32]]]]* @A, i64 36, i64 0, i64 1, i64 0, i64 5)
|
2009-09-11 08:04:14 +08:00
|
|
|
@C = global i32* getelementptr ([2 x [3 x [5 x [7 x i32]]]]* @A, i64 3, i64 2, i64 0, i64 0, i64 7523)
|
2010-09-03 06:35:33 +08:00
|
|
|
; CHECK: @C = global i32* getelementptr ([2 x [3 x [5 x [7 x i32]]]]* @A, i64 39, i64 1, i64 1, i64 4, i64 5)
|
2009-04-26 06:20:49 +08:00
|
|
|
|
2012-11-13 20:59:33 +08:00
|
|
|
; Verify that i16 indices work.
|
2009-04-26 06:20:49 +08:00
|
|
|
@x = external global {i32, i32}
|
Land the long talked about "type system rewrite" patch. This
patch brings numerous advantages to LLVM. One way to look at it
is through diffstat:
109 files changed, 3005 insertions(+), 5906 deletions(-)
Removing almost 3K lines of code is a good thing. Other advantages
include:
1. Value::getType() is a simple load that can be CSE'd, not a mutating
union-find operation.
2. Types a uniqued and never move once created, defining away PATypeHolder.
3. Structs can be "named" now, and their name is part of the identity that
uniques them. This means that the compiler doesn't merge them structurally
which makes the IR much less confusing.
4. Now that there is no way to get a cycle in a type graph without a named
struct type, "upreferences" go away.
5. Type refinement is completely gone, which should make LTO much MUCH faster
in some common cases with C++ code.
6. Types are now generally immutable, so we can use "Type *" instead
"const Type *" everywhere.
Downsides of this patch are that it removes some functions from the C API,
so people using those will have to upgrade to (not yet added) new API.
"LLVM 3.0" is the right time to do this.
There are still some cleanups pending after this, this patch is large enough
as-is.
llvm-svn: 134829
2011-07-10 01:41:24 +08:00
|
|
|
@y = global i32* getelementptr ({ i32, i32 }* @x, i16 42, i32 0)
|
|
|
|
; CHECK: @y = global i32* getelementptr ({ i32, i32 }* @x, i16 42, i32 0)
|
2009-04-26 06:20:49 +08:00
|
|
|
|
2012-11-13 20:59:33 +08:00
|
|
|
; See if i92 indices work too.
|
2009-04-26 06:20:49 +08:00
|
|
|
define i32 *@test({i32, i32}* %t, i92 %n) {
|
2009-09-11 08:04:14 +08:00
|
|
|
; CHECK: @test
|
Land the long talked about "type system rewrite" patch. This
patch brings numerous advantages to LLVM. One way to look at it
is through diffstat:
109 files changed, 3005 insertions(+), 5906 deletions(-)
Removing almost 3K lines of code is a good thing. Other advantages
include:
1. Value::getType() is a simple load that can be CSE'd, not a mutating
union-find operation.
2. Types a uniqued and never move once created, defining away PATypeHolder.
3. Structs can be "named" now, and their name is part of the identity that
uniques them. This means that the compiler doesn't merge them structurally
which makes the IR much less confusing.
4. Now that there is no way to get a cycle in a type graph without a named
struct type, "upreferences" go away.
5. Type refinement is completely gone, which should make LTO much MUCH faster
in some common cases with C++ code.
6. Types are now generally immutable, so we can use "Type *" instead
"const Type *" everywhere.
Downsides of this patch are that it removes some functions from the C API,
so people using those will have to upgrade to (not yet added) new API.
"LLVM 3.0" is the right time to do this.
There are still some cleanups pending after this, this patch is large enough
as-is.
llvm-svn: 134829
2011-07-10 01:41:24 +08:00
|
|
|
; CHECK: %B = getelementptr { i32, i32 }* %t, i92 %n, i32 0
|
2009-04-26 06:20:49 +08:00
|
|
|
%B = getelementptr {i32, i32}* %t, i92 %n, i32 0
|
|
|
|
ret i32* %B
|
|
|
|
}
|
|
|
|
|
2012-11-13 20:59:33 +08:00
|
|
|
; Verify that constant expression vector GEPs work.
|
|
|
|
|
|
|
|
@z = global <2 x i32*> getelementptr (<2 x [3 x {i32, i32}]*> zeroinitializer, <2 x i32> <i32 1, i32 2>, <2 x i32> <i32 2, i32 3>, <2 x i32> <i32 1, i32 1>)
|
|
|
|
|
|
|
|
; Verify that struct GEP works with a vector of pointers.
|
|
|
|
define <2 x i32*> @test7(<2 x {i32, i32}*> %a) {
|
|
|
|
%w = getelementptr <2 x {i32, i32}*> %a, <2 x i32> <i32 5, i32 9>, <2 x i32> zeroinitializer
|
|
|
|
ret <2 x i32*> %w
|
|
|
|
}
|
|
|
|
|
|
|
|
; Verify that array GEP works with a vector of pointers.
|
|
|
|
define <2 x i8*> @test8(<2 x [2 x i8]*> %a) {
|
|
|
|
%w = getelementptr <2 x [2 x i8]*> %a, <2 x i32> <i32 0, i32 0>, <2 x i8> <i8 0, i8 1>
|
|
|
|
ret <2 x i8*> %w
|
|
|
|
}
|