Skip to content

[mono] LLVM ImplicitNullChecks crash #47026

Open
@imhameed

Description

@imhameed

dotnet/llvm-project#89 works around this. See #46817 (comment).

Current (not completely minimized) test IR:

This successfully compiles (https://godbolt.org/z/dvrqG8):

@aotconst_sflda_22 = internal unnamed_addr global i64* null, align 8
@aotconst_sflda_23 = internal unnamed_addr global i64* null, align 8

define void @testfunc(i32 %branchguy, i64 * %dst) {
  %1 = icmp eq i32 %branchguy, 1

  %isnull = icmp eq i64 * %dst, null
  br i1 %isnull, label %EX_BB0, label %NOEX_BB0, !make.implicit !0

NOEX_BB0:
  %dst1 = bitcast i64 * %dst to i32 *
  store i32 0, i32 *%dst1, align 4

  %.val = load i64**, i64*** bitcast (i64** @aotconst_sflda_22 to i64***), align 8
  %.val4 = load i64**, i64*** bitcast (i64** @aotconst_sflda_23 to i64***), align 8
  %.in = select i1 %1, i64** %.val, i64** %.val4
  %2 = load i64*, i64** %.in, align 8

  %is_2_null = icmp eq i64 * %2, null
  br i1 %is_2_null, label %EX_BB1, label %NOEX_BB1, !make.implicit !0

EX_BB0:
  ret void

NOEX_BB1:
  store i32 0, i32 * %dst1, align 4
  ret void

EX_BB1:
  ret void
}

!0 = !{}

This will make llc crash (https://godbolt.org/z/8sq6hd):

@aotconst_sflda_22 = internal unnamed_addr global i64* null, align 8
@aotconst_sflda_23 = internal unnamed_addr global i64* null, align 8

define void @testfunc(i32 %branchguy, i64 * %dst) {
  %1 = icmp eq i32 %branchguy, 1

  %.val = load i64**, i64*** bitcast (i64** @aotconst_sflda_22 to i64***), align 8
  %.val4 = load i64**, i64*** bitcast (i64** @aotconst_sflda_23 to i64***), align 8
  %.in = select i1 %1, i64** %.val, i64** %.val4
  %2 = load i64*, i64** %.in, align 8

  %isnull = icmp eq i64 * %dst, null
  br i1 %isnull, label %EX_BB0, label %NOEX_BB0, !make.implicit !0

NOEX_BB0:
  %dst1 = bitcast i64 * %dst to i32 *
  store i32 0, i32 *%dst1, align 4

  %is_2_null = icmp eq i64 * %2, null
  br i1 %is_2_null, label %EX_BB1, label %NOEX_BB1, !make.implicit !0

EX_BB0:
  ret void

NOEX_BB1:
  store i32 0, i32 * %dst1, align 4
  ret void

EX_BB1:
  ret void
}

!0 = !{}

Build with -march=x86-64 -mcpu=generic -enable-implicit-null-checks -filetype=obj.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions