Skip to content

Commit 58ad14f

Browse files
fda0igcbot
authored andcommitted
Coverity fixes and refactors
Initialize uninitialized variables. Use cast instead of dyn_cast.
1 parent a37bd51 commit 58ad14f

File tree

6 files changed

+17
-18
lines changed

6 files changed

+17
-18
lines changed

IGC/Compiler/CISACodeGen/OpenCLOptions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,12 @@ void Options::parseOptions(const char* opts)
524524
}
525525
}
526526

527-
for (auto arg : apiOptions.getAllArgValues(OPT_large_grf_kernel_common))
527+
for (const auto& arg : apiOptions.getAllArgValues(OPT_large_grf_kernel_common))
528528
{
529529
LargeGRFKernels.push_back(arg);
530530
}
531531

532-
for (auto arg : apiOptions.getAllArgValues(OPT_regular_grf_kernel_common))
532+
for (const auto& arg : apiOptions.getAllArgValues(OPT_regular_grf_kernel_common))
533533
{
534534
RegularGRFKernels.push_back(arg);
535535
}

IGC/Compiler/Optimizer/OpenCLPasses/BufferBoundsChecking/BufferBoundsChecking.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ IGC_INITIALIZE_PASS_END(BufferBoundsChecking, PASS_FLAG, PASS_DESCRIPTION, PASS_
4242

4343
char BufferBoundsChecking::ID = 0;
4444

45-
BufferBoundsChecking::BufferBoundsChecking()
46-
: ModulePass(ID), modified(false), kernelArgs(nullptr), bufferSizePlaceholderFunction(nullptr)
45+
BufferBoundsChecking::BufferBoundsChecking() : ModulePass(ID)
4746
{
4847
initializeBufferBoundsCheckingPass(*PassRegistry::getPassRegistry());
4948
}

IGC/Compiler/Optimizer/OpenCLPasses/BufferBoundsChecking/BufferBoundsChecking.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ namespace IGC
5959
llvm::Value* elementSizeInBytes;
6060
};
6161

62-
bool modified;
62+
bool modified = false;
6363

64-
IGCMD::MetaDataUtils* metadataUtils;
65-
ModuleMetaData* moduleMetadata;
66-
ImplicitArgs* implicitArgs;
67-
KernelArgs* kernelArgs;
64+
IGCMD::MetaDataUtils* metadataUtils = nullptr;
65+
ModuleMetaData* moduleMetadata = nullptr;
66+
ImplicitArgs* implicitArgs = nullptr;
67+
KernelArgs* kernelArgs = nullptr;
6868
llvm::SmallVector<llvm::Instruction*, 4> loadsAndStoresToCheck;
6969
llvm::DenseMap<llvm::StringRef, llvm::GlobalVariable*> stringsCache;
70-
llvm::DICompileUnit* compileUnit;
71-
llvm::Function* bufferSizePlaceholderFunction;
70+
llvm::DICompileUnit* compileUnit = nullptr;
71+
llvm::Function* bufferSizePlaceholderFunction = nullptr;
7272

7373
void handleLoadStore(llvm::Instruction* instruction);
7474

IGC/Compiler/Optimizer/OpenCLPasses/BufferBoundsChecking/BufferBoundsCheckingPatcher.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ bool BufferBoundsCheckingPatcher::runOnModule(Module& M)
6969
continue;
7070
}
7171

72-
auto bufferSize = getBufferSizeArg(call->getFunction(), (uint32_t)dyn_cast<ConstantInt>(call->getArgOperand(0))->getSExtValue());
72+
auto bufferSize = getBufferSizeArg(call->getFunction(), (uint32_t)cast<ConstantInt>(call->getArgOperand(0))->getSExtValue());
7373
//auto bufferSize = ConstantInt::get(Type::getInt64Ty(call->getContext()), 64); // Only for testing purposes
7474
call->replaceAllUsesWith(bufferSize);
7575
toRemove.push_back(call);

IGC/Compiler/Optimizer/OpenCLPasses/BufferBoundsChecking/BufferBoundsCheckingPatcher.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ namespace IGC
4444
void visitCallInst(llvm::CallInst& icmp);
4545

4646
private:
47-
ImplicitArgs* implicitArgs;
48-
IGCMD::MetaDataUtils* metadataUtils;
47+
ImplicitArgs* implicitArgs = nullptr;
48+
IGCMD::MetaDataUtils* metadataUtils = nullptr;
4949
llvm::SmallVector<llvm::CallInst*, 8> toRemove;
5050

5151
llvm::Argument* getBufferSizeArg(llvm::Function* function, uint32_t n);

visa/LocalScheduler/SWSB_G4IR.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ class G4_BB_SB {
621621
// TODO: May want to change these to use llvm allocator as well.
622622
vISA::Mem_Manager &mem;
623623
G4_BB *bb;
624-
G4_Label *BBLabel;
624+
G4_Label *BBLabel = nullptr;
625625
int nodeID;
626626
int ALUID;
627627

@@ -641,7 +641,7 @@ class G4_BB_SB {
641641
unsigned short getDpasSrcCacheSize(Gen4_Operand_Number opNum) const;
642642

643643
public:
644-
LiveGRFBuckets *send_use_kills;
644+
LiveGRFBuckets *send_use_kills = nullptr;
645645
BB_SWSB_LIST Preds;
646646
BB_SWSB_LIST Succs;
647647

@@ -680,8 +680,8 @@ class G4_BB_SB {
680680
std::vector<BitSet> tokeNodesMap;
681681
int first_DPASID = 0;
682682
int last_DPASID = 0;
683-
unsigned *tokenLiveInDist;
684-
unsigned *tokenLiveOutDist;
683+
unsigned *tokenLiveInDist = nullptr;
684+
unsigned *tokenLiveOutDist = nullptr;
685685
SBBitSets localReachingSends;
686686
SBBitSets
687687
BBGRF; // Is used to record the GRF registers accessed by each basic block

0 commit comments

Comments
 (0)