From c4393f2fbd7077ff35cf145d6eebabc6397941f9 Mon Sep 17 00:00:00 2001 From: Abul Date: Mon, 20 Jul 2026 23:46:58 +0530 Subject: [PATCH 1/3] Test --- .github/workflows/perf.yml | 3 +++ compiler/src/dmd/main.d | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/.github/workflows/perf.yml b/.github/workflows/perf.yml index 348959d32167..207d5949448e 100644 --- a/.github/workflows/perf.yml +++ b/.github/workflows/perf.yml @@ -115,6 +115,9 @@ jobs: --host-dmd "$HOST_DMD" \ --out "$GITHUB_WORKSPACE/results.json" + - name: Show results + run: cat "$GITHUB_WORKSPACE/results.json" + # perf-comment.yml picks this up and posts the comment. - name: Upload results if: github.event_name == 'pull_request' diff --git a/compiler/src/dmd/main.d b/compiler/src/dmd/main.d index 2d7f3739d7c6..59fc1c660824 100644 --- a/compiler/src/dmd/main.d +++ b/compiler/src/dmd/main.d @@ -178,6 +178,21 @@ private int tryMain(const(char)[][] argv, out Param params) Strings libmodules; global._init(); + // TESTING ONLY — deliberate busy loop to verify perf bot detects regressions. + // Uses XOR-shift (non-linear recurrence) so LLVM -O3 + LTO cannot reduce it. + // Remove before merging. + { + long dummy = 1; + foreach (i; 0 .. 500_000) + { + dummy ^= (dummy << 13); + dummy ^= (dummy >>> 7); + dummy ^= (dummy << 17); + } + if (dummy == 0) + fputs("", stderr); + } + ErrorSink eSink = global.errorSink; scope(exit) From 2c181ab27dbea63222f657f149172a5a90398dbe Mon Sep 17 00:00:00 2001 From: Abul Date: Tue, 21 Jul 2026 00:02:51 +0530 Subject: [PATCH 2/3] test 2 --- compiler/src/dmd/main.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/src/dmd/main.d b/compiler/src/dmd/main.d index 59fc1c660824..e2412fa9598e 100644 --- a/compiler/src/dmd/main.d +++ b/compiler/src/dmd/main.d @@ -180,9 +180,10 @@ private int tryMain(const(char)[][] argv, out Param params) // TESTING ONLY — deliberate busy loop to verify perf bot detects regressions. // Uses XOR-shift (non-linear recurrence) so LLVM -O3 + LTO cannot reduce it. + // Seed from argv.length (runtime value) prevents compile-time constant folding. // Remove before merging. { - long dummy = 1; + long dummy = argv.length | 1; foreach (i; 0 .. 500_000) { dummy ^= (dummy << 13); From 281f25429e97c23979a8cc148b1d7b653ee766a1 Mon Sep 17 00:00:00 2001 From: Abul Date: Tue, 21 Jul 2026 00:17:34 +0530 Subject: [PATCH 3/3] test 3 --- compiler/src/dmd/main.d | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/compiler/src/dmd/main.d b/compiler/src/dmd/main.d index e2412fa9598e..a3cccbbad59b 100644 --- a/compiler/src/dmd/main.d +++ b/compiler/src/dmd/main.d @@ -179,19 +179,34 @@ private int tryMain(const(char)[][] argv, out Param params) global._init(); // TESTING ONLY — deliberate busy loop to verify perf bot detects regressions. - // Uses XOR-shift (non-linear recurrence) so LLVM -O3 + LTO cannot reduce it. - // Seed from argv.length (runtime value) prevents compile-time constant folding. + // Uses ldc.llvmasm optimization barrier so LLVM cannot constant-fold or delete + // the loop. Same technique as Google Benchmark's DoNotOptimize. // Remove before merging. { - long dummy = argv.length | 1; - foreach (i; 0 .. 500_000) + version (LDC) { - dummy ^= (dummy << 13); - dummy ^= (dummy >>> 7); - dummy ^= (dummy << 17); + import ldc.llvmasm; + long dummy = 1; + foreach (i; 0 .. 500_000) + { + dummy ^= (dummy << 13); + dummy ^= (dummy >>> 7); + dummy ^= (dummy << 17); + __asm!void("", "r,~{memory}", dummy); + } + } + else + { + long dummy = 1; + foreach (i; 0 .. 500_000) + { + dummy ^= (dummy << 13); + dummy ^= (dummy >>> 7); + dummy ^= (dummy << 17); + } + if (dummy == 0) + fputs("", stderr); } - if (dummy == 0) - fputs("", stderr); } ErrorSink eSink = global.errorSink;