-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[Verifier] Remove redundant null-check (NFC) #157458
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
Conversation
@llvm/pr-subscribers-debuginfo @llvm/pr-subscribers-llvm-ir Author: Daniel Kuts (apach301) ChangesFixes #157448 Full diff: https://github.com/llvm/llvm-project/pull/157458.diff 1 Files Affected:
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index f38871f09f35f..57ea5b53647aa 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -3188,7 +3188,7 @@ void Verifier::visitFunction(const Function &F) {
if (SP && ((Scope != SP) && !Seen.insert(SP).second))
return;
- CheckDI(SP->describes(&F),
+ CheckDI(SP && SP->describes(&F),
"!dbg attachment points at wrong subprogram for function", N, &F,
&I, DL, Scope, SP);
};
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kindly add a test, showing that this bug can actually be hit.
It was a static analyzer report, so I don't know how to run this code and have any input data. But the problem in this code is that 'SP' could be NULL - in previous if-statement it is checked on NULL. So it also shoulf be checked in current function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think DISubprogram::getSubprogram can return null:
DISubprogram *DILocalScope::getSubprogram() const {
if (auto *Block = dyn_cast<DILexicalBlockBase>(this))
return Block->getScope()->getSubprogram();
return const_cast<DISubprogram *>(cast<DISubprogram>(this));
}
So, the check SP &&
preceding your patch should probably be stripped, as it is dead?
If it cant return nullptr after cast, then yes, I could remove both checks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the PR title/description. Suffix the title with "(NFC)" to make it clear that the change is non-functional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Fixes #157448