Skip to content

Conversation

@vchuravy
Copy link
Member

Maybe slightly nicer-form since we now emit them regularly,
and makes them slightly easier to handle for Enzyme.

cc: @wsmoses @d-netto

@vchuravy vchuravy added GC Garbage collector backport 1.9 Change should be backported to release-1.9 compiler:llvm For issues that relate to LLVM labels Oct 30, 2022
@JeffBezanson
Copy link
Member

JIT session error: Symbols not found: [ julia.safepoint ]
JIT session error: Failed to materialize symbols: { (JuliaOJIT, { julia_dllist_7415 }) }
JIT session error: Failed to materialize symbols: { (JuliaOJIT, { julia_dllist_7415 }) }
JIT session error: Failed to materialize symbols: { (JuliaOJIT, { julia_dllist_7415 }) }
JIT session error: Failed to materialize symbols: { (JuliaOJIT, { julia_host_triplet_7284 }) }

@JeffBezanson
Copy link
Member

OK I think at least this is needed, but it's not sufficient to fix the error:

diff --git a/src/codegen_shared.h b/src/codegen_shared.h
index 0c8e92ca88..fc9cb22735 100644
--- a/src/codegen_shared.h
+++ b/src/codegen_shared.h
@@ -257,9 +257,9 @@ static inline llvm::Value *emit_gc_state_set(llvm::IRBuilder<> &builder, llvm::V
 {
     using namespace llvm;
     Type *T_int8 = state->getType();
-    ptls = emit_bitcast_with_builder(builder, ptls, builder.getInt8PtrTy());
+    llvm::Value *ptls_i8 = emit_bitcast_with_builder(builder, ptls, builder.getInt8PtrTy());
     Constant *offset = ConstantInt::getSigned(builder.getInt32Ty(), offsetof(jl_tls_states_t, gc_state));
-    Value *gc_state = builder.CreateInBoundsGEP(T_int8, ptls, ArrayRef<Value*>(offset), "gc_state");
+    Value *gc_state = builder.CreateInBoundsGEP(T_int8, ptls_i8, ArrayRef<Value*>(offset), "gc_state");
     if (old_state == nullptr) {
         old_state = builder.CreateLoad(T_int8, gc_state);
         cast<LoadInst>(old_state)->setOrdering(AtomicOrdering::Monotonic);
diff --git a/src/llvm-pass-helpers.cpp b/src/llvm-pass-helpers.cpp
index 50ba3652e1..71512df741 100644
--- a/src/llvm-pass-helpers.cpp
+++ b/src/llvm-pass-helpers.cpp
@@ -232,7 +232,7 @@ namespace jl_intrinsics {
             auto intrinsic = Function::Create(
                 FunctionType::get(
                     Type::getVoidTy(context.getLLVMContext()),
-                    {},
+                    {JuliaType::get_ppjlvalue_ty(context.getLLVMContext())},
                     false),
                 Function::ExternalLinkage,
                 SAFEPOINT_NAME);

@vchuravy
Copy link
Member Author

The error means we are not running final lowering over a function

@gbaraldi
Copy link
Member

Could we also not emit this for smallish functions? So something like sin in a hot loop doesn't synchronize every iteration?

On my computer I did some very rough testing and a function call + return takes about 1ns and the safepoint takes about 2ns so it's not nothing.

@vchuravy
Copy link
Member Author

Using JULIA_LLVM_ARGS="-debug-only=orc"

Defining MU dllist for JuliaOJIT (tracker: default)  { ("jlcapi_dl_phdr_info_callback_7427", [Callable]), ("jfptr_dllist_7420", [Callable]), ("julia_dllist_7419", [Callable]) }
Looking up { (julia_dllist_7419, RequiredSymbol) } in [ ("JuliaOJIT", MatchExportedSymbolsOnly) ] (required state: Ready)
Dispatching MaterializationUnits...
Done dispatching MaterializationUnits.
Entering OL_applyQueryPhase1:
  Lookup kind: Static
  Search order: [ ("JuliaOJIT", MatchExportedSymbolsOnly) ], Current index = 0 (entering new JITDylib)
  Lookup set: { (julia_dllist_7419, RequiredSymbol) }
  Definition generator candidates: { (julia_dllist_7419, RequiredSymbol) }
  Definition generator non-candidates: { }
Visiting "JuliaOJIT" (MatchExportedSymbolsOnly) with lookup set { (julia_dllist_7419, RequiredSymbol) }:
  First time visiting JuliaOJIT, resetting candidate sets and building generator stack
  Updating candidate set...
    Remaining candidates = { }
  No generators to run for this JITDylib.
All symbols matched.
Phase 1 succeeded.
Entering OL_completeLookup:
  Lookup kind: Static
  Search order: [ ("JuliaOJIT", MatchExportedSymbolsOnly) ], Current index = 1
  Lookup set: { (julia_dllist_7419, RequiredSymbol) }
  Definition generator candidates: { }
  Definition generator non-candidates: { }
Visiting "JuliaOJIT" (MatchExportedSymbolsOnly) with lookup set { (julia_dllist_7419, RequiredSymbol) }:
  Attempting to match "julia_dllist_7419" (RequiredSymbol)... matched, preparing to dispatch MU@0x55f7b3fcdcd0 (dllist)
Stripping unmatched weakly-referenced symbols
Query successfully lodged
Adding MUs to dispatch:
  For JuliaOJIT: Adding 1 MUs.
No dependencies to register
Dispatching MaterializationUnits...
  Dispatching "dllist"
Dispatching: Materialization task: dllist in JuliaOJIT
Emitting, for JuliaOJIT, MU@0x55f7b3fcdcd0 ("dllist", { })
In JuliaOJIT resolving { ("jlcapi_dl_phdr_info_callback_7427": 0x00007f5729e75f00 [Callable]), ("jfptr_dllist_7420": 0x00007f5729e75ee0 [Callable]), ("julia_dllist_7419": 0x00007f5729e75cd0 [Callable]) }
Looking up { (__stack_chk_fail, RequiredSymbol), (__stack_chk_guard, RequiredSymbol), (ijl_adopt_thread, RequiredSymbol), (ijl_apply_generic, RequiredSymbol), (ijl_bounds_error_ints, RequiredSymbol), (ijl_box_uint64, RequiredSymbol), (ijl_gc_pool_alloc, RequiredSymbol), (ijl_throw, RequiredSymbol), (ijl_type_error, RequiredSymbol), (jl_undefref_exception, RequiredSymbol), (jl_world_counter, RequiredSymbol), (jlplt_dl_iterate_phdr_7429_got, RequiredSymbol), (jlplt_ijl_alloc_array_1d_7079_got, RequiredSymbol), (jlplt_ijl_array_del_beg_7431_got, RequiredSymbol), (jlsys_ArgumentError_77, RequiredSymbol), (jlsys_dl_phdr_info_callback_236, RequiredSymbol), (julia.safepoint, RequiredSymbol), (julia_filter!_7433, RequiredSymbol) } in [ ("JuliaOJIT", MatchAllSymbols), ("JuliaGlobals", MatchExportedSymbolsOnly) ] (required state: Resolved)
Dispatching MaterializationUnits...
Done dispatching MaterializationUnits.
Entering OL_applyQueryPhase1:
  Lookup kind: Static
  Search order: [ ("JuliaOJIT", MatchAllSymbols), ("JuliaGlobals", MatchExportedSymbolsOnly) ], Current index = 0 (entering new JITDylib)
  Lookup set: { (__stack_chk_fail, RequiredSymbol), (__stack_chk_guard, RequiredSymbol), (ijl_adopt_thread, RequiredSymbol), (ijl_apply_generic, RequiredSymbol), (ijl_bounds_error_ints, RequiredSymbol), (ijl_box_uint64, RequiredSymbol), (ijl_gc_pool_alloc, RequiredSymbol), (ijl_throw, RequiredSymbol), (ijl_type_error, RequiredSymbol), (jl_undefref_exception, RequiredSymbol), (jl_world_counter, RequiredSymbol), (jlplt_dl_iterate_phdr_7429_got, RequiredSymbol), (jlplt_ijl_alloc_array_1d_7079_got, RequiredSymbol), (jlplt_ijl_array_del_beg_7431_got, RequiredSymbol), (jlsys_ArgumentError_77, RequiredSymbol), (jlsys_dl_phdr_info_callback_236, RequiredSymbol), (julia.safepoint, RequiredSymbol), (julia_filter!_7433, RequiredSymbol) }
  Definition generator candidates: { (__stack_chk_fail, RequiredSymbol), (__stack_chk_guard, RequiredSymbol), (ijl_adopt_thread, RequiredSymbol), (ijl_apply_generic, RequiredSymbol), (ijl_bounds_error_ints, RequiredSymbol), (ijl_box_uint64, RequiredSymbol), (ijl_gc_pool_alloc, RequiredSymbol), (ijl_throw, RequiredSymbol), (ijl_type_error, RequiredSymbol), (jl_undefref_exception, RequiredSymbol), (jl_world_counter, RequiredSymbol), (jlplt_dl_iterate_phdr_7429_got, RequiredSymbol), (jlplt_ijl_alloc_array_1d_7079_got, RequiredSymbol), (jlplt_ijl_array_del_beg_7431_got, RequiredSymbol), (jlsys_ArgumentError_77, RequiredSymbol), (jlsys_dl_phdr_info_callback_236, RequiredSymbol), (julia.safepoint, RequiredSymbol), (julia_filter!_7433, RequiredSymbol) }
  Definition generator non-candidates: { }
Visiting "JuliaOJIT" (MatchAllSymbols) with lookup set { (__stack_chk_fail, RequiredSymbol), (__stack_chk_guard, RequiredSymbol), (ijl_adopt_thread, RequiredSymbol), (ijl_apply_generic, RequiredSymbol), (ijl_bounds_error_ints, RequiredSymbol), (ijl_box_uint64, RequiredSymbol), (ijl_gc_pool_alloc, RequiredSymbol), (ijl_throw, RequiredSymbol), (ijl_type_error, RequiredSymbol), (jl_undefref_exception, RequiredSymbol), (jl_world_counter, RequiredSymbol), (jlplt_dl_iterate_phdr_7429_got, RequiredSymbol), (jlplt_ijl_alloc_array_1d_7079_got, RequiredSymbol), (jlplt_ijl_array_del_beg_7431_got, RequiredSymbol), (jlsys_ArgumentError_77, RequiredSymbol), (jlsys_dl_phdr_info_callback_236, RequiredSymbol), (julia.safepoint, RequiredSymbol), (julia_filter!_7433, RequiredSymbol) }:
  First time visiting JuliaOJIT, resetting candidate sets and building generator stack
  Updating candidate set...
    Remaining candidates = { (julia.safepoint, RequiredSymbol), (jl_undefref_exception, RequiredSymbol), (ijl_adopt_thread, RequiredSymbol), (ijl_gc_pool_alloc, RequiredSymbol) }
  No generators to run for this JITDylib.
Phase 1 moving to next JITDylib.
Visiting "JuliaGlobals" (MatchExportedSymbolsOnly) with lookup set { (__stack_chk_fail, RequiredSymbol), (__stack_chk_guard, RequiredSymbol), (ijl_adopt_thread, RequiredSymbol), (ijl_apply_generic, RequiredSymbol), (ijl_bounds_error_ints, RequiredSymbol), (ijl_box_uint64, RequiredSymbol), (ijl_gc_pool_alloc, RequiredSymbol), (ijl_throw, RequiredSymbol), (ijl_type_error, RequiredSymbol), (jl_undefref_exception, RequiredSymbol), (jl_world_counter, RequiredSymbol), (jlplt_dl_iterate_phdr_7429_got, RequiredSymbol), (jlplt_ijl_alloc_array_1d_7079_got, RequiredSymbol), (jlplt_ijl_array_del_beg_7431_got, RequiredSymbol), (jlsys_ArgumentError_77, RequiredSymbol), (jlsys_dl_phdr_info_callback_236, RequiredSymbol), (julia.safepoint, RequiredSymbol), (julia_filter!_7433, RequiredSymbol) }:
  First time visiting JuliaGlobals, resetting candidate sets and building generator stack
  Updating candidate set...
    Remaining candidates = { (julia.safepoint, RequiredSymbol), (ijl_adopt_thread, RequiredSymbol) }
  Running 2 remaining generators for 2 candidates
  Attempting to generate { (julia.safepoint, RequiredSymbol), (ijl_adopt_thread, RequiredSymbol) }
Defining MU <Absolute Symbols> for JuliaGlobals (tracker: 0x0, default will be used)
  { ("ijl_adopt_thread", [Data]) }
  Updating candidate set post-generation
  Attempting to generate { (julia.safepoint, RequiredSymbol) }
  Updating candidate set post-generation
Phase 1 moving to next JITDylib.
Phase 1 failed with unresolved symbols.
JIT session error: Symbols not found: [ julia.safepoint ]
In JuliaOJIT failing materialization for { ("jlcapi_dl_phdr_info_callback_7427", [Callable]), ("jfptr_dllist_7420", [Callable]), ("julia_dllist_7419", [Callable]) }

Looks like this is our first @cfunction? But looking at the last calls to FinalLowerGC::runFunction

(rr) p F.getParent()->dump()
; ModuleID = 'dllist'
source_filename = "dllist"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@"+Core.Array48" = private unnamed_addr constant {}* inttoptr (i64 140083731563600 to {}*), !julia.constgv !0
@jlplt_ijl_alloc_array_1d_7079_got = external global void ()*
@jl_world_counter = external global i64
@"jl_global#541" = private unnamed_addr constant {}* inttoptr (i64 140083567395392 to {}*), !julia.constgv !0
@"jl_global#542" = private unnamed_addr constant {}* inttoptr (i64 140083758686808 to {}*), !julia.constgv !0
@"+Main.Base.Libc.Libdl.dl_phdr_info543" = private unnamed_addr constant {}* inttoptr (i64 140083741189072 to {}*), !julia.constgv !0
@"+Core.Int32416" = private unnamed_addr constant {}* inttoptr (i64 140083660482112 to {}*), !julia.constgv !0
@_j_str50 = private unnamed_addr constant [10 x i8] c"cfunction\00"
@"*Core.Intrinsics.bitcast32" = private unnamed_addr constant {}* inttoptr (i64 140083661392080 to {}*), !julia.constgv !0
@jlplt_dl_iterate_phdr_7429_got = external global void ()*
@"*Core.Intrinsics.arraylen30" = private unnamed_addr constant {}* inttoptr (i64 140083661388624 to {}*), !julia.constgv !0
@"*Core.===37" = private unnamed_addr constant {}* inttoptr (i64 140083660467216 to {}*), !julia.constgv !0
@"*Core.ArgumentError17" = private unnamed_addr constant {}* inttoptr (i64 140083660457296 to {}*), !julia.constgv !0
@"jl_global#544" = private unnamed_addr constant {}* inttoptr (i64 140083733353768 to {}*), !julia.constgv !0
@"*Core.throw19" = private unnamed_addr constant {}* inttoptr (i64 140083660472720 to {}*), !julia.constgv !0
@"+Core.ArgumentError18" = private unnamed_addr constant {}* inttoptr (i64 140083661191360 to {}*), !julia.constgv !0
@"*Core.arrayref50" = private unnamed_addr constant {}* inttoptr (i64 140083660466640 to {}*), !julia.constgv !0
@jl_undefref_exception = external constant {}*
@jlplt_ijl_array_del_beg_7431_got = external global void ()*
@"*Main.Base.filter!545" = private unnamed_addr constant {}* inttoptr (i64 140083720891344 to {}*), !julia.constgv !0
@llvm.compiler.used = appending global [4 x i8*] [i8* bitcast (void ({} addrspace(10)*)* @ijl_gc_queue_root to i8*), i8* bitcast (void ({} addrspace(10)*)* @jl_gc_queue_binding to i8*), i8* bitcast ({} addrspace(10)* (i8*, i32, i32)* @ijl_gc_pool_alloc to i8*), i8* bitcast ({} addrspace(10)* (i8*, i64)* @ijl_gc_big_alloc to i8*)], section "llvm.metadata"

; Function Attrs: sspstrong
define nonnull {} addrspace(10)* @julia_dllist_7419() #0 !dbg !6 {
top:
  %gcframe = alloca {} addrspace(10)*, i32 3, align 16
  %0 = bitcast {} addrspace(10)** %gcframe to i8*
  call void @llvm.memset.p0i8.i32(i8* align 16 %0, i8 0, i32 24, i1 false), !tbaa !8
  %1 = call {}*** @julia.get_pgcstack()
  %2 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)** %gcframe, i32 0
  %3 = bitcast {} addrspace(10)** %2 to i64*
  store i64 4, i64* %3, align 8, !tbaa !8
  %4 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)** %gcframe, i32 1
  %5 = bitcast {} addrspace(10)** %4 to {}***
  %6 = load {}**, {}*** %1, align 8
  store {}** %6, {}*** %5, align 8, !tbaa !8
  %7 = bitcast {}*** %1 to {} addrspace(10)***
  store {} addrspace(10)** %gcframe, {} addrspace(10)*** %7, align 8
  %8 = bitcast {}*** %1 to {}**
  %current_task = getelementptr inbounds {}*, {}** %8, i64 -13
  %9 = bitcast {}** %current_task to i64*
  %world_age = getelementptr inbounds i64, i64* %9, i64 14
  %10 = bitcast {}*** %1 to {}**
  %current_task1 = getelementptr inbounds {}*, {}** %10, i64 -13
  %ptls_field = getelementptr inbounds {}*, {}** %current_task1, i64 15
  %ptls_load = load {}*, {}** %ptls_field, align 8, !tbaa !8
  %ptls = bitcast {}* %ptls_load to {}**
  fence syncscope("singlethread") seq_cst
  %11 = bitcast {}** %ptls to i64**, !dbg !12
  %12 = getelementptr inbounds i64*, i64** %11, i64 2, !dbg !12
  %safepoint = load i64*, i64** %12, align 8, !dbg !12
  %13 = load volatile i64, i64* %safepoint, align 8, !dbg !12
  fence syncscope("singlethread") seq_cst
  %14 = load {}*, {}** @"+Core.Array48", align 8, !dbg !13, !tbaa !18, !nonnull !0, !dereferenceable !20, !align !21
  %15 = addrspacecast {}* %14 to {} addrspace(10)*, !dbg !13
  %16 = load atomic void ()*, void ()** @jlplt_ijl_alloc_array_1d_7079_got unordered, align 8, !dbg !13
  %17 = bitcast void ()* %16 to {} addrspace(10)* ({} addrspace(10)*, i64)*, !dbg !13
  %18 = call nonnull {} addrspace(10)* %17({} addrspace(10)* %15, i64 0), !dbg !13
  %19 = addrspacecast {} addrspace(10)* %18 to {} addrspace(11)*, !dbg !22
  %20 = addrspacecast {} addrspace(11)* %19 to {}*
  %21 = load {}*, {}** @"*Core.Intrinsics.bitcast32", align 8, !dbg !32, !tbaa !18
  %22 = bitcast {}* %21 to {} addrspace(10)**, !dbg !32
  %23 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)** %22, i64 1, !dbg !32
  %24 = ptrtoint {}* %20 to i64, !dbg !32
  %25 = bitcast {}* %20 to i8*, !dbg !31
  %26 = load atomic void ()*, void ()** @jlplt_dl_iterate_phdr_7429_got unordered, align 8, !dbg !31
  %27 = bitcast void ()* %26 to i32 (i64, i8*)*, !dbg !31
  %28 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)** %gcframe, i32 2
  store {} addrspace(10)* %18, {} addrspace(10)** %28, align 8
  %29 = call i32 %27(i64 ptrtoint (i32 (i8*, i64, i8*)* @jlcapi_dl_phdr_info_callback_7427 to i64), i8* %25), !dbg !31
  %30 = load {}*, {}** @"*Core.Intrinsics.arraylen30", align 8, !dbg !35, !tbaa !18
  %31 = bitcast {}* %30 to {} addrspace(10)**, !dbg !35
  %32 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)** %31, i64 1, !dbg !35
  %33 = addrspacecast {} addrspace(10)* %18 to {} addrspace(11)*, !dbg !35
  %34 = bitcast {} addrspace(11)* %33 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)*, !dbg !35
  %35 = getelementptr inbounds { i8 addrspace(13)*, i64, i16, i16, i32 }, { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* %34, i32 0, i32 1, !dbg !35
  %36 = load i64, i64 addrspace(11)* %35, align 8, !dbg !35, !tbaa !45, !range !48
  %37 = load {}*, {}** @"*Core.===37", align 8, !dbg !49, !tbaa !18
  %38 = bitcast {}* %37 to {} addrspace(10)**, !dbg !49
  %39 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)** %38, i64 1, !dbg !49
  %40 = icmp eq i64 %36, 0, !dbg !49
  %41 = zext i1 %40 to i8, !dbg !49
  %42 = trunc i8 %41 to i1, !dbg !41
  %43 = xor i1 %42, true, !dbg !41
  br i1 %43, label %L12, label %L9, !dbg !41

