Skip to content

Commit 8b6dfce

Browse files
fda0igcbot
authored andcommitted
Conform to rule of three
Delete destructors or delete copy constructors and copy assignment operators to conform to rule of three. User defined a special function (copy constructor, copy assignment operator, destructor). If one of these functions requires a user-definition then it is likely all of them should have a definition. To avoid erroneous copies and leaked resources we delete copy constructors that shouldn't be used.
1 parent ee5fcfe commit 8b6dfce

34 files changed

+53
-49
lines changed

IGC/AdaptorOCL/CLElfLib/ElfReader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class RAIIElf
105105
public:
106106
explicit RAIIElf(CElfReader *pElf);
107107
~RAIIElf();
108+
RAIIElf(const RAIIElf&) = delete;
109+
RAIIElf& operator=(const RAIIElf&) = delete;
108110
private:
109111
CElfReader *p;
110112
};

IGC/Compiler/CISACodeGen/CShaderProgram.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ namespace IGC
2828
typedef llvm::MapVector<llvm::Function*, CShaderProgram*> KernelShaderMap;
2929
CShaderProgram(CodeGenContext* ctx, llvm::Function* kernel);
3030
~CShaderProgram();
31+
CShaderProgram(const CShaderProgram&) = delete;
32+
CShaderProgram& operator=(const CShaderProgram&) = delete;
3133
CShader* GetOrCreateShader(SIMDMode simd, ShaderDispatchMode mode = ShaderDispatchMode::NOT_APPLICABLE);
3234
CShader* GetShader(SIMDMode simd, ShaderDispatchMode mode = ShaderDispatchMode::NOT_APPLICABLE);
3335
void DeleteShader(SIMDMode simd, ShaderDispatchMode mode = ShaderDispatchMode::NOT_APPLICABLE);

