Skip to content
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

[NFC][X86][ISel] Remove the unused assert #133029

Merged
merged 1 commit into from
Mar 26, 2025

Conversation

shining1984
Copy link
Contributor

@shining1984 shining1984 commented Mar 26, 2025

The condition of assert is always true, so just remove it.
OptForMinSize means hasMinSize(), which is hasFnAttribute(Attribute::MinSize).
hasOptSize() is hasFnAttribute(Attribute::OptimizeForSize) || hasMinSize().
So, '!hasMinSize() || hasFnAttribute(Attribute::OptimizeForSize) || hasMinSize()' is awalys true.


llvm/include/llvm/IR/Function.h

/// Optimize this function for minimum size (-Oz).
  bool hasMinSize() const { return hasFnAttribute(Attribute::MinSize); }

  /// Optimize this function for size (-Os) or minimum size (-Oz).
  bool hasOptSize() const {
    return hasFnAttribute(Attribute::OptimizeForSize) || hasMinSize();
  }

The condition of assert is always true, so just remove it.
OptForMinSize means hasMinSize(), which is hasFnAttribute(Attribute::MinSize).
hasOptSize() is hasFnAttribute(Attribute::OptimizeForSize) || hasMinSize().
So, '!hasMinSize() || hasFnAttribute(Attribute::OptimizeForSize) || hasMinSize()'
is awalys true.
@llvmbot
Copy link
Member

llvmbot commented Mar 26, 2025

@llvm/pr-subscribers-backend-x86

Author: Ningning Shi(史宁宁) (shining1984)

Changes

The condition of assert is always true, so just remove it.
OptForMinSize means hasMinSize(), which is hasFnAttribute(Attribute::MinSize).
hasOptSize() is hasFnAttribute(Attribute::OptimizeForSize) || hasMinSize().
So, '!hasMinSize() || hasFnAttribute(Attribute::OptimizeForSize) || hasMinSize()' is awalys true.


llvm/include/llvm/IR/Function.h
` /// Optimize this function for minimum size (-Oz).
bool hasMinSize() const { return hasFnAttribute(Attribute::MinSize); }

/// Optimize this function for size (-Os) or minimum size (-Oz).
bool hasOptSize() const {
return hasFnAttribute(Attribute::OptimizeForSize) || hasMinSize();
}`


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

1 Files Affected:

  • (modified) llvm/lib/Target/X86/X86ISelDAGToDAG.cpp (-2)
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 878c054503473..d322e70fc0c20 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -184,8 +184,6 @@ namespace {
 
       // OptFor[Min]Size are used in pattern predicates that isel is matching.
       OptForMinSize = MF.getFunction().hasMinSize();
-      assert((!OptForMinSize || MF.getFunction().hasOptSize()) &&
-             "OptForMinSize implies OptForSize");
       return SelectionDAGISel::runOnMachineFunction(MF);
     }
 

Copy link
Contributor

@wangpc-pp wangpc-pp left a comment

Choose a reason for hiding this comment

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

LGTM. Good catch!

@wangpc-pp wangpc-pp merged commit ab5de9a into llvm:main Mar 26, 2025
13 checks passed
@shining1984 shining1984 deleted the X86ISelDAG_assert branch March 26, 2025 07:07
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.

3 participants