L9:                                               ; preds = %top
  %44 = load {}*, {}** @"*Core.ArgumentError17", align 8, !dbg !52, !tbaa !18
  %45 = bitcast {}* %44 to {} addrspace(10)**, !dbg !52
  %46 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)** %45, i64 1, !dbg !52
  %47 = load {}*, {}** @"jl_global#544", align 8, !dbg !52, !tbaa !18, !nonnull !0
  %48 = addrspacecast {}* %47 to {} addrspace(10)*, !dbg !52
  %49 = call [1 x {} addrspace(10)*] @jlsys_ArgumentError_77({} addrspace(10)* %48) #1, !dbg !52
  %50 = load {}*, {}** @"*Core.throw19", align 8, !dbg !52, !tbaa !18
  %51 = bitcast {}* %50 to {} addrspace(10)**, !dbg !52
  %52 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)** %51, i64 1, !dbg !52
  %53 = load {}*, {}** @"+Core.ArgumentError18", align 8, !dbg !52, !tbaa !18, !nonnull !0, !dereferenceable !20, !align !21
  %54 = bitcast {}*** %1 to {}**, !dbg !52
  %current_task2 = getelementptr inbounds {}*, {}** %54, i64 -13, !dbg !52
  %55 = addrspacecast {}* %53 to {} addrspace(10)*, !dbg !52
  %56 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)** %gcframe, i32 2
  %57 = extractvalue [1 x {} addrspace(10)*] %49, 0
  store {} addrspace(10)* %57, {} addrspace(10)** %56, align 8
  %ptls_field4 = getelementptr inbounds {}*, {}** %current_task2, i64 15, !dbg !52
  %ptls_load5 = load {}*, {}** %ptls_field4, align 8, !dbg !52, !tbaa !8
  %ptls6 = bitcast {}* %ptls_load5 to {}**, !dbg !52
  %58 = bitcast {}** %ptls6 to i8*, !dbg !52
  %59 = call noalias nonnull {} addrspace(10)* @ijl_gc_pool_alloc(i8* %58, i32 1392, i32 16) #3, !dbg !52
  %60 = bitcast {} addrspace(10)* %59 to {}* addrspace(10)*, !dbg !52
  %61 = getelementptr inbounds {}*, {}* addrspace(10)* %60, i64 -1, !dbg !52
  store atomic {}* %53, {}* addrspace(10)* %61 unordered, align 8, !dbg !52, !tbaa !53
  %62 = bitcast {} addrspace(10)* %59 to [1 x {} addrspace(10)*] addrspace(10)*, !dbg !52
  store [1 x {} addrspace(10)*] %49, [1 x {} addrspace(10)*] addrspace(10)* %62, align 8, !dbg !52, !tbaa !56
  %63 = addrspacecast {} addrspace(10)* %59 to {} addrspace(12)*, !dbg !52
  call void @ijl_throw({} addrspace(12)* %63), !dbg !52
  unreachable, !dbg !52

