Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have the default target default to not using the Julia runtime. #380

Merged
merged 2 commits into from
Dec 23, 2022

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Dec 22, 2022

Otherwise the kernel example fails on macOS running Julia 1.9:

Reason: unsupported call through a literal pointer (call to pthread_getspecific)

This is because the TLS getter is lowered differently:

define void @_Z17julia_kernel_2628() #0 !dbg !4 {
top:
  %0 = call {}*** @julia.get_pgcstack()
  %1 = bitcast {}*** %0 to {}**
  %current_task = getelementptr inbounds {}*, {}** %1, i64 -13
  %2 = bitcast {}** %current_task to i64*
  %world_age = getelementptr inbounds i64, i64* %2, i64 14
  %3 = bitcast {}*** %0 to {}**
  %current_task1 = getelementptr inbounds {}*, {}** %3, i64 -13
  %ptls_field = getelementptr inbounds {}*, {}** %current_task1, i64 15
  %ptls_load = load {}*, {}** %ptls_field, align 8, !tbaa !7
  %ptls = bitcast {}* %ptls_load to {}**
  fence syncscope("singlethread") seq_cst
  %4 = bitcast {}** %ptls to i64**
  %5 = getelementptr inbounds i64*, i64** %4, i64 2
  %safepoint = load i64*, i64** %5, align 8, !tbaa !11, !invariant.load !6
  %6 = load volatile i64, i64* %safepoint, align 8
  fence syncscope("singlethread") seq_cst
  ret void, !dbg !13
}

optimizes to

define void @_Z17julia_kernel_2997() local_unnamed_addr #0 !dbg !5 {
top:
  %0 = call {}*** inttoptr (i64 7114247836 to {}*** (i64)*)(i64 261) #1
  %ptls_field3 = getelementptr inbounds {}**, {}*** %0, i64 2
  %1 = bitcast {}*** %ptls_field3 to i64***
  %ptls_load45 = load i64**, i64*** %1, align 8, !tbaa !8
  fence syncscope("singlethread") seq_cst
  %2 = getelementptr inbounds i64*, i64** %ptls_load45, i64 2
  %safepoint = load i64*, i64** %2, align 8, !tbaa !12
  %3 = load volatile i64, i64* %safepoint, align 8
  fence syncscope("singlethread") seq_cst
  ret void, !dbg !14
}

while on other platforms:

define void @_Z17julia_kernel_2198() #0 !dbg !4 {
top:
  %0 = call {}*** @julia.get_pgcstack()
  %1 = bitcast {}*** %0 to {}**
  %current_task = getelementptr inbounds {}*, {}** %1, i64 -13
  %2 = bitcast {}** %current_task to i64*
  %world_age = getelementptr inbounds i64, i64* %2, i64 14
  %3 = bitcast {}*** %0 to {}**
  %current_task1 = getelementptr inbounds {}*, {}** %3, i64 -13
  %ptls_field = getelementptr inbounds {}*, {}** %current_task1, i64 15
  %ptls_load = load {}*, {}** %ptls_field, align 8, !tbaa !7
  %ptls = bitcast {}* %ptls_load to {}**
  fence syncscope("singlethread") seq_cst
  %4 = bitcast {}** %ptls to i64**
  %5 = getelementptr inbounds i64*, i64** %4, i64 2
  %safepoint = load i64*, i64** %5, align 8, !tbaa !11, !invariant.load !6
  %6 = load volatile i64, i64* %safepoint, align 8
  fence syncscope("singlethread") seq_cst
  ret void, !dbg !13
}

... optimizes to

define void @_Z17julia_kernel_2936() local_unnamed_addr #0 !dbg !5 {
top:
  %thread_ptr = call i8* asm "movq %fs:0, $0", "=r"() #1
  %ppgcstack_i8 = getelementptr i8, i8* %thread_ptr, i64 -8
  %ppgcstack = bitcast i8* %ppgcstack_i8 to {}****
  %pgcstack = load {}***, {}**** %ppgcstack, align 8
  %ptls_field3 = getelementptr inbounds {}**, {}*** %pgcstack, i64 2
  %0 = bitcast {}*** %ptls_field3 to i64***
  %ptls_load45 = load i64**, i64*** %0, align 8, !tbaa !8
  fence syncscope("singlethread") seq_cst
  %1 = getelementptr inbounds i64*, i64** %ptls_load45, i64 2
  %safepoint = load i64*, i64** %1, align 8, !tbaa !12
  %2 = load volatile i64, i64* %safepoint, align 8
  fence syncscope("singlethread") seq_cst
  ret void, !dbg !14
}

which doesn't trigger the validator (inline asm vs call-to-pointer)


on 1.8, where we didn't emit a safepoint at the start, we used to get:

define void @_Z17julia_kernel_2728() #0 !dbg !5 {
top:
  %0 = call {}*** @julia.get_pgcstack()
  %1 = bitcast {}*** %0 to {}**
  %current_task = getelementptr inbounds {}*, {}** %1, i64 -12
  %2 = bitcast {}** %current_task to i64*
  %world_age = getelementptr inbounds i64, i64* %2, i64 13
  ret void, !dbg !7
}

@maleadt maleadt requested a review from vchuravy December 22, 2022 17:08
@maleadt maleadt force-pushed the tb/native_jlruntime_default branch from e5f2dcd to 054d30d Compare December 23, 2022 13:43
@maleadt maleadt merged commit 7f2f49a into master Dec 23, 2022
@maleadt maleadt deleted the tb/native_jlruntime_default branch December 23, 2022 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants