Skip to content

Commit bb68ada

Browse files
authored
Clean-up LLVM for SPIR-V before mcgen. (#277)
1 parent 48f8d45 commit bb68ada

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/spirv.jl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,26 @@ function finish_module!(job::CompilerJob{SPIRVCompilerTarget}, mod::LLVM.Module,
7070
MDNode([ConstantInt(Int32(1); ctx),
7171
ConstantInt(Int32(5); ctx)]; ctx))
7272

73+
return entry
74+
end
75+
76+
@unlocked function mcgen(job::CompilerJob{SPIRVCompilerTarget}, mod::LLVM.Module,
77+
format=LLVM.API.LLVMAssemblyFile)
78+
# The SPIRV Tools don't handle Julia's debug info, rejecting DW_LANG_Julia...
79+
strip_debuginfo!(mod)
80+
7381
ModulePassManager() do pm
7482
# SPIR-V does not support trap, and has no mechanism to abort compute kernels
7583
# (OpKill is only available in fragment execution mode)
7684
add!(pm, ModulePass("RemoveTrap", rm_trap!))
85+
86+
# the LLVM to SPIR-V translator does not support the freeze instruction
87+
# (SPIRV-LLVM-Translator#1140)
7788
add!(pm, ModulePass("RemoveFreeze", rm_freeze!))
7889

7990
run!(pm, mod)
8091
end
8192

82-
return entry
83-
end
84-
85-
@unlocked function mcgen(job::CompilerJob{SPIRVCompilerTarget}, mod::LLVM.Module,
86-
format=LLVM.API.LLVMAssemblyFile)
87-
# The SPIRV Tools don't handle Julia's debug info, rejecting DW_LANG_Julia...
88-
strip_debuginfo!(mod)
89-
9093
# translate to SPIR-V
9194
input = tempname(cleanup=false) * ".bc"
9295
translated = tempname(cleanup=false) * ".spv"

0 commit comments

Comments
 (0)