Skip to content

[CodeLayout] Do not verify after assigning blocks #111754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

ellishg
Copy link
Contributor

@ellishg ellishg commented Oct 9, 2024

Rather than invariantly running F->verify() when asserts are enabled, run machine IR verification in LIT tests only.

Swap CHECK-PERF and CHECK-SIZE in code_placement_ext_tsp_large.ll.

Remove ={0,1,true,false} from flags in tests.

@llvmbot
Copy link
Member

llvmbot commented Oct 9, 2024

@llvm/pr-subscribers-backend-x86

Author: Ellis Hoag (ellishg)

Changes

Rather than invariantly running F->verify() when asserts are enabled, run machine IR verification in LIT tests only.

Swap CHECK-PERF and CHECK-SIZE in code_placement_ext_tsp_large.ll.

Remove ={0,1,true,false} from flags in tests.


Full diff: https://github.com/llvm/llvm-project/pull/111754.diff

4 Files Affected:

  • (modified) llvm/lib/CodeGen/MachineBlockPlacement.cpp (+1-6)
  • (modified) llvm/test/CodeGen/X86/code_placement_ext_tsp.ll (+1-1)
  • (modified) llvm/test/CodeGen/X86/code_placement_ext_tsp_large.ll (+4-4)
  • (modified) llvm/test/CodeGen/X86/code_placement_ext_tsp_size.ll (+17-17)
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index c42e63202c3b5a..dd5220b4599f95 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -3572,7 +3572,7 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &MF) {
   if (UseExtTspForPerf || UseExtTspForSize) {
     assert(
         !(UseExtTspForPerf && UseExtTspForSize) &&
-        "UseExtTspForPerf and UseExtTspForSize can not be set simultaneosly");
+        "UseExtTspForPerf and UseExtTspForSize can not be set simultaneously");
     applyExtTsp(/*OptForSize=*/UseExtTspForSize);
     createCFGChainExtTsp();
   }
@@ -3745,11 +3745,6 @@ void MachineBlockPlacement::assignBlockOrder(
       continue;
     MBB.updateTerminator(FTMBB);
   }
