aboutsummaryrefslogtreecommitdiffstats
path: root/test/Instrumentation/BoundsChecking
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-04-23 16:57:46 -0700
committerStephen Hines <srhines@google.com>2014-04-24 15:53:16 -0700
commit36b56886974eae4f9c5ebc96befd3e7bfe5de338 (patch)
treee6cfb69fbbd937f450eeb83bfb83b9da3b01275a /test/Instrumentation/BoundsChecking
parent69a8640022b04415ae9fac62f8ab090601d8f889 (diff)
downloadexternal_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.zip
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.gz
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.bz2
Update to LLVM 3.5a.
Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
Diffstat (limited to 'test/Instrumentation/BoundsChecking')
-rw-r--r--test/Instrumentation/BoundsChecking/phi.ll55
-rw-r--r--test/Instrumentation/BoundsChecking/simple.ll24
2 files changed, 77 insertions, 2 deletions
diff --git a/test/Instrumentation/BoundsChecking/phi.ll b/test/Instrumentation/BoundsChecking/phi.ll
index 86b5922..0f9d1b0 100644
--- a/test/Instrumentation/BoundsChecking/phi.ll
+++ b/test/Instrumentation/BoundsChecking/phi.ll
@@ -1,5 +1,5 @@
; RUN: opt < %s -bounds-checking -S | FileCheck %s
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+target datalayout = "e-p:64:64:64-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
@global = private unnamed_addr constant [10 x i8] c"ola\00mundo\00", align 1
@@ -50,3 +50,56 @@ while.body.i:
fn.exit:
ret void
}
+
+
+@global_as1 = private addrspace(1) unnamed_addr constant [10 x i8] c"ola\00mundo\00", align 1
+
+define void @f1_as1(i8 addrspace(1)* nocapture %c) {
+; CHECK: @f1_as1
+; no checks are possible here
+; CHECK-NOT: trap
+; CHECK: add i16 undef, -1
+; CHECK-NOT: trap
+entry:
+ %0 = load i8 addrspace(1)* %c, align 1
+ %tobool1 = icmp eq i8 %0, 0
+ br i1 %tobool1, label %while.end, label %while.body
+
+while.body:
+ %c.addr.02 = phi i8 addrspace(1)* [ %incdec.ptr, %while.body ], [ %c, %entry ]
+ %incdec.ptr = getelementptr inbounds i8 addrspace(1)* %c.addr.02, i64 -1
+ store i8 100, i8 addrspace(1)* %c.addr.02, align 1
+ %1 = load i8 addrspace(1)* %incdec.ptr, align 1
+ %tobool = icmp eq i8 %1, 0
+ br i1 %tobool, label %while.end, label %while.body
+
+while.end:
+ ret void
+}
+
+
+define void @f2_as1() {
+; CHECK: @f2_as1
+while.body.i.preheader:
+ %addr = getelementptr inbounds [10 x i8] addrspace(1)* @global_as1, i16 0, i16 9
+ br label %while.body.i
+
+while.body.i:
+; CHECK: phi
+; CHECK-NEXT: phi
+; CHECK-NOT: phi
+ %c.addr.02.i = phi i8 addrspace(1)* [ %incdec.ptr.i, %while.body.i ], [ %addr, %while.body.i.preheader ]
+ %incdec.ptr.i = getelementptr inbounds i8 addrspace(1)* %c.addr.02.i, i16 -1
+; CHECK: sub i16 10, %0
+; CHECK-NEXT: icmp ult i16 10, %0
+; CHECK-NEXT: icmp ult i16 {{.*}}, 1
+; CHECK-NEXT: or i1
+; CHECK-NEXT: br {{.*}}, label %trap
+ store i8 100, i8 addrspace(1)* %c.addr.02.i, align 1
+ %0 = load i8 addrspace(1)* %incdec.ptr.i, align 1
+ %tobool.i = icmp eq i8 %0, 0
+ br i1 %tobool.i, label %fn.exit, label %while.body.i
+
+fn.exit:
+ ret void
+}
diff --git a/test/Instrumentation/BoundsChecking/simple.ll b/test/Instrumentation/BoundsChecking/simple.ll
index 72b58f4..ddacf6d 100644
--- a/test/Instrumentation/BoundsChecking/simple.ll
+++ b/test/Instrumentation/BoundsChecking/simple.ll
@@ -1,8 +1,11 @@
; RUN: opt < %s -bounds-checking -S | FileCheck %s
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+target datalayout = "e-p:64:64:64-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
@.str = private constant [8 x i8] c"abcdefg\00" ; <[8 x i8]*>
+@.str_as1 = private addrspace(1) constant [8 x i8] c"abcdefg\00" ; <[8 x i8] addrspace(1)*>
+
+
declare noalias i8* @malloc(i64) nounwind
declare noalias i8* @calloc(i64, i64) nounwind
declare noalias i8* @realloc(i8* nocapture, i64) nounwind
@@ -60,6 +63,16 @@ define void @f5(i64 %x) nounwind {
ret void
}
+define void @f5_as1(i64 %x) nounwind {
+; CHECK: @f5_as1
+ %idx = getelementptr inbounds [8 x i8] addrspace(1)* @.str_as1, i64 0, i64 %x
+ ; CHECK: sub i16
+ ; CHECK icmp ult i16
+; CHECK: trap
+ %1 = load i8 addrspace(1)* %idx, align 4
+ ret void
+}
+
; CHECK: @f6
define void @f6(i64 %x) nounwind {
%1 = alloca i128
@@ -117,6 +130,15 @@ define void @f11(i128* byval %x) nounwind {
ret void
}
+; CHECK: @f11_as1
+define void @f11_as1(i128 addrspace(1)* byval %x) nounwind {
+ %1 = bitcast i128 addrspace(1)* %x to i8 addrspace(1)*
+ %2 = getelementptr inbounds i8 addrspace(1)* %1, i16 16
+; CHECK: br label
+ %3 = load i8 addrspace(1)* %2, align 4
+ ret void
+}
+
; CHECK: @f12
define i64 @f12(i64 %x, i64 %y) nounwind {
%1 = tail call i8* @calloc(i64 1, i64 %x)