-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
Resolve static analyser report on pointer dereferencing after null check #88278
Merged
Conversation
This file contains 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
Contributor
mmoadeli
commented
Apr 10, 2024
- Resolve Static Analyzer Check Failure: Pointer Dereferencing After Null Check.
- Minor naming and style improvement
@llvm/pr-subscribers-backend-amdgpu Author: None (mmoadeli) Changes
Full diff: https://github.com/llvm/llvm-project/pull/88278.diff 1 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
index 595f09664c55e4..b2ab9d77ebe0f9 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
@@ -1052,21 +1052,18 @@ class AMDGPULowerModuleLDS {
void removeNoLdsKernelIdFromReachable(CallGraph &CG, Function *KernelRoot) {
KernelRoot->removeFnAttr("amdgpu-no-lds-kernel-id");
- SmallVector<Function *> Tmp({CG[KernelRoot]->getFunction()});
- if (!Tmp.back())
- return;
-
+ SmallVector<Function *> WorkList({CG[KernelRoot]->getFunction()});
SmallPtrSet<Function *, 8> Visited;
bool SeenUnknownCall = false;
- do {
- Function *F = Tmp.pop_back_val();
+ while (!WorkList.empty()) {
+ Function *F = WorkList.pop_back_val();
- for (auto &N : *CG[F]) {
- if (!N.second)
+ for (auto &CallRecord : *CG[F]) {
+ if (!CallRecord.second)
continue;
- Function *Callee = N.second->getFunction();
+ Function *Callee = CallRecord.second->getFunction();
if (!Callee) {
if (!SeenUnknownCall) {
SeenUnknownCall = true;
@@ -1074,21 +1071,20 @@ class AMDGPULowerModuleLDS {
// If we see any indirect calls, assume nothing about potential
// targets.
// TODO: This could be refined to possible LDS global users.
- for (auto &N : *CG.getExternalCallingNode()) {
- Function *PotentialCallee = N.second->getFunction();
- if (!isKernelLDS(PotentialCallee))
+ for (auto &ExternalCallRecord : *CG.getExternalCallingNode()) {
+ Function *PotentialCallee =
+ ExternalCallRecord.second->getFunction();
+ if (PotentialCallee && !isKernelLDS(PotentialCallee))
PotentialCallee->removeFnAttr("amdgpu-no-lds-kernel-id");
}
-
- continue;
}
+ } else {
+ Callee->removeFnAttr("amdgpu-no-lds-kernel-id");
+ if (Visited.insert(Callee).second)
+ WorkList.push_back(Callee);
}
-
- Callee->removeFnAttr("amdgpu-no-lds-kernel-id");
- if (Visited.insert(Callee).second)
- Tmp.push_back(Callee);
}
- } while (!Tmp.empty());
+ }
}
DenseMap<Function *, GlobalVariable *> lowerDynamicLDSVariables(
|
mmoadeli
changed the title
Resolve pointer dereferencing after null check static analyser check failure
Resolve static analyser check on pointer dereferencing after null check
Apr 10, 2024
mmoadeli
changed the title
Resolve static analyser check on pointer dereferencing after null check
Resolve static analyser report on pointer dereferencing after null check
Apr 10, 2024
arsenm
reviewed
Apr 12, 2024
arsenm
approved these changes
Apr 15, 2024
aniplcc
pushed a commit
to aniplcc/llvm-project
that referenced
this pull request
Apr 15, 2024
…eck (llvm#88278) - Resolve Static Analyzer Check Failure: Pointer Dereferencing After Null Check. - Minor naming and style improvement
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.