Skip to content

Commit f0962ad

Browse files
DianaChenigcbot
authored andcommitted
IGA: Clean-up gcc warnings
Clean-up gcc warnings, such as -Werror=misleading-indentation -Werror=catch-value -Werror=class-memaccess -Werror=unused-variable -Werror=unused-but-set-variable
1 parent 09a8d1b commit f0962ad

File tree

95 files changed

+361
-498
lines changed

Some content is hidden

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

95 files changed

+361
-498
lines changed

visa/BinaryEncodingCNL.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,7 @@ inline void BinaryEncodingCNL::EncodeTwoSrcInst(
978978
twoSrc.GetOperandControls().SetSrc0Regfile(
979979
TranslateVisaToHDLRegFile(EncodingHelper::GetSrcRegFile(src0)));
980980

981+
[[maybe_unused]]
981982
bool src0ImmOk = inst->isMath() && inst->asMathInst()->isOneSrcMath();
982983
vISA_ASSERT(src0ImmOk || !src0->isImm(),
983984
"src0 is immediate in two src instruction!");

visa/BinaryEncodingIGA.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ class BinaryEncodingIGA {
335335
static MathFC getMathFC(const G4_INST *inst);
336336
Type getIGAType(const G4_INST *I, Gen4_Operand_Number O, TARGET_PLATFORM P);
337337

338-
void *m_kernelBuffer;
339-
uint32_t m_kernelBufferSize;
338+
void *m_kernelBuffer = nullptr;
339+
uint32_t m_kernelBufferSize = 0;
340340
}; // class BinaryEncodingIGA
341341

342342
Platform
@@ -384,8 +384,7 @@ BinaryEncodingIGA::getIGAInternalPlatform(TARGET_PLATFORM genxPlatform) {
384384
}
385385

386386
BinaryEncodingIGA::BinaryEncodingIGA(vISA::G4_Kernel &k, const std::string& fname)
387-
: kernel(k), fileName(fname), m_kernelBuffer(nullptr),
388-
m_kernelBufferSize(0), platform(k.fg.builder->getPlatform()) {
387+
: kernel(k), fileName(fname), platform(k.fg.builder->getPlatform()) {
389388
platformModel = Model::LookupModel(getIGAInternalPlatform(platform));
390389
IGAKernel = new Kernel(*platformModel);
391390
}
@@ -1025,7 +1024,7 @@ void BinaryEncodingIGA::getIGAFlagInfo(G4_INST *inst, const OpSpec *opSpec,
10251024
G4_Predicate *predG4 = inst->getPredicate();
10261025
G4_CondMod *condModG4 = inst->getCondMod();
10271026
RegRef predFlag;
1028-
bool hasPredFlag = false;
1027+
[[maybe_unused]] bool hasPredFlag = false;
10291028

10301029
if (opSpec->supportsPredication() && predG4 != nullptr) {
10311030
pred = getIGAPredication(predG4, inst->getExecSize(), *kernel.fg.builder);
@@ -1977,6 +1976,7 @@ Predication BinaryEncodingIGA::getIGAPredication(const G4_Predicate *predG4,
19771976
// Xe_PVC+ has removed predCtrl width. Only .any, .all and .seq (default) are
19781977
// supported. Try to translate PredCtrl values to compatible ones on Xe_PVC+
19791978
// Return true on success, false on fail
1979+
[[maybe_unused]]
19801980
auto translatePredCtrl = [&](G4_Predicate_Control &predCtrl) {
19811981
if (builder.predCtrlHasWidth())
19821982
return true;

visa/BuildCISAIR.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ class CISA_IR_Builder : public VISABuilder {
4545
CISA_IR_Builder(TARGET_PLATFORM platform, VISA_BUILDER_OPTION buildOption,
4646
vISABuilderMode mode, int majorVersion, int minorVersion,
4747
const WA_TABLE *pWaTable)
48-
: mBuildOption(buildOption), m_builderMode(mode), m_mem(4096),
49-
m_pWaTable(pWaTable) {
48+
: mBuildOption(buildOption), m_builderMode(mode), m_pWaTable(pWaTable) {
5049
m_platformInfo = vISA::PlatformInfo::LookupPlatformInfo(platform);
5150
vISA_ASSERT(m_platformInfo != nullptr, "null m_platformInfo");
5251
m_header.major_version = majorVersion;
@@ -696,7 +695,7 @@ class CISA_IR_Builder : public VISABuilder {
696695
private:
697696
const vISA::PlatformInfo *m_platformInfo;
698697

699-
vISA::Mem_Manager m_mem;
698+
vISA::Mem_Manager m_mem = 4096;
700699
const VISA_BUILDER_OPTION mBuildOption;
701700
// FIXME: we need to make 3D/media per kernel instead of per builder
702701
const vISABuilderMode m_builderMode;

visa/BuildCISAIRImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ void CISA_IR_Builder::LinkTimeOptimization(
862862
auto &callerBuilder = caller->fg.builder;
863863
auto &calleeBuilder = callee->fg.builder;
864864
auto getPointerOffset = [&](G4_INST *inst, long long offset) {
865-
auto execSize = static_cast<int>(inst->getExecSize());
865+
[[maybe_unused]] auto execSize = static_cast<int>(inst->getExecSize());
866866
auto typeSize = inst->getSrc(0)->getTypeSize() * 8;
867867
switch (inst->opcode()) {
868868
case G4_mov: {

visa/BuildIR.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ class DeclarePool {
260260
//
261261
class IR_Builder {
262262
public:
263-
const char *curFile;
264-
unsigned int curLine;
265-
int curCISAOffset;
263+
const char *curFile = nullptr;
264+
unsigned int curLine = 0;
265+
int curCISAOffset = -1;
266266

267267
static const int OrphanVISAIndex = 0xffffffff;
268268
int debugInfoPlaceholder =
@@ -287,7 +287,7 @@ class IR_Builder {
287287
IR_Builder &builder;
288288

289289
public:
290-
GlobalImmPool(IR_Builder &b) : builder(b), immArray(), dclArray() {}
290+
GlobalImmPool(IR_Builder &b) : builder(b) {}
291291
G4_Declare *addImmVal(G4_Imm *imm, int numElt);
292292
int size() const { return curSize; }
293293
const ImmVal &getImmVal(int i) { return immArray[i]; }
@@ -305,7 +305,7 @@ class IR_Builder {
305305

306306
int subroutineId = -1; // the kernel itself has id 0, as we always emit a
307307
// subroutine label for kernel too
308-
enum VISA_BUILD_TYPE type; // as opposed to what?
308+
enum VISA_BUILD_TYPE type = VISA_BUILD_TYPE::KERNEL; // as opposed to what?
309309

310310
uint32_t m_next_local_label_id = 0;
311311

@@ -365,7 +365,7 @@ class IR_Builder {
365365
// Indicates that sampler header cache (builtinSamplerHeader) is correctly
366366
// initialized with r0 contents.
367367
// Used only when vISA_cacheSamplerHeader option is set.
368-
bool builtinSamplerHeaderInitialized;
368+
bool builtinSamplerHeaderInitialized = false;
369369
// for PVC send WAR WA
370370
bool hasDF = false;
371371
// function call related declares
@@ -457,14 +457,14 @@ class IR_Builder {
457457
const CISA_IR_Builder *parentBuilder = nullptr;
458458

459459
// stores all metadata ever allocated
460-
Mem_Manager metadataMem;
460+
Mem_Manager metadataMem = 4096;
461461
std::vector<Metadata *> allMDs;
462462
std::vector<MDNode *> allMDNodes;
463463

464464
FrequencyInfo freqInfoManager;
465465

466466
// bump pointer allocator for variable and label names, used for IR dump only.
467-
Mem_Manager debugNameMem;
467+
Mem_Manager debugNameMem = 4096;
468468

469469
// Whether the kernel should avoid clobbering or even reading R0, this
470470
// is generally due to mid-thread preemption.

visa/BuildIRImpl.cpp

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -795,16 +795,21 @@ IR_Builder::IR_Builder(INST_LIST_NODE_ALLOCATOR &alloc, G4_Kernel &k,
795795
Mem_Manager &m, Options *options,
796796
CISA_IR_Builder *parent, FINALIZER_INFO *jitInfo,
797797
const WA_TABLE *pWaTable)
798-
: curFile(NULL), curLine(0), curCISAOffset(-1), immPool(*this),
799-
metaData(jitInfo), type(VISA_BUILD_TYPE::KERNEL), parentBuilder(parent),
800-
builtinSamplerHeaderInitialized(false), m_pWaTable(pWaTable),
801-
m_options(options), CanonicalRegionStride0(0, 1, 0),
802-
CanonicalRegionStride1(1, 1, 0), CanonicalRegionStride2(2, 1, 0),
803-
CanonicalRegionStride4(4, 1, 0), mem(m),
804-
phyregpool(m, k.grfMode.getInitalGRFNum()),
805-
hashtable(m), rgnpool(m), dclpool(m, *this), instList(alloc), kernel(k),
806-
metadataMem(4096), debugNameMem(4096),
807-
r0AccessMode(getR0AccessFromOptions()), freqInfoManager(this, k) {
798+
: immPool(*this),
799+
metaData(jitInfo),
800+
m_pWaTable(pWaTable),
801+
m_options(options),
802+
CanonicalRegionStride0(0, 1, 0),
803+
CanonicalRegionStride1(1, 1, 0),
804+
CanonicalRegionStride2(2, 1, 0),
805+
CanonicalRegionStride4(4, 1, 0),
806+
parentBuilder(parent),
807+
freqInfoManager(this, k),
808+
r0AccessMode(getR0AccessFromOptions()),
809+
mem(m), phyregpool(m, k.grfMode.getInitalGRFNum()),
810+
hashtable(m), rgnpool(m), dclpool(m, *this), instList(alloc),
811+
kernel(k)
812+
{
808813
num_temp_dcl = 0;
809814
kernel.setBuilder(this); // kernel needs pointer to the builder
810815
if (!getIsPayload())
@@ -816,9 +821,15 @@ IR_Builder::IR_Builder(INST_LIST_NODE_ALLOCATOR &alloc, G4_Kernel &k,
816821

817822
arg_size = 0;
818823
return_var_size = 0;
819-
820824
if (metaData != NULL) {
825+
#if defined(__GNUC__) && (__GNUC__ >= 8)
826+
#pragma GCC diagnostic push
827+
#pragma GCC diagnostic ignored "-Wclass-memaccess"
828+
#endif
821829
memset(metaData, 0, sizeof(FINALIZER_INFO));
830+
#if defined(__GNUC__) && (__GNUC__ >= 8)
831+
#pragma GCC diagnostic pop
832+
#endif
822833
}
823834

824835
usedBarriers = BitSet(kernel.getMaxNumOfBarriers(), false);
@@ -2608,7 +2619,7 @@ G4_SendDescRaw *IR_Builder::createLscMsgDesc(
26082619
const unsigned execSize = Get_VISA_Exec_Size(execSizeEnum);
26092620
int src1Len = 0;
26102621
uint32_t dataRegs = 1;
2611-
bool isBlock2D =
2622+
[[maybe_unused]] bool isBlock2D =
26122623
op == LSC_OP::LSC_LOAD_BLOCK2D || op == LSC_OP::LSC_STORE_BLOCK2D;
26132624
vISA_ASSERT(!isBlock2D, "block2d not implemented yet");
26142625

visa/ByteCodeReaderNG.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static VISA_PredVar *readPreVarNG(unsigned &bytePos, const char *buf,
290290
RoutineContainer &container) {
291291
vISA_ASSERT_INPUT(buf != nullptr, "Argument Exception: argument buf is NULL.");
292292

293-
uint8_t tag = 0;
293+
[[maybe_unused]] uint8_t tag = 0;
294294
READ_CISA_FIELD(tag, uint8_t, bytePos, buf);
295295

296296
uint16_t index = 0;
@@ -2448,7 +2448,6 @@ static void
24482448
readInstructionLscUntypedAppendCounterAtomic(LSC_OP subOpcode,
24492449
unsigned &bytePos, const char *buf,
24502450
RoutineContainer &container) {
2451-
const LscOpInfo opInfo = LscOpInfoGet(subOpcode);
24522451

24532452
VISA_EMask_Ctrl execMask = vISA_EMASK_M1;
24542453
VISA_Exec_Size execSize = EXEC_SIZE_ILLEGAL;
@@ -2701,9 +2700,9 @@ static void readRoutineNG(unsigned &bytePos, const char *buf,
27012700
VISA_GenVar *decl = NULL;
27022701
VISA_Type varType = (VISA_Type)((var->bit_properties) & 0xF);
27032702
VISA_Align varAlign = (VISA_Align)((var->bit_properties >> 4) & 0xF);
2704-
uint8_t aliasScopeSpecifier =
2703+
[[maybe_unused]] uint8_t aliasScopeSpecifier =
27052704
header.variables[declID].alias_scope_specifier;
2706-
int status = VISA_SUCCESS;
2705+
[[maybe_unused]] int status = VISA_SUCCESS;
27072706

27082707
vISA_ASSERT(aliasScopeSpecifier == 0,
27092708
"file scope variables are no longer supported");
@@ -2761,7 +2760,7 @@ static void readRoutineNG(unsigned &bytePos, const char *buf,
27612760
/// VISA Builder Call
27622761
addr_info_t *var = &header.addresses[declID];
27632762
VISA_AddrVar *decl = NULL;
2764-
int status = kernelBuilderImpl->CreateVISAAddrVar(
2763+
[[maybe_unused]] int status = kernelBuilderImpl->CreateVISAAddrVar(
27652764
decl, header.strings[var->name_index], var->num_elements);
27662765
vISA_ASSERT(VISA_SUCCESS == status, "Failed to add VISA address variable.");
27672766

@@ -2800,7 +2799,7 @@ static void readRoutineNG(unsigned &bytePos, const char *buf,
28002799
/// VISA Builder Call
28012800
pred_info_t *var = &header.predicates[declID];
28022801
VISA_PredVar *decl = NULL;
2803-
int status = kernelBuilderImpl->CreateVISAPredVar(
2802+
[[maybe_unused]] int status = kernelBuilderImpl->CreateVISAPredVar(
28042803
decl, header.strings[var->name_index], var->num_elements);
28052804
vISA_ASSERT(VISA_SUCCESS == status,
28062805
"Failed to add VISA predicate vairable.");
@@ -2832,7 +2831,7 @@ static void readRoutineNG(unsigned &bytePos, const char *buf,
28322831
unsigned declID = i;
28332832
label_info_t *var = &header.labels[declID];
28342833
VISA_LabelOpnd *decl = NULL;
2835-
int status = kernelBuilderImpl->CreateVISALabelVar(
2834+
[[maybe_unused]] int status = kernelBuilderImpl->CreateVISALabelVar(
28362835
decl,
28372836
getDeclLabelString("L", var->name_index, header,
28382837
VISA_Label_Kind(var->kind))
@@ -2877,7 +2876,7 @@ static void readRoutineNG(unsigned &bytePos, const char *buf,
28772876
unsigned declID = i;
28782877
state_info_t *var = &header.samplers[declID];
28792878
VISA_SamplerVar *decl = NULL;
2880-
int status = kernelBuilderImpl->CreateVISASamplerVar(
2879+
[[maybe_unused]] int status = kernelBuilderImpl->CreateVISASamplerVar(
28812880
decl, header.strings[var->name_index], var->num_elements);
28822881
vISA_ASSERT(VISA_SUCCESS == status, "Failed to add VISA sampler variable.");
28832882

@@ -2925,7 +2924,7 @@ static void readRoutineNG(unsigned &bytePos, const char *buf,
29252924
unsigned declID = i;
29262925
state_info_t *var = &header.surfaces[declID];
29272926
VISA_SurfaceVar *decl = NULL;
2928-
int status = kernelBuilderImpl->CreateVISASurfaceVar(
2927+
[[maybe_unused]] int status = kernelBuilderImpl->CreateVISASurfaceVar(
29292928
decl, header.strings[var->name_index], var->num_elements);
29302929
vISA_ASSERT(VISA_SUCCESS == status, "Failed to add VISA surface variable.");
29312930

@@ -2946,7 +2945,7 @@ static void readRoutineNG(unsigned &bytePos, const char *buf,
29462945
container.surfaceVarDecls[i] = decl;
29472946
}
29482947

2949-
int vmeCount = 0;
2948+
[[maybe_unused]] int vmeCount = 0;
29502949
READ_CISA_FIELD(vmeCount, uint8_t, bytePos, buf);
29512950
vISA_ASSERT(vmeCount == 0, "VME variable is no longer supported");
29522951
header.vme_count = 0;
@@ -2986,7 +2985,7 @@ static void readRoutineNG(unsigned &bytePos, const char *buf,
29862985
vISA_ASSERT_UNREACHABLE("Incorrect input variable type.");
29872986
}
29882987

2989-
int status = kernelBuilderImpl->CreateVISAInputVar(
2988+
[[maybe_unused]] int status = kernelBuilderImpl->CreateVISAInputVar(
29902989
decl, var->offset, var->size, var->getImplicitKind());
29912990
vISA_ASSERT(VISA_SUCCESS == status, "Failed to add VISA input variable.");
29922991

visa/CFGStructurizer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ ANodeHG *CFGStructurizer::getEnclosingANodeHG(ANode *AN) {
14181418
} else {
14191419
// Error message
14201420
G4_BB *predBB = pred->getBeginBB();
1421-
G4_INST *predGoto = getGotoInst(predBB);
1421+
[[maybe_unused]] G4_INST *predGoto = getGotoInst(predBB);
14221422

14231423
// If predGoto is null, it means that a non-goto branching inst like
14241424
// jmpi jumps into a range of goto instrutions, such as the following:
@@ -1793,6 +1793,7 @@ ANodeBB *CFGStructurizer::addLandingBB(ANodeHG *node,
17931793
}
17941794

17951795
// Add a new empty BB as a predecessor of splitBB.
1796+
[[maybe_unused]]
17961797
ANode *CFGStructurizer::addSplitBBAtBegin(G4_BB *splitBB) {
17971798
G4_BB *newBB = createBBWithLabel();
17981799
G4_Label *newLabel = newBB->getLabel();
@@ -1924,6 +1925,7 @@ void CFGStructurizer::reConnectAllPreds(ANode *from, ANode *to) {
19241925
// Re-connect every successors of "from" to its new predecesor "to". Update
19251926
// "to"'s succs and its new successors' preds. Note that "from"'s succs are
19261927
// left unchanged.
1928+
[[maybe_unused]]
19271929
void CFGStructurizer::reConnectAllSuccs(ANode *from, ANode *to) {
19281930
for (ANList::iterator I = from->succs.begin(), E = from->succs.end(); I != E;
19291931
++I) {
@@ -2771,7 +2773,7 @@ void CFGStructurizer::convertIf(ANodeHG *node, G4_BB *nextJoinBB) {
27712773
execSize = execSize > 1 ? execSize : kernelExecSize;
27722774
ANList::iterator II = node->children.begin();
27732775
ANode *thenNode = *(++II); // children[1]
2774-
G4_BB *end = node->getEndBB();
2776+
[[maybe_unused]] G4_BB *end = node->getEndBB();
27752777
G4_BB *exit = node->getExitBB();
27762778

27772779
vISA_ASSERT(end->getPhysicalSucc() == exit,

visa/CISA.l

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ void resetGlobalVariables() {
6161
%}
6262

6363
%option yylineno
64+
%option nounput
6465

6566
%x eat_comment
6667
%x string_literal
@@ -1649,17 +1650,6 @@ static unsigned char FENCEOptions(const char* str)
16491650
return result;
16501651
}
16511652

1652-
static COMMON_ISA_VME_OP_MODE VMEType(const char* str)
1653-
{
1654-
for (int i = 0; i < VME_OP_MODE_NUM; i++)
1655-
if (!strcmp(vme_op_mode_str[i], str))
1656-
return (COMMON_ISA_VME_OP_MODE)i;
1657-
1658-
YY_FATAL_ERROR("Invalid Media Mode");
1659-
1660-
return VME_OP_MODE_NUM;
1661-
}
1662-
16631653
static CHANNEL_OUTPUT_FORMAT Get_Channel_Output(const char* str)
16641654
{
16651655
for (int i = 0; i < CHANNEL_OUTPUT_NUM; i++)

visa/CISA.y

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ void CISAerror(CISA_IR_Builder* builder, char const* msg);
3030
int yylex(CISA_IR_Builder *pBuilder);
3131
extern int CISAlineno;
3232

33-
static bool streq(const char *sym0, const char *sym1);
33+
[[maybe_unused]] static bool streq(const char *sym0, const char *sym1);
3434
static bool ParseAlign(CISA_IR_Builder* pBuilder, const char *sym, VISA_Align &value);
3535
static VISA_Align AlignBytesToVisaAlignment(int bytes);
36-
static int DataTypeSizeOf(VISA_Type type);
3736
static bool ParseEMask(const char* sym, VISA_EMask_Ctrl &emask);
3837

3938
//

0 commit comments

Comments
 (0)