Skip to content

Commit 624d863

Browse files
authored
Avoid calling rand if using Base.donotdelete.
1 parent 174c1fa commit 624d863

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/LinuxPerf.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,12 +1140,14 @@ macro pstats(args...)
11401140
try
11411141
enable_all!()
11421142
val = $(esc(expr))
1143+
disable_all!()
1144+
# trick the compiler not to eliminate the code
11431145
@static if isdefined(Base, :donotdelete)
11441146
Base.donotdelete(val)
1147+
stats = Stats(bench)
1148+
else
1149+
stats = @noinline rand() < 0 ? val : Stats(bench)
11451150
end
1146-
disable_all!()
1147-
# trick the compiler not to eliminate the code
1148-
stats = @noinline rand() < 0 ? val : Stats(bench)
11491151
return stats::Stats
11501152
catch
11511153
rethrow()

0 commit comments

Comments
 (0)