From 94bf4a325c4dec3d7f5cd114142f5145c1e675e9 Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Wed, 11 Dec 2024 16:32:58 +0000 Subject: [PATCH] Use `Base.donotdelete` to avoid code elision Also bump Julia compatibility to >=1.8 --- Project.toml | 2 +- src/LinuxPerf.jl | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index ffd0ef9..a7a81f1 100644 --- a/Project.toml +++ b/Project.toml @@ -8,4 +8,4 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" [compat] PrettyTables = "2" -julia = "1" +julia = "1.8" diff --git a/src/LinuxPerf.jl b/src/LinuxPerf.jl index 3f37499..af9f044 100644 --- a/src/LinuxPerf.jl +++ b/src/LinuxPerf.jl @@ -1139,11 +1139,10 @@ macro pstats(args...) bench = make_bench_threaded(groups, threads = $(opts.threads)) try enable_all!() - val = $(esc(expr)) + Base.donotdelete($(esc(expr))) disable_all!() # trick the compiler not to eliminate the code - stats = rand() < 0 ? val : Stats(bench) - return stats::Stats + return Stats(bench)::Stats catch rethrow() finally