diff options
author | Shih-wei Liao <sliao@google.com> | 2010-04-28 01:47:00 -0700 |
---|---|---|
committer | Shih-wei Liao <sliao@google.com> | 2010-04-28 01:47:00 -0700 |
commit | 7abe37e4aee38cc79d91dd069a37d7e91d5bef53 (patch) | |
tree | c13b26fc3d8909240f981988535c0b82dd9bf37c /test/Other | |
parent | 6037a7c3c97b651dd70e48ebe5453134713971ed (diff) | |
download | external_llvm-7abe37e4aee38cc79d91dd069a37d7e91d5bef53.zip external_llvm-7abe37e4aee38cc79d91dd069a37d7e91d5bef53.tar.gz external_llvm-7abe37e4aee38cc79d91dd069a37d7e91d5bef53.tar.bz2 |
Sync upstream to r102410.
Re-turn on sdk.
Change-Id: I91a890863989a67243b4d2dfd1ae09b843ebaeaf
Diffstat (limited to 'test/Other')
-rw-r--r-- | test/Other/constant-fold-gep.ll | 43 | ||||
-rw-r--r-- | test/Other/lint.ll | 66 |
2 files changed, 103 insertions, 6 deletions
diff --git a/test/Other/constant-fold-gep.ll b/test/Other/constant-fold-gep.ll index 5358e1f..ecef9c4 100644 --- a/test/Other/constant-fold-gep.ll +++ b/test/Other/constant-fold-gep.ll @@ -21,10 +21,12 @@ ; PLAIN: %1 = type { double, float, double, double } ; PLAIN: %2 = type { i1, i1* } ; PLAIN: %3 = type { i64, i64 } +; PLAIN: %4 = type { i32, i32 } ; OPT: %0 = type { i1, double } ; OPT: %1 = type { double, float, double, double } ; OPT: %2 = type { i1, i1* } ; OPT: %3 = type { i64, i64 } +; OPT: %4 = type { i32, i32 } ; The automatic constant folder in opt does not have targetdata access, so ; it can't fold gep arithmetic, in general. However, the constant folder run @@ -118,9 +120,19 @@ ; TO: @N = constant i64* inttoptr (i64 8 to i64*) ; TO: @O = constant i64* inttoptr (i64 8 to i64*) -@M = constant i64* getelementptr (i64 *null, i32 1) -@N = constant i64* getelementptr ({ i64, i64 } *null, i32 0, i32 1) -@O = constant i64* getelementptr ([2 x i64] *null, i32 0, i32 1) +@M = constant i64* getelementptr (i64* null, i32 1) +@N = constant i64* getelementptr ({ i64, i64 }* null, i32 0, i32 1) +@O = constant i64* getelementptr ([2 x i64]* null, i32 0, i32 1) + +; Fold GEP of a GEP. Theoretically some of these cases could be folded +; without using targetdata, however that's not implemented yet. + +; PLAIN: @Z = global i32* getelementptr inbounds (i32* getelementptr inbounds ([3 x %4]* @ext, i64 0, i64 1, i32 0), i64 1) +; OPT: @Z = global i32* getelementptr (i32* getelementptr inbounds ([3 x %4]* @ext, i64 0, i64 1, i32 0), i64 1) +; TO: @Z = global i32* getelementptr inbounds ([3 x %0]* @ext, i64 0, i64 1, i32 1) + +@ext = external global [3 x { i32, i32 }] +@Z = global i32* getelementptr inbounds (i32* getelementptr inbounds ([3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 0), i64 1) ; Duplicate all of the above as function return values rather than ; global initializers. @@ -457,14 +469,33 @@ define i64 @fk() nounwind { ; SCEV: --> sizeof(i64) define i64* @fM() nounwind { - %t = bitcast i64* getelementptr (i64 *null, i32 1) to i64* + %t = bitcast i64* getelementptr (i64* null, i32 1) to i64* ret i64* %t } define i64* @fN() nounwind { - %t = bitcast i64* getelementptr ({ i64, i64 } *null, i32 0, i32 1) to i64* + %t = bitcast i64* getelementptr ({ i64, i64 }* null, i32 0, i32 1) to i64* ret i64* %t } define i64* @fO() nounwind { - %t = bitcast i64* getelementptr ([2 x i64] *null, i32 0, i32 1) to i64* + %t = bitcast i64* getelementptr ([2 x i64]* null, i32 0, i32 1) to i64* ret i64* %t } + +; PLAIN: define i32* @fZ() nounwind { +; PLAIN: %t = bitcast i32* getelementptr inbounds (i32* getelementptr inbounds ([3 x %4]* @ext, i64 0, i64 1, i32 0), i64 1) to i32* +; PLAIN: ret i32* %t +; PLAIN: } +; OPT: define i32* @fZ() nounwind { +; OPT: ret i32* getelementptr inbounds (i32* getelementptr inbounds ([3 x %4]* @ext, i64 0, i64 1, i32 0), i64 1) +; OPT: } +; TO: define i32* @fZ() nounwind { +; TO: ret i32* getelementptr inbounds ([3 x %0]* @ext, i64 0, i64 1, i32 1) +; TO: } +; SCEV: Classifying expressions for: @fZ +; SCEV: %t = bitcast i32* getelementptr inbounds (i32* getelementptr inbounds ([3 x %4]* @ext, i64 0, i64 1, i32 0), i64 1) to i32* +; SCEV: --> ((3 * sizeof(i32)) + @ext) + +define i32* @fZ() nounwind { + %t = bitcast i32* getelementptr inbounds (i32* getelementptr inbounds ([3 x { i32, i32 }]* @ext, i64 0, i64 1, i32 0), i64 1) to i32* + ret i32* %t +} diff --git a/test/Other/lint.ll b/test/Other/lint.ll new file mode 100644 index 0000000..8658495 --- /dev/null +++ b/test/Other/lint.ll @@ -0,0 +1,66 @@ +; RUN: opt -lint -disable-output < %s |& FileCheck %s +target datalayout = "e-p:64:64:64" + +declare fastcc void @bar() + +define i32 @foo() noreturn { +; CHECK: Caller and callee calling convention differ + call void @bar() +; CHECK: Null pointer dereference + store i32 0, i32* null +; CHECK: Null pointer dereference + %t = load i32* null +; CHECK: Undef pointer dereference + store i32 0, i32* undef +; CHECK: Undef pointer dereference + %u = load i32* undef +; CHECK: Memory reference address is misaligned + %x = inttoptr i32 1 to i32* + load i32* %x, align 4 +; CHECK: Division by zero + %sd = sdiv i32 2, 0 +; CHECK: Division by zero + %ud = udiv i32 2, 0 +; CHECK: Division by zero + %sr = srem i32 2, 0 +; CHECK: Division by zero + %ur = urem i32 2, 0 +; CHECK: extractelement index out of range + %ee = extractelement <4 x i32> zeroinitializer, i32 4 +; CHECK: insertelement index out of range + %ie = insertelement <4 x i32> zeroinitializer, i32 0, i32 4 +; CHECK: Shift count out of range + %r = lshr i32 0, 32 +; CHECK: Shift count out of range + %q = ashr i32 0, 32 +; CHECK: Shift count out of range + %l = shl i32 0, 32 +; CHECK: xor(undef, undef) + %xx = xor i32 undef, undef +; CHECK: sub(undef, undef) + %xs = sub i32 undef, undef + br label %next + +next: +; CHECK: Static alloca outside of entry block + %a = alloca i32 +; CHECK: Return statement in function with noreturn attribute + ret i32 0 + +foo: + %z = add i32 0, 0 +; CHECK: unreachable immediately preceded by instruction without side effects + unreachable +} + +; CHECK: Unnamed function with non-local linkage +define void @0() nounwind { + ret void +} + +; CHECK: va_start called in a non-varargs function +declare void @llvm.va_start(i8*) +define void @not_vararg(i8* %p) nounwind { + call void @llvm.va_start(i8* %p) + ret void +} |