[llvm] 176a082 - [opt] Fix static code analysis concerns
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 19 11:35:34 PST 2023
Author: Arvind Sudarsanam
Date: 2023-01-19T11:35:15-08:00
New Revision: 176a0827de42f123436c8ab850ef009f9339b7b6
URL: https://github.com/llvm/llvm-project/commit/176a0827de42f123436c8ab850ef009f9339b7b6
DIFF: https://github.com/llvm/llvm-project/commit/176a0827de42f123436c8ab850ef009f9339b7b6.diff
LOG: [opt] Fix static code analysis concerns
This is an issue reported inside the NewPMDriver module. Static analyzer reported that Null pointer 'P' may be dereferenced at line 371 and two more sites. Proposed change guards this use.
Reviewed By: aeubanks
Differential Revision: https://reviews.llvm.org/D142047
Added:
Modified:
llvm/tools/opt/NewPMDriver.cpp
Removed:
################################################################################
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index 2e66c0b66f93d..a8db0c62898ee 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -354,11 +354,15 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
}
if (CSPGOKindFlag != NoCSPGO) {
if (P && (P->Action == PGOOptions::IRInstr ||
- P->Action == PGOOptions::SampleUse))
+ P->Action == PGOOptions::SampleUse)) {
errs() << "CSPGOKind cannot be used with IRInstr or SampleUse";
+ return false;
+ }
if (CSPGOKindFlag == CSInstrGen) {
- if (CSProfileGenFile.empty())
+ if (CSProfileGenFile.empty()) {
errs() << "CSInstrGen needs to specify CSProfileGenFile";
+ return false;
+ }
if (P) {
P->CSAction = PGOOptions::CSIRInstr;
P->CSProfileGenFile = CSProfileGenFile;
@@ -366,8 +370,10 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
P = PGOOptions("", CSProfileGenFile, ProfileRemappingFile,
PGOOptions::NoAction, PGOOptions::CSIRInstr);
} else /* CSPGOKindFlag == CSInstrUse */ {
- if (!P)
+ if (!P) {
errs() << "CSInstrUse needs to be together with InstrUse";
+ return false;
+ }
P->CSAction = PGOOptions::CSIRUse;
}
}
More information about the llvm-commits
mailing list