Skip to content

Commit 40b663a

Browse files
authored
Merge pull request #339 from JuliaGPU/tb/fixes
Minor drive-by improvements.
2 parents dac277c + 187587f commit 40b663a

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

src/irgen.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,16 +463,13 @@ function lower_byval(@nospecialize(job::CompilerJob), mod::LLVM.Module, f::LLVM.
463463
arg.cc != GHOST
464464
end
465465
for arg in args
466-
if arg.cc == BITS_REF
467-
# NOTE: +1 since this pass runs after introducing the kernel state
468-
byval[arg.codegen.i] = true
469-
end
466+
byval[arg.codegen.i] = (arg.cc == BITS_REF)
470467
end
471468
end
472469

473470
# fixup metadata
474471
#
475-
# Julia emits invariant.load and const TBAA metadta on loads from pointer args,
472+
# Julia emits invariant.load and const TBAA metadata on loads from pointer args,
476473
# which is invalid now that we have materialized the byval.
477474
for (i, param) in enumerate(parameters(f))
478475
if byval[i]
@@ -519,7 +516,7 @@ function lower_byval(@nospecialize(job::CompilerJob), mod::LLVM.Module, f::LLVM.
519516
# emit IR performing the "conversions"
520517
new_args = LLVM.Value[]
521518
@dispose builder=Builder(ctx) begin
522-
entry = BasicBlock(new_f, "entry"; ctx)
519+
entry = BasicBlock(new_f, "conversion"; ctx)
523520
position!(builder, entry)
524521

525522
# perform argument conversions

src/spirv.jl

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,7 @@ function wrap_byval(@nospecialize(job::CompilerJob), mod::LLVM.Module, f::LLVM.F
237237
arg.cc != GHOST
238238
end
239239
for arg in args
240-
if arg.cc == BITS_REF
241-
byval[arg.codegen.i] = true
242-
end
240+
byval[arg.codegen.i] = (arg.cc == BITS_REF)
243241
end
244242
end
245243

@@ -264,7 +262,7 @@ function wrap_byval(@nospecialize(job::CompilerJob), mod::LLVM.Module, f::LLVM.F
264262
# emit IR performing the "conversions"
265263
new_args = Vector{LLVM.Value}()
266264
@dispose builder=Builder(ctx) begin
267-
entry = BasicBlock(new_f, "entry"; ctx)
265+
entry = BasicBlock(new_f, "conversion"; ctx)
268266
position!(builder, entry)
269267

270268
# perform argument conversions
@@ -310,17 +308,5 @@ function wrap_byval(@nospecialize(job::CompilerJob), mod::LLVM.Module, f::LLVM.F
310308
unsafe_delete!(mod, f)
311309
LLVM.name!(new_f, fn)
312310

313-
# clean-up
314-
# NOTE: byval wrapping happens very late, after optimization
315-
@dispose pm=ModulePassManager() begin
316-
# merge GEPs
317-
instruction_combining!(pm)
318-
319-
# fold the entry bb into the rest of the function
320-
cfgsimplification!(pm)
321-
322-
run!(pm, mod)
323-
end
324-
325311
return new_f
326312
end

0 commit comments

Comments
 (0)