L12:                                              ; preds = %top
  %64 = load {}*, {}** @"*Core.arrayref50", align 8, !dbg !59, !tbaa !18
  %65 = bitcast {}* %64 to {} addrspace(10)**, !dbg !59
  %66 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)** %65, i64 1, !dbg !59
  %67 = addrspacecast {} addrspace(10)* %18 to {} addrspace(11)*, !dbg !59
  %68 = bitcast {} addrspace(11)* %67 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)*, !dbg !59
  %69 = getelementptr inbounds { i8 addrspace(13)*, i64, i16, i16, i32 }, { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* %68, i32 0, i32 1, !dbg !59
  %70 = load i64, i64 addrspace(11)* %69, align 8, !dbg !59, !tbaa !45, !range !48
  %71 = icmp ult i64 0, %70, !dbg !59
  br i1 %71, label %idxend, label %oob, !dbg !59

oob:                                              ; preds = %L12
  %72 = alloca i64, i64 1, align 8, !dbg !59
  %73 = getelementptr inbounds i64, i64* %72, i64 0, !dbg !59
  store i64 1, i64* %73, align 8, !dbg !59
  %74 = addrspacecast {} addrspace(10)* %18 to {} addrspace(12)*, !dbg !59
  call void @ijl_bounds_error_ints({} addrspace(12)* %74, i64* %72, i64 1), !dbg !59
  unreachable, !dbg !59

idxend:                                           ; preds = %L12
  %75 = addrspacecast {} addrspace(10)* %18 to {} addrspace(11)*, !dbg !59
  %76 = bitcast {} addrspace(11)* %75 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)*, !dbg !59
  %77 = getelementptr inbounds { i8 addrspace(13)*, i64, i16, i16, i32 }, { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* %76, i32 0, i32 0, !dbg !59
  %78 = load i8 addrspace(13)*, i8 addrspace(13)* addrspace(11)* %77, align 8, !dbg !59, !tbaa !62, !nonnull !0
  %79 = bitcast i8 addrspace(13)* %78 to {} addrspace(10)* addrspace(13)*, !dbg !59
  %80 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)* addrspace(13)* %79, i64 0, !dbg !59
  %81 = load {} addrspace(10)*, {} addrspace(10)* addrspace(13)* %80, align 8, !dbg !59, !tbaa !64
  %82 = load {}*, {}** @jl_undefref_exception, align 8, !dbg !59, !tbaa !18, !nonnull !0
  %83 = icmp ne {} addrspace(10)* %81, null, !dbg !59
  br i1 %83, label %pass, label %fail, !dbg !59

