Skip to content

LLVM15 does not like our calling convention scheme #45057

Closed
@Keno

Description

On LLVM15, during bootstrap, LLVM turns the following:

@MUL.CoreDOT.nothing20 = external dso_local global ptr
@MUL.CoreDOT.typeassert104 = external dso_local global ptr
@MUL.CoreDOT.tuple268 = external dso_local global ptr
@SUM.CoreDOT.String59 = external dso_local global ptr
@MUL.CoreDOT.String58 = external dso_local global ptr
@MUL.MainDOT.BaseDOT.print_to_string2339 = external dso_local global ptr
@jl_globalYY.2469 = external dso_local global ptr
@MUL.MainDOT.BaseDOT.SysDOT.BINDIR5428 = external dso_local global ptr
@MUL.MainDOT.BaseDOT.FilesystemDOT.joinpath3906 = external dso_local global ptr
@MUL.MainDOT.BaseDOT.FilesystemDOT.abspath4476 = external dso_local global ptr
@MUL.MainDOT.BaseDOT.SysDOT.STDLIB5135 = external dso_local global ptr
@jl_globalYY.5429 = external dso_local global ptr
@jl_globalYY.4888 = external dso_local global ptr
@jl_globalYY.5430 = external dso_local global ptr
@jl_globalYY.4890 = external dso_local global ptr
@jl_globalYY.5431 = external dso_local global ptr
@jl_globalYY.5432 = external dso_local global ptr
@jl_globalYY.5433 = external dso_local global ptr
@jl_globalYY.5434 = external dso_local global ptr
@_j_str7 = external dso_local constant [11 x i8]
@jlplt_ijl_get_julia_bindir_28472_got = external dso_local global ptr

declare ptr @julia.get_pgcstack()

; Function Attrs: cold noreturn nounwind
declare void @llvm.trap() #0

declare void @ijl_type_error()

declare ptr addrspace(10) @julia.typeof(ptr addrspace(10))

declare void @julia.write_barrier_binding(ptr addrspace(10), ...)

; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
declare i32 @llvm.bswap.i32(i32) #1

define internal ptr addrspace(10) @japi1_print_to_string_32888() {
after_throw24:
  ret ptr addrspace(10) null
}

declare ptr addrspace(10) @julia_joinpath_24652()

define internal void @julia___init_build_28469(ptr %jlplt_ijl_get_julia_bindir_28472_got, ptr %SUM.CoreDOT.String59, ptr %0, ptr addrspace(10) %1, i1 %2, ptr %MUL.MainDOT.BaseDOT.SysDOT.BINDIR5428, ptr %3, ptr addrspace(10) %4, ptr %jl_globalYY.2469, ptr %5, ptr %jl_globalYY.5429, ptr %6, ptr %jl_globalYY.4888, ptr %7, ptr %jl_globalYY.5430, ptr %8, ptr %jl_globalYY.4890, ptr %9) {
top:
  %10 = call ptr @julia.get_pgcstack()
  %11 = load atomic ptr, ptr %jlplt_ijl_get_julia_bindir_28472_got unordered, align 8
  %12 = call ptr addrspace(10) %11()
  %13 = load ptr, ptr %jlplt_ijl_get_julia_bindir_28472_got, align 8
  %14 = addrspacecast ptr %jlplt_ijl_get_julia_bindir_28472_got to ptr addrspace(10)
  %15 = call ptr addrspace(10) @julia.typeof(ptr addrspace(10) null)
  %16 = icmp eq ptr addrspace(10) null, %1
  br i1 %2, label %pass, label %fail

fail:                                             ; preds = %top
  call void @ijl_type_error()
  unreachable

pass:                                             ; preds = %top
  %17 = load ptr, ptr %jlplt_ijl_get_julia_bindir_28472_got, align 8
  %18 = addrspacecast ptr %jlplt_ijl_get_julia_bindir_28472_got to ptr addrspace(10)
  call void (ptr addrspace(10), ...) @julia.write_barrier_binding(ptr addrspace(10) null, ptr addrspace(10) %1)
  %19 = load ptr, ptr %jlplt_ijl_get_julia_bindir_28472_got, align 8
  %20 = addrspacecast ptr %jlplt_ijl_get_julia_bindir_28472_got to ptr addrspace(10)
  %21 = load ptr, ptr %jlplt_ijl_get_julia_bindir_28472_got, align 8
  %22 = addrspacecast ptr %jlplt_ijl_get_julia_bindir_28472_got to ptr addrspace(10)
  %23 = load ptr, ptr %jlplt_ijl_get_julia_bindir_28472_got, align 8
  %24 = addrspacecast ptr %jlplt_ijl_get_julia_bindir_28472_got to ptr addrspace(10)
  %25 = load ptr, ptr %jlplt_ijl_get_julia_bindir_28472_got, align 8
  %26 = addrspacecast ptr %jlplt_ijl_get_julia_bindir_28472_got to ptr addrspace(10)
  %27 = load ptr, ptr %jlplt_ijl_get_julia_bindir_28472_got, align 8
  %28 = addrspacecast ptr %jlplt_ijl_get_julia_bindir_28472_got to ptr addrspace(10)
  %29 = call cc37 ptr addrspace(10) @japi1_print_to_string_32888(ptr addrspace(10) null, ptr addrspace(10) null, ptr addrspace(10) null, ptr addrspace(10) null, ptr addrspace(10) null)
  ret void
}

declare ptr addrspace(10) @julia_abspath_24603()

attributes #0 = { cold noreturn nounwind }
attributes #1 = { nocallback nofree nosync nounwind readnone speculatable willreturn }

into

pass:                                             ; preds = %top
  call void (ptr addrspace(10), ...) @julia.write_barrier_binding(ptr addrspace(10) null, ptr addrspace(10) %1)
  store i1 true, ptr undef, align 1
  ret void

The reason for that is this instcombine code that makes cc mismatches unreachable behavior:

https://github.com/llvm/llvm-project/blob/0c090dcc8a97a07bb3b3d2f64dbd1abf3990c1c6/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp#L2897-L2924

That code is not new in LLVM15, so I don't know what triggered this to start happening now.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    compiler:llvmFor issues that relate to LLVM

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions