Skip to content

Commit 05fdfbe

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: 192c735: Initialize members, use std::move, use const& in loops
Coverity related fixes. Initialize members, use std::move, use const& in loops, organize code in a way that's easier to analyze for Coverity.
1 parent f8b61aa commit 05fdfbe

File tree

6 files changed

+64
-46
lines changed

6 files changed

+64
-46
lines changed

IGC/AdaptorCommon/RayTracing/TraceRayInlineLoweringPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ using namespace RTStackFormat;
3434
//Lowering pass for Synchronous raytracing intrinsics known as TraceRayInline/RayQuery
3535
class TraceRayInlineLoweringPass : public FunctionPass
3636
{
37-
LoopInfo* LI = nullptr;
37+
LoopInfo* LI;
3838
public:
3939
TraceRayInlineLoweringPass() : FunctionPass(ID) {
4040
initializeTraceRayInlineLoweringPassPass(*PassRegistry::getPassRegistry());

IGC/Compiler/CISACodeGen/CShader.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,25 @@ CShader::CShader(Function *pFunc, CShaderProgram *pProgram, GenericShaderState &
3737
, encoder()
3838
{
3939
m_ctx = m_parent->GetContext();
40+
m_WI = nullptr;
41+
m_deSSA = nullptr;
42+
m_coalescingEngine = nullptr;
43+
m_DL = nullptr;
44+
m_FGA = nullptr;
45+
m_VRA = nullptr;
46+
m_RLA = nullptr;
47+
m_EmitPass = nullptr;
48+
m_HW_TID = nullptr;
49+
50+
m_shaderStats = nullptr;
51+
// [OCL] preAnalysis()/ParseShaderSpecificOpcode() must
52+
// set this to ture if there is any stateless access.
53+
m_HasGlobalStatelessMemoryAccess = false;
54+
m_HasConstantStatelessMemoryAccess = false;
55+
56+
m_SavedSRetPtr = nullptr;
57+
m_FP = nullptr;
58+
m_SavedFP = nullptr;
4059

4160
bool SepSpillPvtSS = SeparateSpillAndScratch(m_ctx);
4261
bool SeparateScratchWA =

IGC/Compiler/CISACodeGen/ResourceLoopUnroll.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ bool ResourceLoopUnroll::emitResourceLoop(llvm::CallInst* CI)
152152

153153
GetResourceOperand(inst, resource, pairTexture, texture, sampler);
154154

155+
// either resource (ld instr), or sample instr must be available
156+
if (!resource && (!pairTexture || !texture || !sampler))
157+
{
158+
IGC_ASSERT(0);
159+
}
160+
155161
// Fill UniformSendBB
156162
builder.SetInsertPoint(checkBB);
157163

@@ -164,7 +170,7 @@ bool ResourceLoopUnroll::emitResourceLoop(llvm::CallInst* CI)
164170
resourceNew->setName("firstActiveRes");
165171
cond = builder.CreateICmpEQ(resource, resourceNew);
166172
}
167-
else if (pairTexture && texture && sampler) // then must be sampler
173+
else // then must be sampler
168174
{
169175
samplerNew = sampler;
170176
textureNew = texture;
@@ -218,10 +224,6 @@ bool ResourceLoopUnroll::emitResourceLoop(llvm::CallInst* CI)
218224
cond = samplerCond;
219225
}
220226
}
221-
else
222-
{
223-
IGC_ASSERT(0);
224-
}
225227

226228
// Here we swap the last loop load and goto, such as
227229
// From

IGC/Compiler/CISACodeGen/ShaderCodeGen.hpp

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ class CShader
399399
SIMDMode m_SIMDSize{};
400400
uint8_t m_numberInstance = 0;
401401
PushInfo pushInfo;
402-
EmitPass* m_EmitPass = nullptr;
402+
EmitPass* m_EmitPass;
403403
uint m_sendStallCycle = 0;
404404
uint m_staticCycle = 0;
405405
uint m_loopNestedStallCycle = 0;
@@ -648,19 +648,19 @@ class CShader
648648
e_alignment preferredAlign);
649649

650650
protected:
651-
CShaderProgram* m_parent = nullptr;
652-
CodeGenContext* m_ctx = nullptr;
653-
WIAnalysis* m_WI = nullptr;
654-
DeSSA* m_deSSA = nullptr;
655-
CoalescingEngine* m_coalescingEngine = nullptr;
656-
CodeGenPatternMatch* m_CG = nullptr;
657-
llvm::DominatorTree* m_DT = nullptr;
658-
const llvm::DataLayout* m_DL = nullptr;
659-
GenXFunctionGroupAnalysis* m_FGA = nullptr;
660-
VariableReuseAnalysis* m_VRA = nullptr;
661-
ResourceLoopAnalysis* m_RLA = nullptr;
662-
663-
IGC::IGCMD::MetaDataUtils* m_pMdUtils = nullptr;
651+
CShaderProgram* m_parent;
652+
CodeGenContext* m_ctx;
653+
WIAnalysis* m_WI;
654+
DeSSA* m_deSSA;
655+
CoalescingEngine* m_coalescingEngine;
656+
CodeGenPatternMatch* m_CG;
657+
llvm::DominatorTree* m_DT;
658+
const llvm::DataLayout* m_DL;
659+
GenXFunctionGroupAnalysis* m_FGA;
660+
VariableReuseAnalysis* m_VRA;
661+
ResourceLoopAnalysis* m_RLA;
662+
663+
IGC::IGCMD::MetaDataUtils* m_pMdUtils;
664664

665665
#if defined(_DEBUG) || defined(_INTERNAL)
666666
llvm::SpecificBumpPtrAllocator<CVariable> Allocator;
@@ -698,26 +698,26 @@ class CShader
698698

699699
uint m_maxBlockId = 0;
700700

701-
CVariable* m_R0 = nullptr;
702-
CVariable* m_NULL = nullptr;
703-
CVariable* m_TSC = nullptr;
704-
CVariable* m_SR0 = nullptr;
705-
CVariable* m_CR0 = nullptr;
706-
CVariable* m_CE0 = nullptr;
707-
CVariable* m_MSG0 = nullptr;
708-
CVariable* m_DBG = nullptr;
709-
CVariable* m_HW_TID = nullptr;
710-
CVariable* m_SP = nullptr;
711-
CVariable* m_FP = nullptr;
712-
CVariable* m_SavedFP = nullptr;
713-
CVariable* m_ARGV = nullptr;
701+
CVariable* m_R0;
702+
CVariable* m_NULL;
703+
CVariable* m_TSC;
704+
CVariable* m_SR0;
705+
CVariable* m_CR0;
706+
CVariable* m_CE0;
707+
CVariable* m_MSG0;
708+
CVariable* m_DBG;
709+
CVariable* m_HW_TID;
710+
CVariable* m_SP;
711+
CVariable* m_FP;
712+
CVariable* m_SavedFP;
713+
CVariable* m_ARGV;
714714
std::array<CVariable*, NUM_ARG_SPACE_RESERVATION_SLOTS> m_ARGVReservedVariables{};
715715
uint32_t m_ARGVReservedVariablesTotalSize = 0;
716-
CVariable* m_RETV = nullptr;
717-
CVariable* m_SavedSRetPtr = nullptr;
718-
CVariable* m_ImplArgBufPtr = nullptr;
719-
CVariable* m_LocalIdBufPtr = nullptr;
720-
CVariable* m_GlobalBufferArg = nullptr;
716+
CVariable* m_RETV;
717+
CVariable* m_SavedSRetPtr;
718+
CVariable* m_ImplArgBufPtr;
719+
CVariable* m_LocalIdBufPtr;
720+
CVariable* m_GlobalBufferArg;
721721

722722
/// holds max number of inputs that can be pushed for this shader unit
723723
static const uint32_t m_pMaxNumOfPushedInputs;
@@ -731,11 +731,8 @@ class CShader
731731
// Those two are for stateful token setup. It is a quick
732732
// special case checking. Once a generic approach is added,
733733
// this two fields shall be retired.
734-
//
735-
// [OCL] preAnalysis()/ParseShaderSpecificOpcode() must
736-
// set this to true if there is any stateless access.
737-
bool m_HasGlobalStatelessMemoryAccess = false;
738-
bool m_HasConstantStatelessMemoryAccess = false;
734+
bool m_HasGlobalStatelessMemoryAccess;
735+
bool m_HasConstantStatelessMemoryAccess;
739736

740737
bool m_HasGlobalAtomics = false;
741738

IGC/Compiler/Optimizer/WaveShuffleIndexSinking.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ namespace IGC
8888
}
8989

