Skip to content

Commit ad101a4

Browse files
committed
after merging with Niklas
1 parent c7101a0 commit ad101a4

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

docs/src/lecture_09/irtools.jl

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ profile_fun(f::Core.Builtin, args...) = f(args...)
2727

2828
@dynamo function profile_fun(f, args...)
2929
ir = IRTools.Inner.IR(f, args...)
30-
for b in IRTools.blocks(ir)
31-
for (v, ex) in b
32-
if timable(ex.expr)
33-
fname = exportname(ex.expr)
34-
insert!(b, v, xcall(Main, :record_start, fname))
35-
insertafter!(b, v, xcall(Main, :record_end, fname))
36-
end
30+
for (v, ex) in ir
31+
if timable(ex.expr)
32+
fname = exportname(ex.expr)
33+
insert!(ir, v, xcall(Main, :record_start, fname))
34+
insertafter!(ir, v, xcall(Main, :record_end, fname))
3735
end
3836
end
3937
for (x, st) in ir
@@ -44,6 +42,13 @@ profile_fun(f::Core.Builtin, args...) = f(args...)
4442
return ir
4543
end
4644

45+
function foo(x, y)
46+
z = x * y
47+
z + sin(y)
48+
end
49+
4750
reset!(to)
4851
profile_fun(foo, 1.0, 1.0)
49-
to
52+
to
53+
54+
@record foo(1.0, 1.0) => profile_fun(foo, 1.0, 1.0)

docs/src/lecture_09/lecture.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ end
2222
```
2323
now observe the output
2424
```julia
25+
julia> genplus(1.0, 1.0) == 1.0 + 1.0
2526
generating genplus(x, y)
2627
(x, y, typeof(x), typeof(y)) = (Float64, Float64, DataType, DataType)
2728
executing generated genplus(x, y)

0 commit comments

Comments
 (0)