Skip to content

Commit bec0d23

Browse files
committed
add dce!
1 parent 1337258 commit bec0d23

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

lib/libLLVM_h.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4599,6 +4599,11 @@ function LLVMAddAggressiveDCEPass(PM)
45994599
@runtime_ccall((:LLVMAddAggressiveDCEPass,libllvm[]), Cvoid, (LLVMPassManagerRef,), PM)
46004600
end
46014601

4602+
# added in LLVM10
4603+
function LLVMAddDCEPass(PM)
4604+
@runtime_ccall((:LLVMAddDCEPass,libllvm[]), Cvoid, (LLVMPassManagerRef,), PM)
4605+
end
4606+
46024607
function LLVMAddBitTrackingDCEPass(PM)
46034608
@runtime_ccall((:LLVMAddBitTrackingDCEPass,libllvm[]), Cvoid, (LLVMPassManagerRef,), PM)
46044609
end

src/transform.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,20 @@ define_transforms([
101101
:LowerExpectIntrinsic, :TypeBasedAliasAnalysis, :ScopedNoAliasAA, :BasicAliasAnalysis
102102
])
103103

104-
export scalar_repl_aggregates!, scalar_repl_aggregates_ssa!
104+
export scalar_repl_aggregates!, scalar_repl_aggregates_ssa!, dce!
105105

106106
scalar_repl_aggregates!(pm::PassManager, threshold::Integer) =
107107
API.LLVMAddScalarReplAggregatesPassWithThreshold(pm, Cint(threshold))
108108

109109
scalar_repl_aggregates_ssa!(pm::PassManager) =
110110
API.LLVMAddScalarReplAggregatesPassSSA(pm)
111111

112+
if version() >= v"10.0"
113+
dce!(pm::PassManager) =
114+
API.LLVMAddDCEPass(pm)
115+
else
116+
dce!(pm::PassManager) = nothing
117+
end
112118

113119
## vectorization transformations
114120

test/transform.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Context() do ctx
3030
LLVM.Module("SomeModule", ctx) do mod
3131
ModulePassManager() do pm
3232
aggressive_dce!(pm)
33+
dce!(pm)
3334
bit_tracking_dce!(pm)
3435
alignment_from_assumptions!(pm)
3536
cfgsimplification!(pm)

0 commit comments

Comments
 (0)