diff options
author | Hans Wennborg <hans@hanshq.net> | 2018-08-08 13:14:57 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2018-08-08 13:14:57 +0000 |
commit | f208a0a1daa9526563817e0f8da6b303b82b8e1d (patch) | |
tree | 80ad449dff80058469a3389e7e18910d9fbcde78 /test/Instrumentation/BoundsChecking/many-traps-2.ll | |
parent | 62ca9ef3b9aff92f53de29cb74429f58d4201c82 (diff) |
Merging r338902:
------------------------------------------------------------------------
r338902 | jgalenson | 2018-08-03 19:12:23 +0200 (Fri, 03 Aug 2018) | 5 lines
Fix crash in bounds checking.
In r337830 I added SCEV checks to enable us to insert fewer bounds checks. Unfortunately, this sometimes crashes when multiple bounds checks are added due to SCEV caching issues. This patch splits the bounds checking pass into two phases, one that computes all the conditions (using SCEV checks) and the other that adds the new instructions.
Differential Revision: https://reviews.llvm.org/D49946
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_70@339239 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Instrumentation/BoundsChecking/many-traps-2.ll')
-rw-r--r-- | test/Instrumentation/BoundsChecking/many-traps-2.ll | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/test/Instrumentation/BoundsChecking/many-traps-2.ll b/test/Instrumentation/BoundsChecking/many-traps-2.ll new file mode 100644 index 00000000000..a6e99586af2 --- /dev/null +++ b/test/Instrumentation/BoundsChecking/many-traps-2.ll @@ -0,0 +1,65 @@ +; RUN: opt < %s -bounds-checking -S | FileCheck %s +@array = internal global [1819 x i16] zeroinitializer, section ".bss,bss" +@offsets = external dso_local global [10 x i16] + +; CHECK-LABEL: @test +define dso_local void @test() { +bb1: + br label %bb19 + +bb20: + %_tmp819 = load i16, i16* null +; CHECK: br {{.*}} %trap + %_tmp820 = sub nsw i16 9, %_tmp819 + %_tmp821 = sext i16 %_tmp820 to i64 + %_tmp822 = getelementptr [10 x i16], [10 x i16]* @offsets, i16 0, i64 %_tmp821 + %_tmp823 = load i16, i16* %_tmp822 + br label %bb33 + +bb34: + %_tmp907 = zext i16 %i__7.107.0 to i64 + %_tmp908 = getelementptr [1819 x i16], [1819 x i16]* @array, i16 0, i64 %_tmp907 + store i16 0, i16* %_tmp908 +; CHECK: br {{.*}} %trap + %_tmp910 = add i16 %i__7.107.0, 1 + br label %bb33 + +bb33: + %i__7.107.0 = phi i16 [ undef, %bb20 ], [ %_tmp910, %bb34 ] + %_tmp913 = add i16 %_tmp823, 191 + %_tmp914 = icmp ult i16 %i__7.107.0, %_tmp913 + br i1 %_tmp914, label %bb34, label %bb19 + +bb19: + %_tmp976 = icmp slt i16 0, 10 + br i1 %_tmp976, label %bb20, label %bb39 + +bb39: + ret void +} + +@e = dso_local local_unnamed_addr global [1 x i16] zeroinitializer, align 1 + +; CHECK-LABEL: @test2 +define dso_local void @test2() local_unnamed_addr { +entry: + br label %while.cond1.preheader + +while.cond1.preheader: + %0 = phi i16 [ undef, %entry ], [ %inc, %while.end ] + %1 = load i16, i16* undef, align 1 +; CHECK: br {{.*}} %trap + br label %while.end + +while.end: + %inc = add nsw i16 %0, 1 + %arrayidx = getelementptr inbounds [1 x i16], [1 x i16]* @e, i16 0, i16 + %0 + %2 = load i16, i16* %arrayidx, align 1 +; CHECK: or i1 +; CHECK-NEXT: br {{.*}} %trap + br i1 false, label %while.end6, label %while.cond1.preheader + +while.end6: + ret void +} |