From 13e71ce69319d7acdd0e8d57b31c09545d9f2a45 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Thu, 19 Sep 2019 16:31:17 +0000 Subject: [Float2Int] avoid crashing on unreachable code (PR38502) In the example from: https://bugs.llvm.org/show_bug.cgi?id=38502 ...we hit infinite looping/crashing because we have non-standard IR - an instruction operand is used before defined. This and other unusual constructs are allowed in unreachable blocks, so avoid the problem by using DominatorTree to step around landmines. Differential Revision: https://reviews.llvm.org/D67766 llvm-svn: 372339 --- llvm/test/Transforms/Float2Int/basic.ll | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'llvm/test/Transforms/Float2Int/basic.ll') diff --git a/llvm/test/Transforms/Float2Int/basic.ll b/llvm/test/Transforms/Float2Int/basic.ll index ad522154eed..615cc601a92 100644 --- a/llvm/test/Transforms/Float2Int/basic.ll +++ b/llvm/test/Transforms/Float2Int/basic.ll @@ -328,3 +328,25 @@ define <4 x i16> @neg_vector(<4 x i8> %a) { %t2 = fptoui <4 x float> %t1 to <4 x i16> ret <4 x i16> %t2 } + +; Don't crash while processing unreachable (non-standard) IR. + +define void @PR38502() { +; CHECK-LABEL: @PR38502( +; CHECK-NEXT: entry: +; CHECK-NEXT: ret void +; CHECK: bogusBB: +; CHECK-NEXT: [[INC1:%.*]] = fadd double [[INC:%.*]], 1.000000e+00 +; CHECK-NEXT: [[INC]] = fadd double [[INC1]], 1.000000e+00 +; CHECK-NEXT: [[TOBOOL:%.*]] = fcmp une double [[INC]], 0.000000e+00 +; CHECK-NEXT: br label [[BOGUSBB:%.*]] +; +entry: + ret void + +bogusBB: ; preds = %bogusBB + %inc1 = fadd double %inc, 1.000000e+00 + %inc = fadd double %inc1, 1.000000e+00 + %tobool = fcmp une double %inc, 0.000000e+00 + br label %bogusBB +} -- cgit v1.2.3