fail:                                             ; preds = %idxend
  %84 = addrspacecast {}* %82 to {} addrspace(12)*, !dbg !59
  call void @ijl_throw({} addrspace(12)* %84), !dbg !59
  unreachable, !dbg !59

pass:                                             ; preds = %idxend
  %85 = load atomic void ()*, void ()** @jlplt_ijl_array_del_beg_7431_got unordered, align 8, !dbg !66
  %86 = bitcast void ()* %85 to void ({} addrspace(10)*, i64)*, !dbg !66
  call void %86({} addrspace(10)* %18, i64 1), !dbg !66
  %87 = load {}*, {}** @"*Main.Base.filter!545", align 8, !dbg !69, !tbaa !18
  %88 = bitcast {}* %87 to {} addrspace(10)**, !dbg !69
  %89 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)** %88, i64 1, !dbg !69
  %90 = call nonnull {} addrspace(10)* @"julia_filter!_7433"({} addrspace(10)* %18) #1, !dbg !69
  %91 = getelementptr inbounds {} addrspace(10)*, {} addrspace(10)** %gcframe, i32 1
  %92 = load {} addrspace(10)*, {} addrspace(10)** %91, align 8, !tbaa !8
  %93 = bitcast {}*** %1 to {} addrspace(10)**
  store {} addrspace(10)* %92, {} addrspace(10)** %93, align 8, !tbaa !8
  ret {} addrspace(10)* %18, !dbg !70
}

