Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CassetteBase/src/CassetteBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ function transform_stmt(@nospecialize(x), map_slot_number, map_ssa_value, @nospe
if isa(x, Expr)
head = x.head
if head === :call
return Expr(:call, SlotNumber(1), map(transform, x.args[1:end])...)
arg1 = x.args[1]
if ((arg1 === Base.cglobal || (arg1 isa GlobalRef && arg1.name === :cglobal)) ||
(arg1 === Core.tuple || (arg1 isa GlobalRef && arg1.name === :tuple)))
return Expr(:call, map(transform, x.args)...) # don't cassette this -- we still have non-linearized cglobal
end
return Expr(:call, SlotNumber(1), map(transform, x.args)...)
elseif head === :foreigncall
arg1 = x.args[1]
if Meta.isexpr(arg1, :call)
Expand Down
5 changes: 5 additions & 0 deletions CassetteBase/test/test_basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ let pass = BasicPass()
@test pass(sin, 1) == sin(1)
@test_throws MethodError pass("1") do x; sin(x); end
end
const libccalltest = "libccalltest"
fcglobal() = unsafe_load(cglobal((:global_var, libccalltest), Cint))
let pass = BasicPass()
@test pass(fcglobal) isa Cint
end

struct RaisePass end
@eval function (pass::RaisePass)(fargs...)
Expand Down
Loading