[llvm] [CodeLayout] Fix X1_Y_X2 and Y_X2_X1 testing for jumps from Y (PR #66592)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 17 01:08:20 PDT 2023


https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/66592

The CHECK2 test in code_placement_ext_tsp_large.ll now has the same result as
the CHECK test. Ideally we should have test coverage for
-ext-tsp-chain-split-threshold=1, but it seems challenging to craft one.
Perhaps the default value of -ext-tsp-chain-split-threshold can be decreased
as the -ext-tsp-enable-chain-split-along-jumps heuristic is now more powerful.


>From 26e84c05aa93025e723ff7e957934e3126f20a07 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Sun, 17 Sep 2023 00:51:32 -0700
Subject: [PATCH] [CodeLayout] Fix X1_Y_X2 and Y_X2_X1 testing for jumps from Y

The CHECK2 test in code_placement_ext_tsp_large.ll now has the same result as
the CHECK test. Ideally we should have test coverage for
-ext-tsp-chain-split-threshold=1, but it seems challenging to craft one.
Perhaps the default value of -ext-tsp-chain-split-threshold can be decreased
as the -ext-tsp-enable-chain-split-along-jumps heuristic is now more powerful.
---
 llvm/lib/Transforms/Utils/CodeLayout.cpp              | 2 +-
 llvm/test/CodeGen/X86/code_placement_ext_tsp_large.ll | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/CodeLayout.cpp b/llvm/lib/Transforms/Utils/CodeLayout.cpp
index c8c0823daaa6bd9..f020637ee186d38 100644
--- a/llvm/lib/Transforms/Utils/CodeLayout.cpp
+++ b/llvm/lib/Transforms/Utils/CodeLayout.cpp
@@ -850,7 +850,7 @@ class ExtTSPImpl {
 
       // Attach (a part of) ChainPred after the last node of ChainSucc.
       for (JumpT *Jump : ChainSucc->Nodes.back()->OutJumps) {
-        const NodeT *DstBlock = Jump->Source;
+        const NodeT *DstBlock = Jump->Target;
         if (DstBlock->CurChain != ChainPred)
           continue;
         size_t Offset = DstBlock->CurIndex;
diff --git a/llvm/test/CodeGen/X86/code_placement_ext_tsp_large.ll b/llvm/test/CodeGen/X86/code_placement_ext_tsp_large.ll
index 314df786b3e80b9..cee8489e9aaea0c 100644
--- a/llvm/test/CodeGen/X86/code_placement_ext_tsp_large.ll
+++ b/llvm/test/CodeGen/X86/code_placement_ext_tsp_large.ll
@@ -81,19 +81,18 @@ define void @func_large() !prof !0 {
 ; CHECK: b7
 ; CHECK: b9
 ;
-; An expected output with chain-split-threshold=1 (disabling splitting) -- the
-; increase of the layout score is smaller, ~7%:
+; An expected output with chain-split-threshold=1 (disabling split point enumeration)
 ;
 ; CHECK2-LABEL: Applying ext-tsp layout
 ; CHECK2:   original  layout score: 9171074274.27
-; CHECK2:   optimized layout score: 9810644873.57
+; CHECK2:   optimized layout score: 10844307310.87
 ; CHECK2: b0
 ; CHECK2: b2
 ; CHECK2: b3
 ; CHECK2: b4
 ; CHECK2: b5
-; CHECK2: b1
 ; CHECK2: b8
+; CHECK2: b1
 ; CHECK2: b6
 ; CHECK2: b7
 ; CHECK2: b9



More information about the llvm-commits mailing list