-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Verifier: Avoid unnecessary hasFnAttr #138104
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When checking string attribute values are valid, it's not necessary to check hasFnAttr prior to querying the value.
@llvm/pr-subscribers-llvm-ir Author: Matt Arsenault (arsenm) ChangesWhen checking string attribute values are valid, it's not Full diff: https://github.com/llvm/llvm-project/pull/138104.diff 1 Files Affected:
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 262e7022099d7..f1b12d94a2bbd 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2388,18 +2388,20 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
CheckFailed("'vscale_range' maximum must be power-of-two value", V);
}
- if (Attrs.hasFnAttr("frame-pointer")) {
- StringRef FP = Attrs.getFnAttr("frame-pointer").getValueAsString();
+ if (Attribute FPAttr = Attrs.getFnAttr("frame-pointer"); FPAttr.isValid()) {
+ StringRef FP = FPAttr.getValueAsString();
if (FP != "all" && FP != "non-leaf" && FP != "none" && FP != "reserved")
CheckFailed("invalid value for 'frame-pointer' attribute: " + FP, V);
}
// Check EVEX512 feature.
- if (MaxParameterWidth >= 512 && Attrs.hasFnAttr("target-features") &&
- TT.isX86()) {
- StringRef TF = Attrs.getFnAttr("target-features").getValueAsString();
- Check(!TF.contains("+avx512f") || !TF.contains("-evex512"),
- "512-bit vector arguments require 'evex512' for AVX512", V);
+ if (TT.isX86() && MaxParameterWidth >= 512) {
+ Attribute TargetFeaturesAttr = Attrs.getFnAttr("target-features");
+ if (TargetFeaturesAttr.isValid()) {
+ StringRef TF = TargetFeaturesAttr.getValueAsString();
+ Check(!TF.contains("+avx512f") || !TF.contains("-evex512"),
+ "512-bit vector arguments require 'evex512' for AVX512", V);
+ }
}
checkUnsignedBaseTenFuncAttr(Attrs, "patchable-function-prefix", V);
|
nikic
approved these changes
May 1, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
When checking string attribute values are valid, it's not necessary to check hasFnAttr prior to querying the value.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
When checking string attribute values are valid, it's not necessary to check hasFnAttr prior to querying the value.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
When checking string attribute values are valid, it's not necessary to check hasFnAttr prior to querying the value.
GeorgeARM
pushed a commit
to GeorgeARM/llvm-project
that referenced
this pull request
May 7, 2025
When checking string attribute values are valid, it's not necessary to check hasFnAttr prior to querying the value.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When checking string attribute values are valid, it's not
necessary to check hasFnAttr prior to querying the value.