9090
// Update ShuffleGroup members
91-
HoistOrAnchorInstsIdx = std::move(NewHoistOrAnchorInstsIdx);
91+
HoistOrAnchorInstsIdx = NewHoistOrAnchorInstsIdx;
9292
InstChains.push_back( InstChainA );
9393
InstChains.push_back( InstChainB );
9494
ShuffleOps.push_back( shuffleInst );
@@ -116,7 +116,7 @@ namespace IGC
116116
}
117117

118118
// Update ShuffleGroup members
119-
HoistOrAnchorInstsIdx = std::move(NewHoistOrAnchorInstsIdx); // this should be the same size as NewInstChain
119+
HoistOrAnchorInstsIdx = NewHoistOrAnchorInstsIdx; // this should be the same size as NewInstChain
120120
InstChains.push_back( NewInstChain );
121121
ShuffleOps.push_back( shuffleInst );
122122
return true;

IGC/WrapperLLVM/include/llvmWrapper/IR/Instructions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ inline unsigned getArgOperandNo(llvm::CallInst &CI, const llvm::Use *U) {
202202
// calls through CB.getCalledFunction() would leave indirect calls unhandled.
203203
inline void setMemoryEffects(llvm::CallBase &CB, IGCLLVM::MemoryEffects ME) {
204204
CB.removeFnAttrs(ME.getOverridenAttrKinds());
205-
for (const auto& MemAttr : ME.getAsAttributeSet(CB.getContext()))
205+
for (auto MemAttr : ME.getAsAttributeSet(CB.getContext()))
206206
CB.addFnAttr(MemAttr);
207207
}
208208

0 commit comments

Comments
 (0)