IGC/Compiler/CISACodeGen/helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,8 @@ namespace IGC
587587
struct Defer
588588
{
589589
Defer(Fn F) : F(F) {}
590+
Defer(const Defer&) = delete;
591+
Defer& operator=(const Defer&) = delete;
590592
~Defer() {
591593
if (Do) F();
592594
}

IGC/Compiler/CodeGenContextWrapper.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ CodeGenContextWrapper::CodeGenContextWrapper() : ImmutablePass(ID), m_ctx(nullpt
3737
IGC_ASSERT_MESSAGE(0, "CodeGenContextWrapper shouldn't get here in runtime");
3838
}
3939

40-
CodeGenContextWrapper::~CodeGenContextWrapper()
41-
{
42-
}
4340
CodeGenContext* CodeGenContextWrapper::getCodeGenContext()
4441
{
4542
return m_ctx;

IGC/Compiler/CodeGenContextWrapper.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ namespace IGC
3636
// Constructs a wrapper to the given CodeGenContext instance.
3737
CodeGenContextWrapper(CodeGenContext* pCtx);
3838
CodeGenContextWrapper();
39-
~CodeGenContextWrapper();
4039

4140
// return the Context
4241
CodeGenContext* getCodeGenContext();

IGC/Compiler/CustomLoopOpt.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ namespace IGC
9797
static char ID;
9898

9999
CustomLoopVersioning();
100-
~CustomLoopVersioning() { }
101100

102101
void getAnalysisUsage(llvm::AnalysisUsage& AU) const
103102
{

IGC/Compiler/CustomSafeOptPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6487,7 +6487,7 @@ bool SinkLoadOpt::sinkLoadInstruction(Function& F)
64876487

64886488
if (moveInst.size())
64896489
{
6490-
for (auto mi : reverse(moveInst))
6490+
for (auto &mi : reverse(moveInst))
64916491
{
64926492
mi.first->moveBefore(mi.second);
64936493
}

IGC/Compiler/CustomSafeOptPass.hpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ namespace IGC
3737

3838
CustomSafeOptPass();
3939

40-
~CustomSafeOptPass() {}
41-
4240
virtual void getAnalysisUsage(llvm::AnalysisUsage& AU) const override
4341
{
4442
AU.addRequired<CodeGenContextWrapper>();
@@ -114,8 +112,6 @@ namespace IGC
114112

115113
TrivialLocalMemoryOpsElimination();
116114

117-
~TrivialLocalMemoryOpsElimination() {}
118-
119115
virtual void getAnalysisUsage(llvm::AnalysisUsage& AU) const override
120116
{
121117
AU.addRequired<CodeGenContextWrapper>();
@@ -153,8 +149,6 @@ namespace IGC
153149

154150
GenSpecificPattern();
155151

156-
~GenSpecificPattern() {}
157-
158152
virtual void getAnalysisUsage(llvm::AnalysisUsage& AU) const override
159153
{
160154
AU.setPreservesCFG();
@@ -199,8 +193,6 @@ namespace IGC
199193

200194
FCmpPaternMatch();
201195

202-
~FCmpPaternMatch() {}
203-
204196
virtual bool runOnFunction(llvm::Function& F) override;
205197

206198
virtual llvm::StringRef getPassName() const override
@@ -218,8 +210,6 @@ namespace IGC
218210

219211
IGCConstProp(bool enableSimplifyGEP = false);
220212

221-
~IGCConstProp() {}
222-
223213
virtual void getAnalysisUsage(llvm::AnalysisUsage& AU) const override
224214
{
225215
AU.addRequired<llvm::TargetLibraryInfoWrapperPass>();

IGC/Compiler/ModuleAllocaAnalysis.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ namespace IGC
3636

3737
ModuleAllocaAnalysis();
3838
~ModuleAllocaAnalysis();
39+
ModuleAllocaAnalysis(const ModuleAllocaAnalysis&) = delete;
40+
ModuleAllocaAnalysis& operator=(const ModuleAllocaAnalysis&) = delete;
3941

4042
virtual llvm::StringRef getPassName() const override;
4143

IGC/Compiler/Optimizer/OpenCLPasses/AggregateArguments/AggregateArguments.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ namespace IGC
2828

2929
AggregateArgumentsAnalysis();
3030

31-
~AggregateArgumentsAnalysis() {}
32-
3331
virtual llvm::StringRef getPassName() const override
3432
{
3533
return "AggregateArgumentsAnalysis";
@@ -63,8 +61,6 @@ namespace IGC
6361

6462
ResolveAggregateArguments();
6563

66-
~ResolveAggregateArguments() {}
67-
6864
virtual llvm::StringRef getPassName() const override
6965
{
7066
return "ResolveAggregateArguments";

IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/DeviceEnqueue.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ namespace IGC
2626

2727
DeviceEnqueueFuncsAnalysis();
2828

29-
~DeviceEnqueueFuncsAnalysis() {}
30-
3129
virtual llvm::StringRef getPassName() const override
3230
{
3331
return "DeviceEnqueueFuncsAnalysis";
@@ -67,8 +65,6 @@ namespace IGC
6765

6866
DeviceEnqueueFuncsResolution();
6967

70-
~DeviceEnqueueFuncsResolution() {}
71-
7268
virtual llvm::StringRef getPassName() const override
7369
{
7470
return "DeviceEnqueueFuncsResolution";

IGC/Compiler/Optimizer/OpenCLPasses/DisableLoopUnrollOnRetry/DisableLoopUnrollOnRetry.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ namespace IGC
2626

2727
DisableLoopUnrollOnRetry();
2828

29-
~DisableLoopUnrollOnRetry() {}
30-
3129
virtual void getAnalysisUsage(llvm::AnalysisUsage& AU) const
3230
{
3331
AU.setPreservesCFG();

IGC/Compiler/Optimizer/OpenCLPasses/RayTracing/ResolveOCLRaytracingBuiltins.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ namespace IGC {
2929

3030
ResolveOCLRaytracingBuiltins();
3131

32-
~ResolveOCLRaytracingBuiltins() {};
33-
3432
virtual llvm::StringRef getPassName() const override {
3533
return "ResolveOCLRaytracingBuiltins";
3634
}

IGC/Compiler/Optimizer/OpenCLPasses/WGFuncs/WGFuncResolution.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ namespace IGC
2727
/// @brief Constructor
2828
WGFuncResolution();
2929

30-
/// @brief Destructor
31-
~WGFuncResolution() {}
32-
3330
/// @brief Provides name of pass
3431
virtual llvm::StringRef getPassName() const override
3532
{

IGC/Metrics/IGCMetricImpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ namespace IGCMetrics
111111
public:
112112
IGCMetricImpl();
113113
~IGCMetricImpl();
114+
IGCMetricImpl(const IGCMetricImpl&) = delete;
115+
IGCMetricImpl& operator=(const IGCMetricImpl&) = delete;
114116
bool Enable();
115117

116118
size_t getMetricDataSize();

IGC/common/debug/TeeOutputStream.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ namespace Debug
3131
bool shouldDeleteRHS);
3232

3333
~TeeOutputStream();
34+
TeeOutputStream(const TeeOutputStream&) = delete;
35+
TeeOutputStream& operator=(const TeeOutputStream&) = delete;
3436

3537
size_t preferred_buffer_size() const override;
3638

visa/Arena.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ class ArenaHeader {
8383
_nextArena = 0;
8484
}
8585

86+
ArenaHeader(const ArenaHeader&) = delete;
87+
ArenaHeader& operator=(const ArenaHeader&) = delete;
88+
8689
void *AllocSpace(size_t size, size_t align);
8790

8891
// Data
@@ -105,6 +108,8 @@ class ArenaManager {
105108
}
106109

107110
~ArenaManager() { FreeArenas(); }
111+
ArenaManager(const ArenaManager&) = delete;
112+
ArenaManager& operator=(const ArenaManager&) = delete;
108113

109114
void *AllocDataSpace(size_t size, size_t al) {
110115
// Do separate memory allocations of debugMemAlloc is set, to allow

visa/LocalScheduler/G4_Sched.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ class BB_Scheduler {
497497
schedule.clear();
498498
OrigInstList.clear();
499499
}
500+
BB_Scheduler(const BB_Scheduler&) = delete;
501+
BB_Scheduler& operator=(const BB_Scheduler&) = delete;
500502

501503
G4_Kernel &getKernel() const { return kernel; }
502504
G4_BB *getBB() const { return ddd.getBB(); }

visa/LocalScheduler/LocalScheduler_G4IR.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ class window2xSP {
413413
instList.clear();
414414
}
415415

416+
window2xSP(const window2xSP&) = delete;
417+
window2xSP& operator=(const window2xSP&) = delete;
418+
416419
~window2xSP() {
417420
instGRFSize = 0;
418421
instType = Type_UNDEF;

visa/LocalScheduler/SWSB_G4IR.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ struct SBFootprint {
159159
unsigned short RB, G4_INST *i)
160160
: fType(ft), type((unsigned short)p), LeftB(LB), RightB(RB), inst(i), isPrecision(true) {
161161
}
162-
~SBFootprint() {}
163162

164163
void setOffset(unsigned short o) { offset = o; }
165164

@@ -322,15 +321,6 @@ class SBNode {
322321
instVec.push_back(i);
323322
}
324323

325-
~SBNode() {
326-
// FIXME: I'd like to replace this with type-specific allocator as well, but
327-
// the ownership is unclear to me, is it safe to put the allocator in
328-
// SBNode?
329-
for (SBFootprint *sm : footprints) {
330-
sm->~SBFootprint();
331-
}
332-
}
333-
334324
void setSendID(int ID) { sendID = ID; }
335325

336326
void setSendUseID(int ID) { sendUseID = ID; }
@@ -530,8 +520,6 @@ struct SBBucketNode {
530520
const SBFootprint *f)
531521
: node(node1), opndNum(opndNum1), footprint(f) {}
532522

533-
~SBBucketNode() {}
534-
535523
void setSendID(int ID) { sendID = ID; }
536524

537525
int getSendID() const { return sendID; }

visa/Mem_Manager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ template <class T> class std_arena_based_allocator {
4848
typedef const T &const_reference;
4949
typedef T value_type;
5050

51+
~std_arena_based_allocator() = default;
52+
5153
explicit std_arena_based_allocator(std::shared_ptr<Mem_Manager> _other_ptr)
5254
: mem_manager_ptr(_other_ptr) {}
5355

visa/Optimizer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@ class Optimizer {
442442
#endif // DLL_MODE
443443
initOptimizations();
444444
}
445+
Optimizer(const Optimizer&) = delete;
446+
Optimizer& operator=(const Optimizer&) = delete;
445447
~Optimizer() {
446448
// Normally, noMask Info will be freed in postRA workaround.
447449
// But in case RA fails, postRA will not be invoked. Thus, need

visa/PhyRegUsage.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ class FreePhyRegs {
9999
weakEdgeUsage.resize(K.getNumRegTotal(), 0);
100100
}
101101

102+
FreePhyRegs(const FreePhyRegs&) = delete;
103+
FreePhyRegs& operator=(const FreePhyRegs&) = delete;
104+
102105
~FreePhyRegs() {
103106
delete[] availableGregs;
104107
delete[] availableAddrs;

visa/RegAlloc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ class LivenessAnalysis {
121121
LivenessAnalysis(GlobalRA &gra, unsigned char kind, bool verifyRA = false,
122122
bool forceRun = false);
123123
~LivenessAnalysis();
124+
LivenessAnalysis(const LivenessAnalysis&) = delete;
125+
LivenessAnalysis& operator=(const LivenessAnalysis&) = delete;
124126
void computeLiveness();
125127
bool isLiveAtEntry(const G4_BB *bb, unsigned var_id) const;
126128
bool isUseThrough(const G4_BB *bb, unsigned var_id) const;

visa/Rematerialization.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ class Rematerialization {
232232
}
233233
}
234234

235+
Rematerialization(const Rematerialization&) = delete;
236+
Rematerialization& operator=(const Rematerialization&) = delete;
237+
235238
bool getChangesMade() const { return IRChanged; }
236239

237240
void run();

visa/SCCAnalysis.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class SCCAnalysis {
6464

6565
public:
6666
SCCAnalysis(const FlowGraph &fg) : cfg(fg) {}
67+
SCCAnalysis(const SCCAnalysis&) = delete;
68+
SCCAnalysis& operator=(const SCCAnalysis&) = delete;
6769
~SCCAnalysis() {
6870
for (auto node : SCCNodes) {
6971
delete node;

visa/SpillManagerGMRF.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,8 @@ class SpillAnalysis {
728728
public:
729729
SpillAnalysis() = default;
730730
~SpillAnalysis();
731+
SpillAnalysis(const SpillAnalysis&) = delete;
732+
SpillAnalysis& operator=(const SpillAnalysis&) = delete;
731733

732734
void Dump(std::ostream &OS = std::cerr);
733735
void DumpHistogram(std::ostream &OS = std::cerr);

visa/VISAKernel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ class VISAKernelImpl : public VISAFunction {
115115
void *alloc(size_t sz) { return m_mem.alloc(sz); }
116116

117117
virtual ~VISAKernelImpl();
118+
VISAKernelImpl(const VISAKernelImpl&) = delete;
119+
VISAKernelImpl& operator=(const VISAKernelImpl&) = delete;
118120

119121
void *operator new(size_t sz, vISA::Mem_Manager &m) { return m.alloc(sz); };
120122

visa/VarSplit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class LoopVarSplit {
4242
LoopVarSplit(G4_Kernel &k, GraphColor *c,
4343
const LivenessAnalysis *liveAnalysis);
4444
~LoopVarSplit() { delete rpe; }
45+
LoopVarSplit(const LoopVarSplit&) = delete;
46+
LoopVarSplit& operator=(const LoopVarSplit&) = delete;
4547

4648
void run();
4749

visa/iga/IGALibrary/IR/RegSet.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class RegSet {
4242
bool isTrackedReg(RegName rn) const;
4343

4444
public:
45+
~RegSet() = default;
4546
RegSet(const Model &m);
4647
RegSet(const RegSet &rs);
4748
RegSet &operator=(const RegSet &);

visa/iga/IGALibrary/MemManager/Arena.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ class ArenaHeader {
6565
_nextArena = 0;
6666
}
6767

68+
ArenaHeader(const ArenaHeader&) = delete;
69+
ArenaHeader& operator=(const ArenaHeader&) = delete;
70+
6871
void *AllocSpace(size_t size);
6972

7073
ArenaHeader *_nextArena; // Word aligned
@@ -82,6 +85,8 @@ class ArenaManager {
8285
}
8386

8487
~ArenaManager() { FreeArenas(); }
88+
ArenaManager(const ArenaManager&) = delete;
89+
ArenaManager& operator=(const ArenaManager&) = delete;
8590

8691
void *AllocDataSpace(size_t size) {
8792
// Do separate memory allocations of debugMemAlloc is set, to allow

visa/iga/IGALibrary/MemManager/StdArenaAllocator.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ template <class T> class std_arena_based_allocator {
2828
typedef const T &const_reference;
2929
typedef T value_type;
3030

31+
~std_arena_based_allocator() = default;
32+
3133
explicit std_arena_based_allocator(std::shared_ptr<MemManager> _other_ptr)
3234
: MemManager_ptr(_other_ptr) {}
3335

visa/iga/IGALibrary/system.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ struct StreamColorSetter {
185185
stream.flush();
186186
restoreColor();
187187
}
188+
StreamColorSetter(const StreamColorSetter&) = delete;
189+
StreamColorSetter& operator=(const StreamColorSetter&) = delete;
188190

189191
bool colorNeedsRestore;
190192
#ifdef _WIN32

0 commit comments

Comments
 (0)