-
-#ifndef NDEBUG
-  // Make sure we correctly constructed all branches.
-  F->verify(this, "After optimized block reordering", &errs());
-#endif
 }
 
 void MachineBlockPlacement::createCFGChainExtTsp() {
diff --git a/llvm/test/CodeGen/X86/code_placement_ext_tsp.ll b/llvm/test/CodeGen/X86/code_placement_ext_tsp.ll
index be0b9820e14541..37e3245467c869 100644
--- a/llvm/test/CodeGen/X86/code_placement_ext_tsp.ll
+++ b/llvm/test/CodeGen/X86/code_placement_ext_tsp.ll
@@ -1,5 +1,5 @@
 ;; See also llvm/unittests/Transforms/Utils/CodeLayoutTest.cpp
-; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -enable-ext-tsp-block-placement=1 < %s | FileCheck %s
+; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -verify-machineinstrs -enable-ext-tsp-block-placement < %s | FileCheck %s
 
 define void @func1a()  {
 ; Test that the algorithm positions the most likely successor first
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 ac172d32c6d8b6..24c52f1e88656e 100644
--- a/llvm/test/CodeGen/X86/code_placement_ext_tsp_large.ll
+++ b/llvm/test/CodeGen/X86/code_placement_ext_tsp_large.ll
@@ -1,8 +1,8 @@
 ; REQUIRES: asserts
-; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -enable-ext-tsp-block-placement=1 -ext-tsp-chain-split-threshold=128 -debug-only=block-placement < %s 2>&1 | FileCheck %s
-; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -enable-ext-tsp-block-placement=1 -ext-tsp-chain-split-threshold=1 -debug-only=block-placement < %s 2>&1 | FileCheck %s -check-prefix=CHECK2
-; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -enable-ext-tsp-block-placement=0 -debug-only=block-placement < %s 2>&1 | FileCheck %s -check-prefix=CHECK3
-; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -enable-ext-tsp-block-placement=1 -ext-tsp-block-placement-max-blocks=8 -debug-only=block-placement < %s 2>&1 | FileCheck %s -check-prefix=CHECK4
+; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -verify-machineinstrs -enable-ext-tsp-block-placement -ext-tsp-chain-split-threshold=128 -debug-only=block-placement < %s 2>&1 | FileCheck %s
+; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -verify-machineinstrs -enable-ext-tsp-block-placement -ext-tsp-chain-split-threshold=1 -debug-only=block-placement < %s 2>&1 | FileCheck %s -check-prefix=CHECK2
+; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -verify-machineinstrs -debug-only=block-placement < %s 2>&1 | FileCheck %s -check-prefix=CHECK3
+; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -verify-machineinstrs -enable-ext-tsp-block-placement -ext-tsp-block-placement-max-blocks=8 -debug-only=block-placement < %s 2>&1 | FileCheck %s -check-prefix=CHECK4
 
 @yydebug = dso_local global i32 0, align 4
 
diff --git a/llvm/test/CodeGen/X86/code_placement_ext_tsp_size.ll b/llvm/test/CodeGen/X86/code_placement_ext_tsp_size.ll
index 59eaf2586f1737..e7a4d6d8fd23a5 100644
--- a/llvm/test/CodeGen/X86/code_placement_ext_tsp_size.ll
+++ b/llvm/test/CodeGen/X86/code_placement_ext_tsp_size.ll
@@ -1,5 +1,5 @@
-; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -apply-ext-tsp-for-size=true  < %s | FileCheck %s -check-prefix=CHECK-PERF
-; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -apply-ext-tsp-for-size=false < %s | FileCheck %s -check-prefix=CHECK-SIZE
+; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -verify-machineinstrs -apply-ext-tsp-for-size < %s | FileCheck %s -check-prefix=CHECK-SIZE
+; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -verify-machineinstrs < %s | FileCheck %s -check-prefix=CHECK-PERF
 
 define void @func1() minsize {
 ;
@@ -19,15 +19,15 @@ define void @func1() minsize {
 ; | b2  | <+
 ; +-----+
 ;
-; CHECK-PERF-LABEL: func1:
-; CHECK-PERF: %b0
-; CHECK-PERF: %b1
-; CHECK-PERF: %b2
-;
 ; CHECK-SIZE-LABEL: func1:
 ; CHECK-SIZE: %b0
-; CHECK-SIZE: %b2
 ; CHECK-SIZE: %b1
+; CHECK-SIZE: %b2
+;
+; CHECK-PERF-LABEL: func1:
+; CHECK-PERF: %b0
+; CHECK-PERF: %b2
+; CHECK-PERF: %b1
 
 b0:
   %call = call zeroext i1 @a()
@@ -75,21 +75,21 @@ define void @func_loop() minsize !prof !9 {
 ;                  |  end   |
 ;                  +--------+
 ;
-; CHECK-PERF-LABEL: func_loop:
-; CHECK-PERF: %entry
-; CHECK-PERF: %header
-; CHECK-PERF: %if.then
-; CHECK-PERF: %if.else
-; CHECK-PERF: %if.end
-; CHECK-PERF: %end
-;
 ; CHECK-SIZE-LABEL: func_loop:
 ; CHECK-SIZE: %entry
 ; CHECK-SIZE: %header
+; CHECK-SIZE: %if.then
 ; CHECK-SIZE: %if.else
 ; CHECK-SIZE: %if.end
-; CHECK-SIZE: %if.then
 ; CHECK-SIZE: %end
+;
+; CHECK-PERF-LABEL: func_loop:
+; CHECK-PERF: %entry
+; CHECK-PERF: %header
+; CHECK-PERF: %if.else
+; CHECK-PERF: %if.end
+; CHECK-PERF: %if.then
+; CHECK-PERF: %end
 
 entry:
   br label %header

Copy link
Contributor

@spupyrev spupyrev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@ellishg ellishg merged commit cb5fbd2 into llvm:main Oct 10, 2024
10 checks passed
@ellishg ellishg deleted the block-placement-verifier branch October 10, 2024 16:11
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
Rather than invariantly running `F->verify()` when asserts are enabled,
run machine IR verification in LIT tests only.

Swap `CHECK-PERF` and `CHECK-SIZE` in `code_placement_ext_tsp_large.ll`.

Remove `={0,1,true,false}` from flags in tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants