Ai
21 Star 49 Fork 0

Gitee 极速下载/julia-language

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/JuliaLang/julia
克隆/下载
compact.jl 1.79 KB
一键复制 编辑 原始数据 按行查看 历史
# This file is a part of Julia. License is MIT: https://julialang.org/license
using Test
include("setup_Compiler.jl")
include("irutils.jl")
using .Compiler: IncrementalCompact, insert_node_here!, finish,
NewInstruction, verify_ir, ReturnNode, SSAValue
foo_test_function(i) = i == 1 ? 1 : 2
@testset "IncrementalCompact statefulness" begin
ir = only(Base.code_ircode(foo_test_function, (Int,)))[1]
compact = IncrementalCompact(ir)
# set up first iterator
x = Compiler.iterate(compact)
x = Compiler.iterate(compact, x[2])
# set up second iterator
x = Compiler.iterate(compact)
# consume remainder
while x !== nothing
x = Compiler.iterate(compact, x[2])
end
ir = finish(compact)
@test Compiler.verify_ir(ir) === nothing
end
# Test early finish of IncrementalCompact
@testset "IncrementalCompact early finish" begin
ir = only(Base.code_ircode(foo_test_function, (Int,)))[1]
compact = IncrementalCompact(ir)
insert_node_here!(compact, NewInstruction(ReturnNode(1), Union{}, ir[SSAValue(1)][:line]))
new_ir = finish(compact)
# TODO: Should IncrementalCompact be doing this internally?
empty!(new_ir.cfg.blocks[1].succs)
verify_ir(new_ir)
@test length(new_ir.cfg.blocks) == 1
end
# Test reverse affinity insert at start of compact
@testset "IncrementalCompact reverse affinity insert" begin
ir = only(Base.code_ircode(foo_test_function, (Int,)))[1]
compact = IncrementalCompact(ir)
@test !Compiler.did_just_finish_bb(compact)
insert_node_here!(compact, NewInstruction(ReturnNode(1), Union{}, ir[SSAValue(1)][:line]), true)
new_ir = finish(compact)
# TODO: Should IncrementalCompact be doing this internally?
empty!(new_ir.cfg.blocks[1].succs)
verify_ir(new_ir)
@test length(new_ir.cfg.blocks) == 1
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/mirrors/julia-language.git
git@gitee.com:mirrors/julia-language.git
mirrors
julia-language
julia-language
master

搜索帮助