Skip to content

Commit e4576f1

Browse files
igorban-inteligcbot
authored andcommitted
Fixed warning from statical code analizer
.
1 parent 5a2d94c commit e4576f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+193
-161
lines changed

IGC/VectorCompiler/igcdeps/include/vc/igcdeps/cmc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ class CMKernel {
4141

4242
explicit CMKernel(const PLATFORM &platform);
4343
~CMKernel();
44+
CMKernel(const CMKernel &) = delete;
45+
CMKernel &operator=(const CMKernel &) = delete;
4446

4547
PLATFORM m_platform;
4648
IGC::SOpenCLKernelInfo m_kernelInfo;
4749
IGC::COCLBTILayout m_btiLayout;
48-
uint32_t m_GRFSizeInBytes;
50+
uint32_t m_GRFSizeInBytes = 0;
4951
bool m_SupportsDebugging = false;
5052

5153
// getter for convenience

IGC/VectorCompiler/include/vc/Support/BackendConfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ class GenXBackendConfig : public ImmutablePass {
233233

234234
public:
235235
GenXBackendConfig();
236-
explicit GenXBackendConfig(GenXBackendOptions OptionsIn,
237-
GenXBackendData DataIn);
236+
explicit GenXBackendConfig(GenXBackendOptions &&OptionsIn,
237+
GenXBackendData &&DataIn);
238238

239239
// Return whether regalloc results should be printed.
240240
bool enableRegAllocDump() const { return Options.DumpRegAlloc; }

IGC/VectorCompiler/include/vc/Utils/General/InstRebuilder.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*========================== begin_copyright_notice ============================
22
3-
Copyright (C) 2021 Intel Corporation
3+
Copyright (C) 2021-2023 Intel Corporation
44
55
SPDX-License-Identifier: MIT
66
@@ -153,7 +153,7 @@ class InstructionRebuilder {
153153
InstructionRebuilder(RebuildInfo ToRebuildIn,
154154
IsSpecialInstFunc IsSpecialInstIn,
155155
CreateSpecialInstFunc CreateSpecialInstIn)
156-
: ToRebuild{ToRebuildIn}, IsSpecialInst{IsSpecialInstIn},
156+
: ToRebuild{std::move(ToRebuildIn)}, IsSpecialInst{IsSpecialInstIn},
157157
CreateSpecialInst{CreateSpecialInstIn} {}
158158

159159
void rebuild() && {
@@ -203,14 +203,14 @@ class InstructionRebuilder {
203203
CurInst =
204204
std::accumulate(First, LastUse, std::move(CurInst),
205205
[this](InstToRebuild Inst, const UseToRebuild &Use) {
206-
return appendOperand(Inst, Use);
206+
return appendOperand(std::move(Inst), Use);
207207
});
208208
return {CurInst, LastUse};
209209
}
210210

211211
// Appends operand/use from \p CurUse to \p InstInfo.
212212
// Returns updated \p InstInfo.
213-
InstToRebuild appendOperand(InstToRebuild InstInfo,
213+
InstToRebuild appendOperand(InstToRebuild &&InstInfo,
214214
const UseToRebuild &CurUse) {
215215
IGC_ASSERT_MESSAGE(InstInfo.User == CurUse.User,
216216
"trying to append a wrong use with wrong user");

IGC/VectorCompiler/lib/GenXCodeGen/ConstantEncoder.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*========================== begin_copyright_notice ============================
22
3-
Copyright (C) 2021 Intel Corporation
3+
Copyright (C) 2021-2023 Intel Corporation
44
55
SPDX-License-Identifier: MIT
66
@@ -28,7 +28,8 @@ encodeConstExprImpl(const llvm::GEPOperator &GEP, const DataLayout &DL) {
2828
bool Success = GEP.accumulateConstantOffset(DL, Offset);
2929
IGC_ASSERT_MESSAGE(Success,
3030
"Offset must be constant for GEP constant expression");
31-
return {Data + Offset, Relocs};
31+
Data += Offset;
32+
return {std::move(Data), Relocs};
3233
}
3334

3435
static std::pair<APInt, std::vector<vISA::ZERelocEntry>>

IGC/VectorCompiler/lib/GenXCodeGen/FunctionGroup.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*========================== begin_copyright_notice ============================
22
3-
Copyright (C) 2017-2021 Intel Corporation
3+
Copyright (C) 2017-2023 Intel Corporation
44
55
SPDX-License-Identifier: MIT
66
@@ -182,6 +182,9 @@ class FunctionGroupAnalysis : public ModulePass {
182182
static char ID;
183183
explicit FunctionGroupAnalysis() : ModulePass(ID) {}
184184
~FunctionGroupAnalysis() { clear(); }
185+
FunctionGroupAnalysis(const FunctionGroupAnalysis &) = delete;
186+
FunctionGroupAnalysis &operator=(const FunctionGroupAnalysis &) = delete;
187+
185188
StringRef getPassName() const override { return "function group analysis"; }
186189
// runOnModule : does almost nothing
187190
bool runOnModule(Module &ArgM) override {
@@ -439,6 +442,9 @@ class DominatorTreeGroupWrapperPass
439442
public:
440443
DominatorTreeGroupWrapperPass() {}
441444
~DominatorTreeGroupWrapperPass() { releaseMemory(); }
445+
DominatorTreeGroupWrapperPass(const DominatorTreeGroupWrapperPass &) = delete;
446+
DominatorTreeGroupWrapperPass &
447+
operator=(const DominatorTreeGroupWrapperPass &) = delete;
442448

443449
DominatorTree *getDomTree(Function *F) { return DTs[F]; }
444450

@@ -471,6 +477,9 @@ class LoopInfoGroupWrapperPass : public FGPassImplInterface,
471477
public:
472478
LoopInfoGroupWrapperPass() {}
473479
~LoopInfoGroupWrapperPass() { releaseMemory(); }
480+
LoopInfoGroupWrapperPass(const LoopInfoGroupWrapperPass &) = delete;
481+
LoopInfoGroupWrapperPass &
482+
operator=(const LoopInfoGroupWrapperPass &) = delete;
474483

475484
LoopInfo *getLoopInfo(Function *F) { return LIs[F]; }
476485
const DominatorTree &getDomTree();

IGC/VectorCompiler/lib/GenXCodeGen/GenXAddressCommoning.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*========================== begin_copyright_notice ============================
22
3-
Copyright (C) 2017-2022 Intel Corporation
3+
Copyright (C) 2017-2023 Intel Corporation
44
55
SPDX-License-Identifier: MIT
66
@@ -918,7 +918,7 @@ bool GenXAddressCommoning::vectorizeAddrsFromOneVector(
918918
Type *FirstType = Extracts[0].Addr->getOperand(0)->getType();
919919
IGC_ASSERT(FirstType);
920920

921-
for (auto e : Extracts) {
921+
for (auto &e : Extracts) {
922922
Type *Tp = e.Addr->getOperand(0)->getType();
923923
if (ConvertWholeRegion && (Tp != FirstType))
924924
return false;

IGC/VectorCompiler/lib/GenXCodeGen/GenXAggregatePseudoLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*========================== begin_copyright_notice ============================
22
3-
Copyright (C) 2020-2021 Intel Corporation
3+
Copyright (C) 2020-2023 Intel Corporation
44
55
SPDX-License-Identifier: MIT
66
@@ -399,7 +399,7 @@ static std::vector<Instruction *>
399399
createSplitInsts(Instruction &Inst, const SplitOpsMap &SplitOps,
400400
const std::vector<IdxListType> &IdxLists) {
401401
std::vector<Instruction *> NewInsts;
402-
for (auto IdxList : enumerate(IdxLists)) {
402+
for (auto &IdxList : enumerate(IdxLists)) {
403403
auto NewOps =
404404
createSplitInstOperands(IdxList.index(), Inst.operands(), SplitOps);
405405
NewInsts.push_back(createSplitInst(Inst, NewOps, IdxList.value()));

IGC/VectorCompiler/lib/GenXCodeGen/GenXAlignmentInfo.h

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*========================== begin_copyright_notice ============================
22
3-
Copyright (C) 2017-2021 Intel Corporation
3+
Copyright (C) 2017-2023 Intel Corporation
44
55
SPDX-License-Identifier: MIT
66
@@ -9,24 +9,26 @@ SPDX-License-Identifier: MIT
99
//
1010
/// genx::AlignmentInfo : alignment information
1111
/// -------------------------------------------
12-
///
12+
///
1313
/// AlignmentInfo is a cache of information on the alignment of instruction
1414
/// values in a function. It does not persist between passes.
1515
///
16-
/// A pass that needs alignment information constructs an AlignmentInfo at
16+
/// A pass that needs alignment information constructs an AlignmentInfo at
1717
/// the start of the pass, and then calls the ``get`` method each time it wants
18-
/// alignment information for a particular instruction value. AlignmentInfo
19-
/// calculates it if it is not already in its cache, which probably involves
20-
/// also calculating the alignment of other instructions that the given one
18+
/// alignment information for a particular instruction value. AlignmentInfo
19+
/// calculates it if it is not already in its cache, which probably involves
20+
/// also calculating the alignment of other instructions that the given one
2121
/// depends on.
2222
///
23-
/// This cacheing and lazy calculation is done instead of having a separate analysis
24-
/// pass because alignment is needed for only a small subset of values in a function.
23+
/// This cacheing and lazy calculation is done instead of having a separate
24+
/// analysis pass because alignment is needed for only a small subset of values
25+
/// in a function.
2526
///
2627
/// The alignment is returned as an *Alignment* object with three fields:
27-
/// *ConstBits*, if ConstBits is not 0x7fffffff, alignment is a known bit-pattern,
28-
/// otherwise *LogAlign* and *ExtraBits* (where 0 <= ExtraBits < (1 << LogAlign)),
29-
/// stating that the value is known to be A << LogAlign | ExtraBits for some A.
28+
/// *ConstBits*, if ConstBits is not 0x7fffffff, alignment is a known
29+
/// bit-pattern, otherwise *LogAlign* and *ExtraBits* (where 0 <= ExtraBits < (1
30+
/// << LogAlign)), stating that the value is known to be A << LogAlign |
31+
/// ExtraBits for some A.
3032
///
3133
/// For a vector value, the alignment information is for element 0.
3234
///
@@ -68,19 +70,6 @@ class Alignment {
6870
Alignment(unsigned C);
6971
// Constructor given Constant.
7072
Alignment(Constant *C);
71-
// Copy-constructor
72-
Alignment(const Alignment& Rhs) {
73-
LogAlign = Rhs.LogAlign;
74-
ExtraBits = Rhs.ExtraBits;
75-
ConstBits = Rhs.ConstBits;
76-
}
77-
// Copy-operator
78-
Alignment& operator=(const Alignment &Rhs) {
79-
LogAlign = Rhs.LogAlign;
80-
ExtraBits = Rhs.ExtraBits;
81-
ConstBits = Rhs.ConstBits;
82-
return *this;
83-
}
8473

8574
// Get an unknown alignment
8675
static Alignment getUnknown() { return Alignment(0, 0); }

IGC/VectorCompiler/lib/GenXCodeGen/GenXArgIndirection.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*========================== begin_copyright_notice ============================
22
3-
Copyright (C) 2017-2022 Intel Corporation
3+
Copyright (C) 2017-2023 Intel Corporation
44
55
SPDX-License-Identifier: MIT
66
@@ -305,13 +305,20 @@ class SubroutineArg {
305305
Function *F = nullptr;
306306
Function *NewFunc = nullptr;
307307
public:
308-
Argument *AddressArgument;
308+
Argument *AddressArgument = nullptr;
309309
SubroutineArg(GenXArgIndirection *Pass, LiveRange *ArgLR, Argument *Arg)
310310
: Pass(Pass), ArgLR(ArgLR), Arg(Arg), F(Arg->getParent()), NewFunc(nullptr) {}
311311
~SubroutineArg() {
312312
for (auto i = CallSites.begin(), e = CallSites.end(); i != e; ++i)
313313
delete *i;
314314
}
315+
SubroutineArg() = delete;
316+
SubroutineArg(const SubroutineArg &) = delete;
317+
SubroutineArg &operator=(const SubroutineArg &) = delete;
318+
319+
SubroutineArg(SubroutineArg &&) = default;
320+
SubroutineArg &operator=(SubroutineArg &&) = delete;
321+
315322
Indirectability checkIndirectability();
316323
ArgIndCallSite *createCallSite(CallInst *CI);
317324
Alignment getIndirectAlignment(unsigned GRFWidth) const;
@@ -496,7 +503,7 @@ static Value *searchForArg(Value *V) {
496503
std::vector<GenXArgIndirection::ArgToConvertAddr>
497504
GenXArgIndirection::collectAlreadyIndirected(LiveRange *ArgLR) {
498505
std::vector<GenXArgIndirection::ArgToConvertAddr> IndirectedArgInfo;
499-
for (auto VI : ArgLR->getValues()) {
506+
for (auto &VI : ArgLR->getValues()) {
500507
Value *Base = VI.getValue();
501508
std::vector<Value *> Addrs = Liveness->getAddressWithBase(Base);
502509
// Not a base
@@ -638,7 +645,7 @@ bool GenXArgIndirection::processArgLR(LiveRange *ArgLR)
638645
ArgToAddressArg.insert(SubrArg->addAddressArg());
639646
// Since the ArgLR has been set to NONE category, it cannot be used as a base
640647
// register and the indirected argument address should be used instead.
641-
for (auto Info : IndirectedArgInfo) {
648+
for (auto &Info : IndirectedArgInfo) {
642649
IGC_ASSERT_MESSAGE(ArgToAddressArg.count(Info.Arg),
643650
"Cannot find indirected arg");
644651
Liveness->setArgAddressBase(Info.ConvertAddr, ArgToAddressArg[Info.Arg]);

IGC/VectorCompiler/lib/GenXCodeGen/GenXBaling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,7 @@ void GenXBaling::processMainInst(Instruction *Inst, int IntrinID) {
14391439
// For an intrinsic, check the arg info of each arg to see if we can
14401440
// bale into it.
14411441
GenXIntrinsicInfo Info(IntrinID);
1442-
for (auto AI : Info.getInstDesc()) {
1442+
for (auto &AI : Info.getInstDesc()) {
14431443
if (AI.isArgOrRet() && !AI.isRet()) {
14441444
unsigned ArgIdx = AI.getArgIdx();
14451445
switch (AI.getCategory()) {

IGC/VectorCompiler/lib/GenXCodeGen/GenXCFSimplification.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,9 @@ BasicBlock *GenXCFSimplification::processBranchedOverBlock(BasicBlock *BB)
284284
Value *V = Phi->getIncomingValueForBlock(BB);
285285
replaceAndRecursivelySimplify(Phi, V);
286286
} else {
287-
unsigned PredIdx = Phi->getBasicBlockIndex(Pred);
288-
unsigned BBIdx = Phi->getBasicBlockIndex(BB);
287+
auto PredIdx = Phi->getBasicBlockIndex(Pred);
288+
auto BBIdx = Phi->getBasicBlockIndex(BB);
289+
IGC_ASSERT_EXIT(PredIdx >= 0 && BBIdx >= 0);
289290
Phi->setIncomingValue(PredIdx, Phi->getIncomingValue(BBIdx));
290291
Phi->removeIncomingValue(BBIdx);
291292
}

IGC/VectorCompiler/lib/GenXCodeGen/GenXCategory.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ namespace {
302302
vc::RegCategory MostUsedCat_;
303303

304304
public:
305-
UsesCatInfo() : Uses_(), Mask_(0), MaxAlign_(0) {}
305+
UsesCatInfo()
306+
: Uses_(), Mask_(0), MaxAlign_(0), MostUsedCat_(vc::RegCategory::None) {
307+
}
306308

307309
UsesCatInfo(const GenXCategory &PassInfo, Value *V) : UsesCatInfo() {
308310
std::array<int, vc::numRegCategories()> Stat = {0};
@@ -667,7 +669,7 @@ bool GenXCategory::processValue(Value *V)
667669

668670
Liveness->getOrCreateLiveRange(V, DefInfo.Cat, std::max(DefInfo.Align, UsesInfo.getMaxAlign()));
669671
auto Convs = buildConversions(V, DefInfo, UsesInfo);
670-
for (auto UseInfo : UsesInfo.getUses()) {
672+
for (auto &UseInfo : UsesInfo.getUses()) {
671673
if (UseInfo.Cat != DefInfo.Cat && UseInfo.Cat != vc::RegCategory::None) {
672674
Instruction *Conv;
673675
if (UseInfo.Cat == vc::RegCategory::Address) {

IGC/VectorCompiler/lib/GenXCodeGen/GenXCisaBuilder.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ class GenXKernelBuilder {
556556
Function *Func = nullptr;
557557
// function corresponding to VISAKernel currently being written
558558
Function *KernFunc = nullptr;
559-
PreDefined_Surface StackSurf;
559+
PreDefined_Surface StackSurf = PreDefined_Surface::PREDEFINED_SURFACE_INVALID;
560560

561561
std::map<Function *, VISA_GenVar *> FPMap;
562562
SmallVector<InsertValueInst *, 10> RetvInserts;
@@ -944,6 +944,8 @@ class GenXKernelBuilder {
944944
collectKernelInfo();
945945
}
946946
~GenXKernelBuilder() { clearLoops(); }
947+
GenXKernelBuilder(const GenXKernelBuilder &) = delete;
948+
GenXKernelBuilder &operator=(const GenXKernelBuilder &) = delete;
947949
void clearLoops() {
948950
for (auto i = Loops.begin(), e = Loops.end(); i != e; ++i) {
949951
delete i->second;
@@ -1627,11 +1629,11 @@ void GenXKernelBuilder::buildInstructions() {
16271629
auto Phi = dyn_cast<PHINode>(&*si);
16281630
if (!Phi)
16291631
break;
1630-
IGC_ASSERT_EXIT(Phi->getBasicBlockIndex(BB) >= 0);
1632+
auto PredIdx = Phi->getBasicBlockIndex(BB);
1633+
IGC_ASSERT_EXIT(PredIdx >= 0);
16311634
if (Phi->getType()->getPrimitiveSizeInBits() >=
16321635
(GrfByteSize * 8) * 4 &&
1633-
isa<UndefValue>(
1634-
Phi->getIncomingValue(Phi->getBasicBlockIndex(BB))))
1636+
isa<UndefValue>(Phi->getIncomingValue(PredIdx)))
16351637
addLifetimeStartInst(Phi);
16361638
}
16371639
}
@@ -5043,6 +5045,7 @@ void GenXKernelBuilder::buildConvertAddr(CallInst *CI, genx::BaleInfo BI,
50435045
CI);
50445046
}
50455047
} else {
5048+
IGC_ASSERT_EXIT(GrfByteSize > 0);
50465049
uint8_t rowOffset = Offset >> genx::log2(GrfByteSize);
50475050
uint8_t colOffset = (Offset & (GrfByteSize - 1)) >> Log2_32(ElementBytes);
50485051
auto TypeSize = BaseReg->Ty->getScalarType()->getPrimitiveSizeInBits() >> 3;

IGC/VectorCompiler/lib/GenXCodeGen/GenXCoalescing.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ void GenXCoalescing::processPhiNodes(FunctionGroup *FG)
10871087
// Perform copy of uncoalesced phi node incomings.
10881088
// New phis can be created during this, store them.
10891089
std::vector<PHINode *> NewPhis;
1090-
for (auto Elem : PhiCopies) {
1090+
for (auto &Elem : PhiCopies) {
10911091
processPhiCopy(Elem.Phi, Elem.IncomingIdx, NewPhis);
10921092
}
10931093
// Phi copies are resolved. Clean the list.
@@ -1107,7 +1107,7 @@ void GenXCoalescing::processPhiNodes(FunctionGroup *FG)
11071107
NewPhis.clear();
11081108

11091109
// Perform copy of uncoalesced phi node incomings.
1110-
for (auto Elem : PhiCopies) {
1110+
for (auto &Elem : PhiCopies) {
11111111
processPhiCopy(Elem.Phi, Elem.IncomingIdx, NewPhis);
11121112
}
11131113
// Phi copies are resolved. Clean the list.
@@ -1899,9 +1899,9 @@ void GenXCoalescing::applyCopiesOptimized() {
18991899
// it is still simple linear traverse through all copies.
19001900

19011901
// Traverse all LRs
1902-
for (auto LRDataIt : SortedCD.CopiesPerLR) {
1902+
for (auto &LRDataIt : SortedCD.CopiesPerLR) {
19031903
// Traverse all copy values
1904-
for (auto CDIt : LRDataIt.second.CopiesPerValue) {
1904+
for (auto &CDIt : LRDataIt.second.CopiesPerValue) {
19051905
// Finally we got into current copy candidates.
19061906
// Traverse all copy data.
19071907
applyCopiesForValue(CDIt.second);

0 commit comments

Comments
 (0)