Skip to content

Commit

Permalink
codegen: enable OpaquePointers on LLVM 15
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy authored and vtjnash committed Dec 12, 2023
1 parent eba10dd commit 64cc21f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/llvm-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#error Only LLVM versions >= 14.0.0 are supported by Julia
#endif

#if JL_LLVM_VERSION >= 160000
#if JL_LLVM_VERSION >= 150000
#define JL_LLVM_OPAQUE_POINTERS 1
#endif

Expand Down
6 changes: 3 additions & 3 deletions test/compiler/codegen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ if !is_debug_build && opt_level > 0
# Array
test_loads_no_call(strip_debug_calls(get_llvm(sizeof, Tuple{Vector{Int}})), [Iptr])
# As long as the eltype is known we don't need to load the elsize, but do need to check isvector
@test_skip test_loads_no_call(strip_debug_calls(get_llvm(sizeof, Tuple{Array{Any}})), ["atomic $Iptr", "{} addrspace(10)* addrspace(10)*", "$Iptr addrspace(10)*", Iptr, Iptr, "{ i64, {} addrspace(10)** } addrspace(10)*", Iptr])
@test_skip test_loads_no_call(strip_debug_calls(get_llvm(sizeof, Tuple{Array{Any}})), ["atomic $Iptr", "ptr addrspace(10)", "ptr addrspace(10)", Iptr, Iptr, "ptr addrspace(10)", Iptr])
# Memory
test_loads_no_call(strip_debug_calls(get_llvm(core_sizeof, Tuple{Memory{Int}})), [Iptr])
# As long as the eltype is known we don't need to load the elsize
test_loads_no_call(strip_debug_calls(get_llvm(core_sizeof, Tuple{Memory{Any}})), [Iptr])
# Check that we load the elsize and isunion from the typeof layout
test_loads_no_call(strip_debug_calls(get_llvm(core_sizeof, Tuple{Memory})), [Iptr, "atomic $Iptr", "i32*", "i32", "i16"])
test_loads_no_call(strip_debug_calls(get_llvm(core_sizeof, Tuple{Memory})), [Iptr, "atomic $Iptr", "i32*", "i32", "i16"])
test_loads_no_call(strip_debug_calls(get_llvm(core_sizeof, Tuple{Memory})), [Iptr, "atomic $Iptr", "ptr", "i32", "i16"])
test_loads_no_call(strip_debug_calls(get_llvm(core_sizeof, Tuple{Memory})), [Iptr, "atomic $Iptr", "ptr", "i32", "i16"])
# Primitive Type size should be folded to a constant
test_loads_no_call(strip_debug_calls(get_llvm(core_sizeof, Tuple{Ptr})), String[])

Expand Down
18 changes: 8 additions & 10 deletions test/llvmpasses/names.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

# RUN: julia --startup-file=no %s %t -O && llvm-link -S %t/* -o %t/module.ll
# RUN: JULIA_LLVM_ARGS=--opaque-pointers julia --startup-file=no %s %t -O && llvm-link -S %t/* -o %t/module.ll
# RUN: cat %t/module.ll | FileCheck %s

## Notes:
Expand Down Expand Up @@ -96,12 +96,12 @@ end
# CHECK: ret double
# CHECK: }

# CHECK-LABEL: define nonnull {} addrspace(10)* @jfptr_f1
# CHECK-LABEL: define nonnull ptr addrspace(10) @jfptr_f1
# CHECK-SAME: %"function::Core.Function"
# CHECK-SAME: %"args::Any[]"
# CHECK-SAME: %"nargs::UInt32"
# CHECK: %"+Core.Float64
# CHECK: ret {} addrspace(10)*
# CHECK: ret ptr addrspace(10)
# CHECK: }
emit(f1, Float64, Float64, Float64, Float64)

Expand Down Expand Up @@ -133,22 +133,20 @@ emit(f2, Float64, Float64, Float64, Float64, Float64, Float64)
# CHECK-SAME: double %"e[3]::Float64"
emit(f2, Float64, Float64, Float64, Float64, Float64, Float64, Float64)

# CHECK: define {{(swiftcc )?}}nonnull {} addrspace(10)* @julia_f5
# CHECK: define {{(swiftcc )?}}nonnull ptr addrspace(10) @julia_f5
# CHECK-SAME: %"a::A"
# CHECK: %"a::A.b_ptr.c_ptr.d
emit(f5, A)

# CHECK: define {{(swiftcc )?}}nonnull {} addrspace(10)* @julia_f6
# CHECK: define {{(swiftcc )?}}nonnull ptr addrspace(10) @julia_f6
# CHECK-SAME: %"e::E"
# CHECK: %jlcallframe
# CHECK: %gcframe
# CHECK: %frame.nroots
# CHECK: %frame.prev
# CHECK: %task.gcstack
# CHECK: %ptls_field
# CHECK: %ptls_load
# CHECK: %safepoint
# CHECK: %"e::E.f_ptr"
# CHECK: %"e::E.f"
# CHECK: %"e::E.f.tag_addr"
# CHECK: %"e::E.f.tag"
Expand All @@ -164,23 +162,23 @@ emit(f6, E)
# CHECK: %"a::Tuple[2]_ptr.unbox
emit(f7, Tuple{Int,Int})

# CHECK: define {{(swiftcc )?}}nonnull {} addrspace(10)* @julia_f8
# CHECK: define {{(swiftcc )?}}nonnull ptr addrspace(10) @julia_f8
# CHECK-SAME: %"y::Int64"
# CHECK: %parent_bits
# CHECK: %parent_old_marked
# CHECK: %child_bit
# CHECK: %child_not_marked
emit(f8, Barrier, Int)

# CHECK: define {{(swiftcc )?}}nonnull {} addrspace(10)* @julia_Barrier
# CHECK: define {{(swiftcc )?}}nonnull ptr addrspace(10) @julia_Barrier
# CHECK-SAME: %"b::Named"
# CHECK: %"new::Barrier"
# CHECK: %"box::Named"
# CHECK: %parent_bits
# CHECK: %parent_old_marked
emit(Barrier, Named)

# CHECK: define {{(swiftcc )?}}nonnull {} addrspace(10)* @julia_fmemory
# CHECK: define {{(swiftcc )?}}nonnull ptr addrspace(10) @julia_fmemory
# CHECK-SAME: %"nel::Int64"
# CHECK: %"Memory{Int64}[]"
emit(fmemory, Int64)

0 comments on commit 64cc21f

Please sign in to comment.