define nonnull {} addrspace(10)* @jfptr_dllist_7420({} addrspace(10)* %0, {} addrspace(10)** noalias nocapture noundef readonly %1, i32 %2) #1 {
top:
  %3 = call {}*** @julia.get_pgcstack()
  %4 = call nonnull {} addrspace(10)* @julia_dllist_7419() #1
  ret {} addrspace(10)* %4
}

declare {}*** @julia.get_pgcstack()

; Function Attrs: inaccessiblemem_or_argmemonly
declare void @julia.safepoint({}** %0) #2

define i32 @jlcapi_dl_phdr_info_callback_7427(i8* %0, i64 %1, i8* %2) #1 {
top:
  %gcframe = call {} addrspace(10)** @julia.new_gc_frame(i32 1)
  %3 = alloca { i32, i64, i64, i16 }, align 8
  %4 = call {}*** @julia.get_pgcstack_or_new()
  call void @julia.push_gc_frame({} addrspace(10)** %gcframe, i32 1)
  %5 = bitcast {}*** %4 to {}**
  %current_task = getelementptr inbounds {}*, {}** %5, i64 -13
  %6 = bitcast {}** %current_task to i64*
  %world_age = getelementptr inbounds i64, i64* %6, i64 14
  %7 = load i64, i64* %world_age, align 8, !tbaa !8
  %8 = load atomic i64, i64* @jl_world_counter acquire, align 8
  %9 = load {}*, {}** @"jl_global#541", align 8, !tbaa !18, !nonnull !0, !dereferenceable !71, !align !72
  %10 = bitcast {}* %9 to i64*
  %11 = getelementptr inbounds i64, i64* %10, i32 3
  %12 = load i64, i64* %11, align 8
  %13 = icmp uge i64 %12, %8
  store i64 %8, i64* %world_age, align 8
  %14 = bitcast i8* %0 to { i32, i64, i64, i16 }*
  %15 = bitcast { i32, i64, i64, i16 }* %3 to i8*
  %16 = bitcast { i32, i64, i64, i16 }* %14 to i8*
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %15, i8* align 1 %16, i64 32, i1 false)
  %17 = bitcast i8* %2 to {}*
  %18 = addrspacecast {}* %17 to {} addrspace(10)*
  %19 = addrspacecast { i32, i64, i64, i16 }* %3 to { i32, i64, i64, i16 } addrspace(11)*
  %20 = select i1 %13, i32 ({ i32, i64, i64, i16 } addrspace(11)*, i64, {} addrspace(10)*)* @jlsys_dl_phdr_info_callback_236, i32 ({ i32, i64, i64, i16 } addrspace(11)*, i64, {} addrspace(10)*)* @jlcapi_dl_phdr_info_callback_7427_gfthunk
  %21 = call {} addrspace(10)** @julia.get_gc_frame_slot({} addrspace(10)** %gcframe, i32 0)
  store {} addrspace(10)* %18, {} addrspace(10)** %21, align 8
  %22 = call i32 %20({ i32, i64, i64, i16 } addrspace(11)* nocapture readonly %19, i64 zeroext %1, {} addrspace(10)* %18) #1
  store i64 %7, i64* %world_age, align 8
  call void @julia.pop_gc_frame({} addrspace(10)** %gcframe)
  ret i32 %22
}

declare {}*** @julia.get_pgcstack_or_new()

declare i32 @jlsys_dl_phdr_info_callback_236({ i32, i64, i64, i16 } addrspace(11)* nocapture readonly %0, i64 zeroext %1, {} addrspace(10)* %2) #1

define internal i32 @jlcapi_dl_phdr_info_callback_7427_gfthunk({ i32, i64, i64, i16 } addrspace(11)* nocapture readonly %0, i64 zeroext %1, {} addrspace(10)* %2) #1 {
top:
  %3 = call {}*** @julia.get_pgcstack()
  %4 = load {}*, {}** @"jl_global#542", align 8, !tbaa !73, !invariant.load !0, !nonnull !0
  %5 = addrspacecast {}* %4 to {} addrspace(10)*
  %6 = load {}*, {}** @"+Main.Base.Libc.Libdl.dl_phdr_info543", align 8, !tbaa !73, !invariant.load !0, !nonnull !0, !dereferenceable !20, !align !21
  %7 = bitcast {}*** %3 to {}**
  %current_task = getelementptr inbounds {}*, {}** %7, i64 -13
  %8 = addrspacecast {}* %6 to {} addrspace(10)*
  %9 = call noalias nonnull {} addrspace(10)* @julia.gc_alloc_obj({}** %current_task, i64 32, {} addrspace(10)* %8) #3
  %10 = bitcast {} addrspace(10)* %9 to i8 addrspace(10)*
  %11 = bitcast { i32, i64, i64, i16 } addrspace(11)* %0 to i8 addrspace(11)*
  call void @llvm.memcpy.p10i8.p11i8.i64(i8 addrspace(10)* align 8 %10, i8 addrspace(11)* %11, i64 32, i1 false), !tbaa !74
  %12 = call nonnull {} addrspace(10)* @ijl_box_uint64(i64 zeroext %1)
  %13 = call nonnull {} addrspace(10)* ({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)*, {} addrspace(10)*, ...) @julia.call({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* @ijl_apply_generic, {} addrspace(10)* %5, {} addrspace(10)* %9, {} addrspace(10)* %12, {} addrspace(10)* %2)
  %14 = load {}*, {}** @"+Core.Int32416", align 8, !tbaa !73, !invariant.load !0, !nonnull !0, !dereferenceable !20, !align !21
  %15 = addrspacecast {}* %14 to {} addrspace(10)*
  %16 = call {} addrspace(10)* @julia.typeof({} addrspace(10)* %13)
  %17 = icmp eq {} addrspace(10)* %16, %15
  br i1 %17, label %pass, label %fail

fail:                                             ; preds = %top
  %18 = load {}*, {}** @"+Core.Int32416", align 8, !tbaa !73, !invariant.load !0, !nonnull !0, !dereferenceable !20, !align !21
  %19 = addrspacecast {}* %18 to {} addrspace(10)*
  %20 = addrspacecast {} addrspace(10)* %13 to {} addrspace(12)*
  call void @ijl_type_error(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @_j_str50, i32 0, i32 0), {} addrspace(10)* %19, {} addrspace(12)* %20)
  unreachable

pass:                                             ; preds = %top
  %21 = bitcast {} addrspace(10)* %13 to i32 addrspace(10)*
  %22 = load i32, i32 addrspace(10)* %21, align 4
  ret i32 %22
}

declare nonnull {} addrspace(10)* @ijl_apply_generic({} addrspace(10)* %0, {} addrspace(10)** noalias nocapture noundef readonly %1, i32 %2)

