[PATCH] D25848: [PM/OptBisect] Don't crash with some particular values of -opt-bisect-limit=

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 5 07:18:58 PST 2016


davide added a comment.

In https://reviews.llvm.org/D25848#579195, @andrew.w.kaylor wrote:

> I'm trying to understand where the data structured entry gets removed when the pass is not skipped.  I tried downloading the reproducer from the PR you mentioned, but I can't seem to get this to happen with that file and the command line you listed above.  I have seen this problem before, but I'm having trouble making it happen now.
>
> Can you send me the .ll file you are using and the LLVM version number you built with?


I completely missed your comment. This still hits an assertion on trunk @r288671.
To reproduce, just run

  $ ./opt unopt.ll -opt-bisect-limit=53 -O3

on the following testcase:

  @d = global i32 1, align 4
  @e = common global i32 0, align 4
  @c = common global i32 0, align 4
  @b = common global i32 0, align 4
  @a = common global i32 0, align 4
  @.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
  define void @fn1() {
    %i = alloca i16, align 2
    %f = alloca i32, align 4
    store i32 53, i32* %f, align 4
    br label %for.cond
  for.cond:                                         ; preds = %for.cond1, %0
    br label %for.cond1
  for.cond1:                                        ; preds = %for.end, %for.cond
    %dec12.sink = phi i32 [ 0, %for.end ], [ 1, %for.cond ]
    store i32 %dec12.sink, i32* @c, align 4
    %tmp = load i32, i32* @c, align 4
    %tobool = icmp ne i32 %tmp, 0
    br i1 %tobool, label %for.body, label %for.cond
  for.body:                                         ; preds = %for.cond1
    %tmp1 = load i32, i32* %f, align 4
    %cmp = icmp sgt i32 %tmp1, 1
    %tmp2 = load i32, i32* %f, align 4
    %shr = ashr i32 1, %tmp2
    %cond = select i1 %cmp, i32 1, i32 %shr
    %conv = trunc i32 %cond to i16
    store i16 %conv, i16* %i, align 2
    %tmp3 = load i16, i16* %i, align 2
    %conv2 = zext i16 %tmp3 to i32
    %tmp4 = load i32, i32* @c, align 4
    %cmp3 = icmp eq i32 %conv2, %tmp4
    %conv4 = zext i1 %cmp3 to i32
    store i32 %conv4, i32* @b, align 4
    store i32 0, i32* %f, align 4
    store i32 1, i32* @a, align 4
    br label %for.cond5
  for.cond5:                                        ; preds = %if.end, %for.body
    %tmp5 = load i32, i32* @a, align 4
    %tobool6 = icmp ne i32 %tmp5, 0
    br i1 %tobool6, label %for.body7, label %for.end
  for.body7:                                        ; preds = %for.cond5
    %tmp6 = load i32, i32* @e, align 4
    %tobool8 = icmp ne i32 %tmp6, 0
    br i1 %tobool8, label %if.then, label %if.end
  if.then:                                          ; preds = %for.body7
    store i32 0, i32* @a, align 4
    br label %if.end
  if.end:                                           ; preds = %if.then, %for.body7
    %tmp8 = load i32, i32* @d, align 4
    %tobool9 = icmp ne i32 %tmp8, 0
    br i1 %tobool9, label %if.then10, label %for.cond5
  if.then10:                                        ; preds = %if.end
    ret void
  for.end:                                          ; preds = %for.cond5
    br label %for.cond1
  }
  define void @main() {
    call void @fn1()
    %tmp = load i32, i32* @b, align 4
    call void (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %tmp)
    ret void
  }
  declare void @printf(i8*, ...)


https://reviews.llvm.org/D25848





More information about the llvm-commits mailing list