Skip to content

Commit bc42922

Browse files
authored
Update to LLVM.jl 6. (#1976)
1 parent 8170267 commit bc42922

File tree

11 files changed

+64
-69
lines changed

11 files changed

+64
-69
lines changed

Manifest.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ version = "0.1.7"
7070

7171
[[Compat]]
7272
deps = ["Dates", "LinearAlgebra", "UUIDs"]
73-
git-tree-sha1 = "7a60c856b9fa189eb34f5f8a6f6b5529b7942957"
73+
git-tree-sha1 = "4e88377ae7ebeaf29a047aa1ee40826e0b708a5d"
7474
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
75-
version = "4.6.1"
75+
version = "4.7.0"
7676

7777
[[CompilerSupportLibraries_jll]]
7878
deps = ["Artifacts", "Libdl"]
@@ -99,9 +99,9 @@ version = "0.1.9"
9999

100100
[[GPUArrays]]
101101
deps = ["Adapt", "GPUArraysCore", "LLVM", "LinearAlgebra", "Printf", "Random", "Reexport", "Serialization", "Statistics"]
102-
git-tree-sha1 = "a3351bc577a6b49297248aadc23a4add1097c2ac"
102+
git-tree-sha1 = "2e57b4a4f9cc15e85a24d603256fe08e527f48d1"
103103
uuid = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
104-
version = "8.7.1"
104+
version = "8.8.1"
105105

106106
[[GPUArraysCore]]
107107
deps = ["Adapt"]
@@ -111,9 +111,9 @@ version = "0.1.5"
111111

112112
[[GPUCompiler]]
113113
deps = ["ExprTools", "InteractiveUtils", "LLVM", "Libdl", "Logging", "Scratch", "TimerOutputs", "UUIDs"]
114-
git-tree-sha1 = "c47730aca2381f935a52fd732190e424c507230e"
114+
git-tree-sha1 = "0c21d9b7ff70859bdb2ca7dab814e144676c31db"
115115
uuid = "61eb1bfa-7361-4325-ad38-22787b887f55"
116-
version = "0.21.0"
116+
version = "0.21.1"
117117

118118
[[InteractiveUtils]]
119119
deps = ["Markdown"]
@@ -138,15 +138,15 @@ version = "1.4.1"
138138

139139
[[KernelAbstractions]]
140140
deps = ["Adapt", "Atomix", "InteractiveUtils", "LinearAlgebra", "MacroTools", "PrecompileTools", "SparseArrays", "StaticArrays", "UUIDs", "UnsafeAtomics", "UnsafeAtomicsLLVM"]
141-
git-tree-sha1 = "47be64f040a7ece575c2b5f53ca6da7b548d69f4"
141+
git-tree-sha1 = "b48617c5d764908b5fac493cd907cf33cc11eec1"
142142
uuid = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
143-
version = "0.9.4"
143+
version = "0.9.6"
144144

145145
[[LLVM]]
146146
deps = ["CEnum", "LLVMExtra_jll", "Libdl", "Printf", "Unicode"]
147-
git-tree-sha1 = "5007c1421563108110bbd57f63d8ad4565808818"
147+
git-tree-sha1 = "7d5788011dd273788146d40eb5b1fbdc199d0296"
148148
uuid = "929cbde3-209d-540e-8aea-75f648917ca0"
149-
version = "5.2.0"
149+
version = "6.0.1"
150150

151151
[[LLVMExtra_jll]]
152152
deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"]
@@ -343,9 +343,9 @@ version = "0.2.1"
343343

344344
[[UnsafeAtomicsLLVM]]
345345
deps = ["LLVM", "UnsafeAtomics"]
346-
git-tree-sha1 = "ea37e6066bf194ab78f4e747f5245261f17a7175"
346+
git-tree-sha1 = "323e3d0acf5e78a56dfae7bd8928c989b4f3083e"
347347
uuid = "d80eeb9a-aca5-4d75-85e5-170c8b632249"
348-
version = "0.1.2"
348+
version = "0.1.3"
349349

350350
[[Zlib_jll]]
351351
deps = ["Libdl"]

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ExprTools = "0.1"
4242
GPUArrays = "8.6"
4343
GPUCompiler = "0.21"
4444
KernelAbstractions = "0.9.2"
45-
LLVM = "5"
45+
LLVM = "6"
4646
Preferences = "1"
4747
Random123 = "1.2"
4848
RandomNumbers = "1.5.3"

src/compiler/compilation.jl

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ function GPUCompiler.link_libraries!(@nospecialize(job::CUDACompilerJob), mod::L
2121
return
2222
end
2323

24-
ctx = LLVM.context(mod)
25-
lib = parse(LLVM.Module, read(libdevice); ctx)
24+
lib = parse(LLVM.Module, read(libdevice))
2625

2726
# override libdevice's triple and datalayout to avoid warnings
2827
triple!(lib, triple(mod))
@@ -32,7 +31,7 @@ function GPUCompiler.link_libraries!(@nospecialize(job::CUDACompilerJob), mod::L
3231

3332
@dispose pm=ModulePassManager() begin
3433
push!(metadata(mod)["nvvm-reflect-ftz"],
35-
MDNode([ConstantInt(Int32(1); ctx)]; ctx))
34+
MDNode([ConstantInt(Int32(1))]))
3635
run!(pm, mod)
3736
end
3837

@@ -99,14 +98,11 @@ end
9998

10099
# compile to executable machine code
101100
function compile(@nospecialize(job::CompilerJob))
101+
# lower to PTX
102102
# TODO: on 1.9, this actually creates a context. cache those.
103-
JuliaContext() do ctx
104-
compile(job, ctx)
103+
asm, meta = JuliaContext() do ctx
104+
GPUCompiler.compile(:asm, job)
105105
end
106-
end
107-
function compile(@nospecialize(job::CompilerJob), ctx)
108-
# lower to PTX
109-
asm, meta = GPUCompiler.compile(:asm, job; ctx)
110106

111107
# remove extraneous debug info on lower debug levels
112108
if Base.JLOptions().debug_level < 2

src/device/intrinsics/assertion.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ assert_counter = 0
4040
@generated function cuassert_fail(::Val{msg}, ::Val{file}, ::Val{line}) where
4141
{msg, file, line}
4242
@dispose ctx=Context() begin
43-
T_void = LLVM.VoidType(ctx)
44-
T_int32 = LLVM.Int32Type(ctx)
45-
T_pint8 = LLVM.PointerType(LLVM.Int8Type(ctx))
43+
T_void = LLVM.VoidType()
44+
T_int32 = LLVM.Int32Type()
45+
T_pint8 = LLVM.PointerType(LLVM.Int8Type())
4646

4747
# create function
4848
llvm_f, _ = create_function(T_void)
4949
mod = LLVM.parent(llvm_f)
5050

5151
# generate IR
52-
@dispose builder=IRBuilder(ctx) begin
53-
entry = BasicBlock(llvm_f, "entry"; ctx)
52+
@dispose builder=IRBuilder() begin
53+
entry = BasicBlock(llvm_f, "entry")
5454
position!(builder, entry)
5555

5656
global assert_counter
@@ -60,7 +60,7 @@ assert_counter = 0
6060
file = globalstring_ptr!(builder, String(file), "assert_file_$(assert_counter)")
6161
line = ConstantInt(T_int32, line)
6262
func = globalstring_ptr!(builder, "unknown", "assert_function_$(assert_counter)")
63-
charSize = ConstantInt(Csize_t(1); ctx)
63+
charSize = ConstantInt(Csize_t(1))
6464

6565
# invoke __assertfail and return
6666
# NOTE: we don't mark noreturn since that control flow might confuse ptxas

src/device/intrinsics/atomics.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ const atomic_acquire_release = LLVM.API.LLVMAtomicOrderingAcquireRelease
2727
# > that points to either the global address space or the shared address space.
2828
@generated function llvm_atomic_op(::Val{binop}, ptr::LLVMPtr{T,A}, val::T) where {binop, T, A}
2929
@dispose ctx=Context() begin
30-
T_val = convert(LLVMType, T; ctx)
31-
T_ptr = convert(LLVMType, ptr; ctx)
30+
T_val = convert(LLVMType, T)
31+
T_ptr = convert(LLVMType, ptr)
3232

3333
T_typed_ptr = LLVM.PointerType(T_val, A)
3434

3535
llvm_f, _ = create_function(T_val, [T_ptr, T_val])
3636

37-
@dispose builder=IRBuilder(ctx) begin
38-
entry = BasicBlock(llvm_f, "entry"; ctx)
37+
@dispose builder=IRBuilder() begin
38+
entry = BasicBlock(llvm_f, "entry")
3939
position!(builder, entry)
4040

4141
typed_ptr = bitcast!(builder, parameters(llvm_f)[1], T_typed_ptr)
@@ -109,15 +109,15 @@ end
109109

110110
@generated function llvm_atomic_cas(ptr::LLVMPtr{T,A}, cmp::T, val::T) where {T, A}
111111
@dispose ctx=Context() begin
112-
T_val = convert(LLVMType, T; ctx)
113-
T_ptr = convert(LLVMType, ptr,;ctx)
112+
T_val = convert(LLVMType, T)
113+
T_ptr = convert(LLVMType, ptr)
114114

115115
T_typed_ptr = LLVM.PointerType(T_val, A)
116116

117117
llvm_f, _ = create_function(T_val, [T_ptr, T_val, T_val])
118118

119-
@dispose builder=IRBuilder(ctx) begin
120-
entry = BasicBlock(llvm_f, "entry"; ctx)
119+
@dispose builder=IRBuilder() begin
120+
entry = BasicBlock(llvm_f, "entry")
121121
position!(builder, entry)
122122

123123
typed_ptr = bitcast!(builder, parameters(llvm_f)[1], T_typed_ptr)

src/device/intrinsics/indexing.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ export
55

66
@generated function _index(::Val{name}, ::Val{range}) where {name, range}
77
@dispose ctx=Context() begin
8-
T_int32 = LLVM.Int32Type(ctx)
8+
T_int32 = LLVM.Int32Type()
99

1010
# create function
1111
llvm_f, _ = create_function(T_int32)
1212
mod = LLVM.parent(llvm_f)
1313

1414
# generate IR
15-
@dispose builder=IRBuilder(ctx) begin
16-
entry = BasicBlock(llvm_f, "entry"; ctx)
15+
@dispose builder=IRBuilder() begin
16+
entry = BasicBlock(llvm_f, "entry")
1717
position!(builder, entry)
1818

1919
# call the indexing intrinsic
@@ -22,9 +22,8 @@ export
2222
idx = call!(builder, intr_typ, intr)
2323

2424
# attach range metadata
25-
range_metadata = MDNode([ConstantInt(Int32(range.start); ctx),
26-
ConstantInt(Int32(range.stop); ctx)];
27-
ctx)
25+
range_metadata = MDNode([ConstantInt(Int32(range.start)),
26+
ConstantInt(Int32(range.stop))])
2827
metadata(idx)[LLVM.MD_range] = range_metadata
2928

3029
ret!(builder, idx)

src/device/intrinsics/memory_dynamic.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ export malloc
44

55
@generated function malloc(sz::Csize_t)
66
@dispose ctx=Context() begin
7-
T_pint8 = LLVM.PointerType(LLVM.Int8Type(ctx))
8-
T_size = convert(LLVMType, Csize_t; ctx)
9-
T_ptr = convert(LLVMType, Ptr{Cvoid}; ctx)
7+
T_pint8 = LLVM.PointerType(LLVM.Int8Type())
8+
T_size = convert(LLVMType, Csize_t)
9+
T_ptr = convert(LLVMType, Ptr{Cvoid})
1010

1111
# create function
1212
llvm_f, _ = create_function(T_ptr, [T_size])
@@ -20,16 +20,16 @@ export malloc
2020
#let attrs = function_attributes(intr)
2121
# AllocSizeNumElemsNotPresent = reinterpret(Cuint, Cint(-1))
2222
# packed_allocsize = Int64(1) << 32 | AllocSizeNumElemsNotPresent
23-
# push!(attrs, EnumAttribute("allocsize", packed_allocsize; ctx))
23+
# push!(attrs, EnumAttribute("allocsize", packed_allocsize))
2424
#end
2525
#let attrs = return_attributes(intr)
26-
# push!(attrs, EnumAttribute("noalias", 0; ctx))
27-
# push!(attrs, EnumAttribute("nonnull", 0; ctx))
26+
# push!(attrs, EnumAttribute("noalias", 0))
27+
# push!(attrs, EnumAttribute("nonnull", 0))
2828
#end
2929

3030
# generate IR
31-
@dispose builder=IRBuilder(ctx) begin
32-
entry = BasicBlock(llvm_f, "entry"; ctx)
31+
@dispose builder=IRBuilder() begin
32+
entry = BasicBlock(llvm_f, "entry")
3333
position!(builder, entry)
3434

3535
ptr = call!(builder, intr_typ, intr, [parameters(llvm_f)[1]])

src/device/intrinsics/memory_shared.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ dynamic_smem_size() =
7474
# get a pointer to shared memory, with known (static) or zero length (dynamic shared memory)
7575
@generated function emit_shmem(::Type{T}, ::Val{len}=Val(0)) where {T,len}
7676
@dispose ctx=Context() begin
77-
T_int8 = LLVM.Int8Type(ctx)
78-
T_ptr = convert(LLVMType, LLVMPtr{T,AS.Shared}; ctx)
77+
T_int8 = LLVM.Int8Type()
78+
T_ptr = convert(LLVMType, LLVMPtr{T,AS.Shared})
7979

8080
# create a function
8181
llvm_f, _ = create_function(T_ptr)
@@ -121,11 +121,11 @@ dynamic_smem_size() =
121121
alignment!(gv, align)
122122

123123
# generate IR
124-
@dispose builder=IRBuilder(ctx) begin
125-
entry = BasicBlock(llvm_f, "entry"; ctx)
124+
@dispose builder=IRBuilder() begin
125+
entry = BasicBlock(llvm_f, "entry")
126126
position!(builder, entry)
127127

128-
ptr = gep!(builder, gv_typ, gv, [ConstantInt(0; ctx), ConstantInt(0; ctx)])
128+
ptr = gep!(builder, gv_typ, gv, [ConstantInt(0), ConstantInt(0)])
129129

130130
untyped_ptr = bitcast!(builder, ptr, T_ptr)
131131

src/device/intrinsics/output.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ end
4040
arg_exprs = [:( argspec[$i] ) for i in 1:length(argspec)]
4141
arg_types = [argspec...]
4242

43-
T_void = LLVM.VoidType(ctx)
44-
T_int32 = LLVM.Int32Type(ctx)
45-
T_pint8 = LLVM.PointerType(LLVM.Int8Type(ctx))
43+
T_void = LLVM.VoidType()
44+
T_int32 = LLVM.Int32Type()
45+
T_pint8 = LLVM.PointerType(LLVM.Int8Type())
4646

4747
# create functions
48-
param_types = LLVMType[convert(LLVMType, typ; ctx) for typ in arg_types]
48+
param_types = LLVMType[convert(LLVMType, typ) for typ in arg_types]
4949
llvm_f, llvm_ft = create_function(T_int32, param_types)
5050
mod = LLVM.parent(llvm_f)
5151

5252
# generate IR
53-
@dispose builder=IRBuilder(ctx) begin
54-
entry = BasicBlock(llvm_f, "entry"; ctx)
53+
@dispose builder=IRBuilder() begin
54+
entry = BasicBlock(llvm_f, "entry")
5555
position!(builder, entry)
5656

5757
str = globalstring_ptr!(builder, String(fmt))
@@ -60,7 +60,7 @@ end
6060
if isempty(argspec)
6161
buffer = LLVM.PointerNull(T_pint8)
6262
else
63-
argtypes = LLVM.StructType("printf_args"; ctx)
63+
argtypes = LLVM.StructType("printf_args")
6464
elements!(argtypes, param_types)
6565

6666
args = alloca!(builder, argtypes)

src/device/random.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ end
156156
# a hacky method of exposing constant tables as constant GPU memory
157157
function emit_constant_array(name::Symbol, data::AbstractArray{T}) where {T}
158158
@dispose ctx=Context() begin
159-
T_val = convert(LLVMType, T; ctx)
160-
T_ptr = convert(LLVMType, LLVMPtr{T,AS.Constant}; ctx)
159+
T_val = convert(LLVMType, T)
160+
T_ptr = convert(LLVMType, LLVMPtr{T,AS.Constant})
161161

162162
# define function and get LLVM module
163163
llvm_f, _ = create_function(T_ptr)
@@ -170,14 +170,14 @@ function emit_constant_array(name::Symbol, data::AbstractArray{T}) where {T}
170170
gv = GlobalVariable(mod, T_global, "gpu_$(name)_data", AS.Constant)
171171
alignment!(gv, 16)
172172
linkage!(gv, LLVM.API.LLVMInternalLinkage)
173-
initializer!(gv, ConstantArray(data; ctx))
173+
initializer!(gv, ConstantArray(data))
174174

175175
# generate IR
176-
@dispose builder=IRBuilder(ctx) begin
177-
entry = BasicBlock(llvm_f, "entry"; ctx)
176+
@dispose builder=IRBuilder() begin
177+
entry = BasicBlock(llvm_f, "entry")
178178
position!(builder, entry)
179179

180-
ptr = gep!(builder, T_global, gv, [ConstantInt(0; ctx), ConstantInt(0; ctx)])
180+
ptr = gep!(builder, T_global, gv, [ConstantInt(0), ConstantInt(0)])
181181

182182
untyped_ptr = bitcast!(builder, ptr, T_ptr)
183183

0 commit comments

Comments
 (0)