declare nonnull {} addrspace(10)* @julia.call({} addrspace(10)* ({} addrspace(10)*, {} addrspace(10)**, i32)* %0, {} addrspace(10)* %1, ...)

; Function Attrs: allocsize(1)
declare noalias nonnull {} addrspace(10)* @julia.gc_alloc_obj({}** %0, i64 %1, {} addrspace(10)* %2) #3

; Function Attrs: argmemonly nofree nounwind willreturn
declare void @llvm.memcpy.p10i8.p11i8.i64(i8 addrspace(10)* noalias nocapture writeonly %0, i8 addrspace(11)* noalias nocapture readonly %1, i64 %2, i1 immarg %3) #4

declare nonnull {} addrspace(10)* @ijl_box_uint64(i64 zeroext %0)

; Function Attrs: norecurse nounwind readnone
declare nonnull {} addrspace(10)* @julia.typeof({} addrspace(10)* %0) #5

; Function Attrs: noreturn
declare void @ijl_type_error(i8* %0, {} addrspace(10)* %1, {} addrspace(12)* %2) #6

; Function Attrs: nounwind readnone
declare nonnull {}* @julia.pointer_from_objref({} addrspace(11)* %0) #7

declare [1 x {} addrspace(10)*] @jlsys_ArgumentError_77({} addrspace(10)* %0) #1

; Function Attrs: noreturn
declare void @ijl_throw({} addrspace(12)* %0) #6

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

; Function Attrs: noreturn
declare void @ijl_bounds_error_ints({} addrspace(12)* %0, i64* %1, i64 %2) #6

declare nonnull {} addrspace(10)* @"julia_filter!_7433"({} addrspace(10)* %0) #1

; Function Attrs: inaccessiblemem_or_argmemonly
declare void @ijl_gc_queue_root({} addrspace(10)* %0) #2

; Function Attrs: inaccessiblemem_or_argmemonly
declare void @jl_gc_queue_binding({} addrspace(10)* %0) #2

; Function Attrs: allocsize(1)
declare noalias nonnull {} addrspace(10)* @ijl_gc_pool_alloc(i8* %0, i32 %1, i32 %2) #3

; Function Attrs: allocsize(1)
declare noalias nonnull {} addrspace(10)* @ijl_gc_big_alloc(i8* %0, i64 %1) #3

; Function Attrs: argmemonly nofree nounwind willreturn
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly %0, i8* noalias nocapture readonly %1, i64 %2, i1 immarg %3) #4

declare noalias nonnull {} addrspace(10)** @julia.new_gc_frame(i32 %0)

declare void @julia.push_gc_frame({} addrspace(10)** %0, i32 %1)

declare {} addrspace(10)** @julia.get_gc_frame_slot({} addrspace(10)** %0, i32 %1)

declare void @julia.pop_gc_frame({} addrspace(10)** %0)

; Function Attrs: allocsize(1)
declare noalias nonnull {} addrspace(10)* @julia.gc_alloc_bytes(i8* %0, i64 %1) #3

; Function Attrs: argmemonly nofree nounwind willreturn writeonly
declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly %0, i8 %1, i32 %2, i1 immarg %3) #9

attributes #0 = { sspstrong "probe-stack"="inline-asm" }
attributes #1 = { "probe-stack"="inline-asm" }
attributes #2 = { inaccessiblemem_or_argmemonly }
attributes #3 = { allocsize(1) }
attributes #4 = { argmemonly nofree nounwind willreturn }
attributes #5 = { norecurse nounwind readnone }
attributes #6 = { noreturn }
attributes #7 = { nounwind readnone }
attributes #8 = { cold noreturn nounwind }
attributes #9 = { argmemonly nofree nounwind willreturn writeonly }

!llvm.module.flags = !{!1, !2, !3}
!llvm.dbg.cu = !{!4}

!0 = !{}
!1 = !{i32 2, !"Dwarf Version", i32 4}
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = !{i32 1, !"stack-protector-guard", !"global"}
!4 = distinct !DICompileUnit(language: DW_LANG_Julia, file: !5, producer: "julia", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, nameTableKind: GNU)
!5 = !DIFile(filename: "libdl.jl", directory: ".")
!6 = distinct !DISubprogram(name: "dllist", linkageName: "julia_dllist_7419", scope: null, file: !5, line: 291, type: !7, scopeLine: 291, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4, retainedNodes: !0)
!7 = !DISubroutineType(types: !0)
!8 = !{!9, !9, i64 0}
!9 = !{!"jtbaa_gcframe", !10, i64 0}
!10 = !{!"jtbaa", !11, i64 0}
!11 = !{!"jtbaa"}
!12 = !DILocation(line: 291, scope: !6)
!13 = !DILocation(line: 477, scope: !14, inlinedAt: !16)
!14 = distinct !DISubprogram(name: "Array;", linkageName: "Array", scope: !15, file: !15, type: !7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4, retainedNodes: !0)
!15 = !DIFile(filename: "boot.jl", directory: ".")
!16 = !DILocation(line: 496, scope: !14, inlinedAt: !17)
!17 = !DILocation(line: 292, scope: !6)
!18 = !{!19, !19, i64 0}
!19 = !{!"jtbaa_const", !10, i64 0}
!20 = !{i64 56}
!21 = !{i64 16}
!22 = !DILocation(line: 155, scope: !23, inlinedAt: !25)
!23 = distinct !DISubprogram(name: "pointer_from_objref;", linkageName: "pointer_from_objref", scope: !24, file: !24, type: !7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4, retainedNodes: !0)
!24 = !DIFile(filename: "pointer.jl", directory: ".")
!25 = !DILocation(line: 42, scope: !26, inlinedAt: !28)
!26 = distinct !DISubprogram(name: "unsafe_convert;", linkageName: "unsafe_convert", scope: !27, file: !27, type: !7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4, retainedNodes: !0)
!27 = !DIFile(filename: "refvalue.jl", directory: ".")
!28 = !DILocation(line: 101, scope: !29, inlinedAt: !31)
!29 = distinct !DISubprogram(name: "unsafe_convert;", linkageName: "unsafe_convert", scope: !30, file: !30, type: !7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4, retainedNodes: !0)
!30 = !DIFile(filename: "refpointer.jl", directory: ".")
!31 = !DILocation(line: 305, scope: !6)
!32 = !DILocation(line: 30, scope: !33, inlinedAt: !34)
!33 = distinct !DISubprogram(name: "convert;", linkageName: "convert", scope: !24, file: !24, type: !7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4, retainedNodes: !0)
!34 = !DILocation(line: 50, scope: !26, inlinedAt: !28)
!35 = !DILocation(line: 10, scope: !36, inlinedAt: !38)
!36 = distinct !DISubprogram(name: "length;", linkageName: "length", scope: !37, file: !37, type: !7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4, retainedNodes: !0)
!37 = !DIFile(filename: "essentials.jl", directory: ".")
!38 = !DILocation(line: 1215, scope: !39, inlinedAt: !41)
!39 = distinct !DISubprogram(name: "isempty;", linkageName: "isempty", scope: !40, file: !40, type: !7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4, retainedNodes: !0)
!40 = !DIFile(filename: "abstractarray.jl", directory: ".")
!41 = !DILocation(line: 1462, scope: !42, inlinedAt: !44)
!42 = distinct !DISubprogram(name: "popfirst!;", linkageName: "popfirst!", scope: !43, file: !43, type: !7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4, retainedNodes: !0)
!43 = !DIFile(filename: "array.jl", directory: ".")
!44 = !DILocation(line: 306, scope: !6)
!45 = !{!46, !46, i64 0}
!46 = !{!"jtbaa_arraylen", !47, i64 0}
!47 = !{!"jtbaa_array", !10, i64 0}
!48 = !{i64 0, i64 9223372036854775807}
!49 = !DILocation(line: 499, scope: !50, inlinedAt: !38)
!50 = distinct !DISubprogram(name: "==;", linkageName: "==", scope: !51, file: !51, type: !7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4, retainedNodes: !0)
!51 = !DIFile(filename: "promotion.jl", directory: ".")
!52 = !DILocation(line: 1463, scope: !42, inlinedAt: !44)
!53 = !{!54, !54, i64 0}
!54 = !{!"jtbaa_tag", !55, i64 0}
!55 = !{!"jtbaa_data", !10, i64 0}
!56 = !{!57, !57, i64 0}
!57 = !{!"jtbaa_immut", !58, i64 0}
!58 = !{!"jtbaa_value", !55, i64 0}
!59 = !DILocation(line: 13, scope: !60, inlinedAt: !61)
!60 = distinct !DISubprogram(name: "getindex;", linkageName: "getindex", scope: !37, file: !37, type: !7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4, retainedNodes: !0)
!61 = !DILocation(line: 1465, scope: !42, inlinedAt: !44)
!62 = !{!63, !63, i64 0}
!63 = !{!"jtbaa_arrayptr", !47, i64 0}
!64 = !{!65, !65, i64 0}
!65 = !{!"jtbaa_ptrarraybuf", !55, i64 0}
!66 = !DILocation(line: 1021, scope: !67, inlinedAt: !68)
!67 = distinct !DISubprogram(name: "_deletebeg!;", linkageName: "_deletebeg!", scope: !43, file: !43, type: !7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4, retainedNodes: !0)
!68 = !DILocation(line: 1466, scope: !42, inlinedAt: !44)
!69 = !DILocation(line: 307, scope: !6)
!70 = !DILocation(line: 314, scope: !6)
!71 = !{i64 96}
!72 = !{i64 8}
!73 = !{!19, !19, i64 0, i64 1}
!74 = !{!10, !10, i64 0}
$8 = void

We elimated the reference to julia.safepoint, but ofc the declaration is still around, that shouldn't cause Orc to search for it though...

@vchuravy vchuravy marked this pull request as ready for review December 28, 2022 12:55
@vchuravy
Copy link
Member Author

@nanosoldier runtests()

@KristofferC KristofferC mentioned this pull request Dec 28, 2022
14 tasks
@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

@KristofferC KristofferC mentioned this pull request Jan 2, 2023
41 tasks
@vchuravy vchuravy added the merge me PR is reviewed. Merge when all tests are passing label Jan 6, 2023
@giordano giordano merged commit db7d762 into master Jan 8, 2023
@giordano giordano deleted the vc/safepoint branch January 8, 2023 15:03
@giordano giordano removed the merge me PR is reviewed. Merge when all tests are passing label Jan 8, 2023
@vchuravy vchuravy removed the backport 1.9 Change should be backported to release-1.9 label Jan 13, 2023
kpamnany pushed a commit to RelationalAI/julia that referenced this pull request Sep 27, 2023
kpamnany pushed a commit to RelationalAI/julia that referenced this pull request Sep 28, 2023
kpamnany pushed a commit to RelationalAI/julia that referenced this pull request Sep 28, 2023
kpamnany pushed a commit to RelationalAI/julia that referenced this pull request Oct 4, 2023
kpamnany pushed a commit to RelationalAI/julia that referenced this pull request Oct 6, 2023
kpamnany pushed a commit to RelationalAI/julia that referenced this pull request Oct 19, 2023
kpamnany pushed a commit to RelationalAI/julia that referenced this pull request Oct 19, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Oct 20, 2023
kpamnany pushed a commit to RelationalAI/julia that referenced this pull request Oct 21, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Oct 23, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Nov 1, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Nov 2, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Nov 7, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Nov 10, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Nov 14, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Nov 15, 2023
@kpamnany kpamnany mentioned this pull request Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:llvm For issues that relate to LLVM GC Garbage collector

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants