From 598038626dd2c10b96308347718f26cfa3dc509c Mon Sep 17 00:00:00 2001 From: "Wesierski, Lukasz" Date: Mon, 9 Sep 2019 09:11:20 -0700 Subject: [PATCH 4/4] Fix for buildbreak when using clang-9 compiler Fixes #106 Fxies #111 Change-Id: I291bf03c31b1786a00b8bc2c6d23c5adb8b72e73 Upstream-Status: Backport [https://github.com/intel/intel-graphics-compiler/commit/a332238b46e9fa9e06265d18eb877d095015e6fb] Signed-off-by: Naveen Saini --- IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVEntry.h | 4 + .../SPIRV/libSPIRV/SPIRVInstruction.h | 18 +-- IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVModule.cpp | 136 +++++++++--------- IGC/AdaptorOCL/cif/cif/export/registry.h | 3 +- IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp | 4 +- visa/CISA.l | 2 +- visa/CMakeLists.txt | 6 +- 7 files changed, 89 insertions(+), 84 deletions(-) diff --git a/IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVEntry.h b/IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVEntry.h index 7a2ba855..307ba3f3 100644 --- a/IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVEntry.h +++ b/IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVEntry.h @@ -129,8 +129,12 @@ class SPIRVExtInst; void decode(std::istream &I) { getDecoder(I) >> x >> y;} #define _SPIRV_DEF_DEC3(x,y,z) \ void decode(std::istream &I) { getDecoder(I) >> x >> y >> z;} +#define _SPIRV_DEF_DEC3_OVERRIDE(x,y,z) \ + void decode(std::istream &I) override { getDecoder(I) >> x >> y >> z;} #define _SPIRV_DEF_DEC4(x,y,z,u) \ void decode(std::istream &I) { getDecoder(I) >> x >> y >> z >> u;} +#define _SPIRV_DEF_DEC4_OVERRIDE(x,y,z,u) \ + void decode(std::istream &I) override { getDecoder(I) >> x >> y >> z >> u;} #define _SPIRV_DEF_DEC5(x,y,z,u,v) \ void decode(std::istream &I) { getDecoder(I) >> x >> y >> z >> u >> v;} #define _SPIRV_DEF_DEC6(x,y,z,u,v,w) \ diff --git a/IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVInstruction.h b/IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVInstruction.h index 9f4e9d1f..bb85fd04 100644 --- a/IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVInstruction.h +++ b/IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVInstruction.h @@ -727,10 +727,10 @@ public: return getValue(ConditionId); } SPIRVLabel *getTrueLabel() const { - return get(TrueLabelId); + return SPIRVEntry::get(TrueLabelId); } SPIRVLabel *getFalseLabel() const { - return get(FalseLabelId); + return SPIRVEntry::get(FalseLabelId); } protected: void setWordCount(SPIRVWord TheWordCount) { @@ -940,7 +940,7 @@ public: SPIRVEntry::setWordCount(TheWordCount); LoopControlParameters.resize(TheWordCount - FixedWordCount); } - _SPIRV_DEF_DEC4(MergeBlock, ContinueTarget, LoopControl, + _SPIRV_DEF_DEC4_OVERRIDE(MergeBlock, ContinueTarget, LoopControl, LoopControlParameters) protected: @@ -1120,7 +1120,7 @@ public: SPIRVFunctionCallGeneric(SPIRVModule *BM, SPIRVWord ResId, SPIRVType *TheType, const std::vector &TheArgs) - : SPIRVInstruction(TheArgs.size() + FixedWordCount, OC, TheType, ResId, + : SPIRVInstruction(TheArgs.size() + FixedWordCount, OC, TheType, ResId, NULL, BM), Args(TheArgs) {} SPIRVFunctionCallGeneric():SPIRVInstruction(OC) {} @@ -1152,7 +1152,7 @@ class SPIRVFunctionCall: public: SPIRVFunctionCall():FunctionId(SPIRVID_INVALID) {} SPIRVFunction *getFunction()const { - return get(FunctionId); + return SPIRVEntry::get(FunctionId); } _SPIRV_DEF_DEC4(Type, Id, FunctionId, Args) void validate()const; @@ -1169,8 +1169,8 @@ public: const std::vector& TheArgs, SPIRVBasicBlock* BB); SPIRVFunctionPointerCallINTEL() : CalledValueId(SPIRVID_INVALID) {} - SPIRVValue* getCalledValue() const { return get(CalledValueId); } - _SPIRV_DEF_DEC4(Type, Id, CalledValueId, Args) + SPIRVValue* getCalledValue() const { return SPIRVEntry::get(CalledValueId); } + _SPIRV_DEF_DEC4_OVERRIDE(Type, Id, CalledValueId, Args) void validate() const override; bool isOperandLiteral(unsigned Index) const { return false; } CapVec getRequiredCapability() const override { @@ -1188,8 +1188,8 @@ public: SPIRVFunctionPointerINTEL(SPIRVId TheId, SPIRVType* TheType, SPIRVFunction* TheFunction, SPIRVBasicBlock* BB); SPIRVFunctionPointerINTEL() : SPIRVInstruction(OC), TheFunction(SPIRVID_INVALID) {} - SPIRVFunction* getFunction() const { return get(TheFunction); } - _SPIRV_DEF_DEC3(Type, Id, TheFunction) + SPIRVFunction* getFunction() const { return SPIRVEntry::get(TheFunction); } + _SPIRV_DEF_DEC3_OVERRIDE(Type, Id, TheFunction) void validate() const override; bool isOperandLiteral(unsigned Index) const { return false; } CapVec getRequiredCapability() const override { diff --git a/IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVModule.cpp b/IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVModule.cpp index 353341b5..74ab6e93 100644 --- a/IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVModule.cpp +++ b/IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVModule.cpp @@ -94,126 +94,126 @@ public: virtual ~SPIRVModuleImpl(); // Object query functions - bool exist(SPIRVId) const; - bool exist(SPIRVId, SPIRVEntry **) const; + bool exist(SPIRVId) const override; + bool exist(SPIRVId, SPIRVEntry **) const override; SPIRVId getId(SPIRVId Id = SPIRVID_INVALID, unsigned Increment = 1); - virtual SPIRVEntry *getEntry(SPIRVId Id) const; + virtual SPIRVEntry *getEntry(SPIRVId Id) const override; virtual void addUnknownStructField( - SPIRVTypeStruct*, unsigned idx, SPIRVId id); - virtual void resolveUnknownStructFields(); - bool hasDebugInfo() const + SPIRVTypeStruct*, unsigned idx, SPIRVId id) override; + virtual void resolveUnknownStructFields() override; + bool hasDebugInfo() const override { return getCompilationUnit() != nullptr; } // Error handling functions - SPIRVErrorLog &getErrorLog() { return ErrLog;} - SPIRVErrorCode getError(std::string &ErrMsg) { return ErrLog.getError(ErrMsg);} + SPIRVErrorLog &getErrorLog() override { return ErrLog;} + SPIRVErrorCode getError(std::string &ErrMsg) override { return ErrLog.getError(ErrMsg);} // Module query functions - SPIRVAddressingModelKind getAddressingModel() { return AddrModel;} - SPIRVExtInstSetKind getBuiltinSet(SPIRVId SetId) const; - const SPIRVCapSet &getCapability() const { return CapSet;} - const std::string &getCompileFlag() const { return CompileFlag;} - std::string &getCompileFlag() { return CompileFlag;} - void setCompileFlag(const std::string &options) { CompileFlag = options; } - bool isSpecConstant(SPIRVWord spec_id) const { + SPIRVAddressingModelKind getAddressingModel() override { return AddrModel;} + SPIRVExtInstSetKind getBuiltinSet(SPIRVId SetId) const override; + const SPIRVCapSet &getCapability() const override { return CapSet;} + const std::string &getCompileFlag() const override { return CompileFlag;} + std::string &getCompileFlag() override { return CompileFlag;} + void setCompileFlag(const std::string &options) override { CompileFlag = options; } + bool isSpecConstant(SPIRVWord spec_id) const override { if(SCMap) return SCMap->find(spec_id) != SCMap->end(); else return false; } - uint64_t getSpecConstant(SPIRVWord spec_id) { + uint64_t getSpecConstant(SPIRVWord spec_id) override { spirv_assert(isSpecConstant(spec_id) && "Specialization constant was not specialized!"); return SCMap->at(spec_id); } - void setSpecConstantMap(SPIRVSpecConstantMap *specConstants) { SCMap = specConstants; } - std::set &getExtension() { return SPIRVExt;} - SPIRVFunction *getFunction(unsigned I) const { return FuncVec[I];} - SPIRVVariable *getVariable(unsigned I) const { return VariableVec[I];} - virtual SPIRVValue *getValue(SPIRVId TheId) const; - virtual std::vector getValues(const std::vector&)const; - virtual std::vector getIds(const std::vector&)const; - virtual std::vector getIds(const std::vector&)const; - virtual SPIRVType *getValueType(SPIRVId TheId)const; + void setSpecConstantMap(SPIRVSpecConstantMap *specConstants) override { SCMap = specConstants; } + std::set &getExtension() override { return SPIRVExt;} + SPIRVFunction *getFunction(unsigned I) const override { return FuncVec[I];} + SPIRVVariable *getVariable(unsigned I) const override { return VariableVec[I];} + virtual SPIRVValue *getValue(SPIRVId TheId) const override; + virtual std::vector getValues(const std::vector&)const override; + virtual std::vector getIds(const std::vector&)const override; + virtual std::vector getIds(const std::vector&)const override; + virtual SPIRVType *getValueType(SPIRVId TheId)const override; virtual std::vector getValueTypes(const std::vector&) - const; - SPIRVMemoryModelKind getMemoryModel() { return MemoryModel;} - virtual SPIRVConstant* getLiteralAsConstant(unsigned Literal); - unsigned getNumEntryPoints(SPIRVExecutionModelKind EM) const { + const override; + SPIRVMemoryModelKind getMemoryModel() override { return MemoryModel;} + virtual SPIRVConstant* getLiteralAsConstant(unsigned Literal) override; + unsigned getNumEntryPoints(SPIRVExecutionModelKind EM) const override{ auto Loc = EntryPointVec.find(EM); if (Loc == EntryPointVec.end()) return 0; return Loc->second.size(); } - SPIRVFunction *getEntryPoint(SPIRVExecutionModelKind EM, unsigned I) const { + SPIRVFunction *getEntryPoint(SPIRVExecutionModelKind EM, unsigned I) const override { auto Loc = EntryPointVec.find(EM); if (Loc == EntryPointVec.end()) return nullptr; spirv_assert(I < Loc->second.size()); return get(Loc->second[I]); } - unsigned getNumFunctions() const { return FuncVec.size();} - unsigned getNumVariables() const { return VariableVec.size();} - SpvSourceLanguage getSourceLanguage(SPIRVWord * Ver = nullptr) const { + unsigned getNumFunctions() const override { return FuncVec.size();} + unsigned getNumVariables() const override { return VariableVec.size();} + SpvSourceLanguage getSourceLanguage(SPIRVWord * Ver = nullptr) const override { if (Ver) *Ver = SrcLangVer; return SrcLang; } - std::set &getSourceExtension() { return SrcExtension;} - bool isEntryPoint(SPIRVExecutionModelKind, SPIRVId EP) const; + std::set &getSourceExtension() override { return SrcExtension;} + bool isEntryPoint(SPIRVExecutionModelKind, SPIRVId EP) const override; const std::string &getModuleProcessed() const { return ModuleProcessed; } - const std::vector &getStringVec() const { return StringVec; } + const std::vector &getStringVec() const override { return StringVec; } // Module changing functions - bool importBuiltinSet(const std::string &, SPIRVId *); - bool importBuiltinSetWithId(const std::string &, SPIRVId); - void optimizeDecorates(); - void setAddressingModel(SPIRVAddressingModelKind AM) { AddrModel = AM;} - void setAlignment(SPIRVValue *, SPIRVWord); - void setMemoryModel(SPIRVMemoryModelKind MM) { MemoryModel = MM;} - void setName(SPIRVEntry *E, const std::string &Name); - void setSourceLanguage(SpvSourceLanguage Lang, SPIRVWord Ver) { + bool importBuiltinSet(const std::string &, SPIRVId *) override; + bool importBuiltinSetWithId(const std::string &, SPIRVId) override; + void optimizeDecorates() override; + void setAddressingModel(SPIRVAddressingModelKind AM) override { AddrModel = AM;} + void setAlignment(SPIRVValue *, SPIRVWord) override; + void setMemoryModel(SPIRVMemoryModelKind MM) override { MemoryModel = MM;} + void setName(SPIRVEntry *E, const std::string &Name) override; + void setSourceLanguage(SpvSourceLanguage Lang, SPIRVWord Ver) override { SrcLang = Lang; SrcLangVer = Ver; } - void setModuleProcessed(const std::string& MP) { + void setModuleProcessed(const std::string& MP) override { ModuleProcessed = MP; } // Object creation functions template void addTo(std::vector &V, SPIRVEntry *E); - virtual SPIRVEntry *addEntry(SPIRVEntry *E); - virtual SPIRVString *getString(const std::string &Str); + virtual SPIRVEntry *addEntry(SPIRVEntry *E) override; + virtual SPIRVString *getString(const std::string &Str) override; virtual SPIRVMemberName *addMemberName(SPIRVTypeStruct *ST, - SPIRVWord MemberNumber, const std::string &Name); + SPIRVWord MemberNumber, const std::string &Name) override; virtual SPIRVLine *addLine(SPIRVString *FileName, SPIRVWord Line, - SPIRVWord Column); - virtual void addCapability(SPIRVCapabilityKind); - virtual const SPIRVDecorateGeneric *addDecorate(const SPIRVDecorateGeneric *); - virtual SPIRVDecorationGroup *addDecorationGroup(); - virtual SPIRVDecorationGroup *addDecorationGroup(SPIRVDecorationGroup *Group); + SPIRVWord Column) override; + virtual void addCapability(SPIRVCapabilityKind) override; + virtual const SPIRVDecorateGeneric *addDecorate(const SPIRVDecorateGeneric *) override; + virtual SPIRVDecorationGroup *addDecorationGroup() override; + virtual SPIRVDecorationGroup *addDecorationGroup(SPIRVDecorationGroup *Group) override; virtual SPIRVGroupDecorate *addGroupDecorate(SPIRVDecorationGroup *Group, - const std::vector &Targets); + const std::vector &Targets) override; virtual SPIRVGroupDecorateGeneric *addGroupDecorateGeneric( - SPIRVGroupDecorateGeneric *GDec); + SPIRVGroupDecorateGeneric *GDec) override; virtual SPIRVGroupMemberDecorate *addGroupMemberDecorate( - SPIRVDecorationGroup *Group, const std::vector &Targets); + SPIRVDecorationGroup *Group, const std::vector &Targets) override; virtual void addEntryPoint(SPIRVExecutionModelKind ExecModel, - SPIRVId EntryPoint); - virtual SPIRVForward *addForward(SPIRVType *Ty); - virtual SPIRVForward *addForward(SPIRVId, SPIRVType *Ty); - virtual SPIRVFunction *addFunction(SPIRVFunction *); - virtual SPIRVFunction *addFunction(SPIRVTypeFunction *, SPIRVId); - virtual SPIRVEntry *replaceForward(SPIRVForward *, SPIRVEntry *); + SPIRVId EntryPoint) override; + virtual SPIRVForward *addForward(SPIRVType *Ty) override; + virtual SPIRVForward *addForward(SPIRVId, SPIRVType *Ty) override; + virtual SPIRVFunction *addFunction(SPIRVFunction *) override; + virtual SPIRVFunction *addFunction(SPIRVTypeFunction *, SPIRVId) override; + virtual SPIRVEntry *replaceForward(SPIRVForward *, SPIRVEntry *) override; // Type creation functions template T * addType(T *Ty); - virtual SPIRVTypeInt *addIntegerType(unsigned BitWidth); + virtual SPIRVTypeInt *addIntegerType(unsigned BitWidth) override; // Constant creation functions - virtual SPIRVValue *addConstant(SPIRVValue *); - virtual SPIRVValue *addConstant(SPIRVType *, uint64_t); + virtual SPIRVValue *addConstant(SPIRVValue *) override; + virtual SPIRVValue *addConstant(SPIRVType *, uint64_t) override; virtual SPIRVInstruction *addLoopMergeInst( SPIRVId MergeBlock, SPIRVId ContinueTarget, @@ -226,7 +226,7 @@ public: addInstruction(SPIRVInstruction *Inst, SPIRVBasicBlock *BB, SPIRVInstruction *InsertBefore = nullptr); - virtual SPIRVExtInst* getCompilationUnit() const + virtual SPIRVExtInst* getCompilationUnit() const override { for (auto& item : IdEntryMap) { @@ -242,7 +242,7 @@ public: return nullptr; } - virtual std::vector getGlobalVars() + virtual std::vector getGlobalVars() override { std::vector globalVars; @@ -260,7 +260,7 @@ public: return globalVars; } - virtual std::vector parseSpecConstants() + virtual std::vector parseSpecConstants() override { std::vector specConstants; diff --git a/IGC/AdaptorOCL/cif/cif/export/registry.h b/IGC/AdaptorOCL/cif/cif/export/registry.h index a2b893c2..1571a698 100644 --- a/IGC/AdaptorOCL/cif/cif/export/registry.h +++ b/IGC/AdaptorOCL/cif/cif/export/registry.h @@ -50,7 +50,8 @@ namespace Helpers { struct EntryPointInterfaceBase{ EntryPointInterfaceBase(){ } - + virtual ~EntryPointInterfaceBase() = default; + virtual ICIF * Create(Version_t version, ICIF * parent) const = 0; virtual InterfaceId_t GetFirstIncompatible(CIF::CompatibilityDataHandle handle) const = 0; virtual void GetSupportedVersions(Version_t &verMin, Version_t &verMax) const = 0; diff --git a/IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp b/IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp index ebad9b3d..3bde1151 100644 --- a/IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp +++ b/IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp @@ -301,7 +301,7 @@ namespace FCL std::string dumpPath = "c:\\Intel\\IGC\\"; // default if something goes wrong char custom_dir[256]; FCLReadIGCRegistry("DumpToCustomDir", custom_dir, sizeof(custom_dir)); - if (custom_dir != nullptr && strlen(custom_dir) > 0) + if (strlen(custom_dir) > 0) { dumpPath = custom_dir; } @@ -321,7 +321,7 @@ namespace FCL std::string dumpPath = "/tmp/IntelIGC/"; // default if something goes wrong char custom_dir[256]; FCLReadIGCRegistry("DumpToCustomDir", custom_dir, sizeof(custom_dir)); - if (custom_dir != nullptr && strlen(custom_dir) > 0) + if (strlen(custom_dir) > 0) { dumpPath = custom_dir; } diff --git a/visa/CISA.l b/visa/CISA.l index def21e4b..27532695 100644 --- a/visa/CISA.l +++ b/visa/CISA.l @@ -45,7 +45,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #pragma warning(default: 4005) #endif -#include "CISA.tab.h" +#include "CISA.tab.hpp" #ifdef _DEBUG #define TRACE(str) fprintf(yyout, str); ECHO; fprintf(yyout, "\n") diff --git a/visa/CMakeLists.txt b/visa/CMakeLists.txt index 11d1bf53..551e4edb 100644 --- a/visa/CMakeLists.txt +++ b/visa/CMakeLists.txt @@ -105,8 +105,8 @@ endif() # Set up the bison and flex targets. These commands will set up commands to generate the appropriate # source files from the input grammars. It will also set up the dependencies correctly for any # library or executable that uses the generated source -BISON_TARGET(CISAParser CISA.y ${CMAKE_CURRENT_BINARY_DIR}/CISA.tab.c COMPILE_FLAGS "-vt -p CISA") -FLEX_TARGET(CISAScanner CISA.l ${CMAKE_CURRENT_BINARY_DIR}/lex.CISA.c COMPILE_FLAGS "-PCISA ${WIN_FLEX_FLAG}") +BISON_TARGET(CISAParser CISA.y ${CMAKE_CURRENT_BINARY_DIR}/CISA.tab.cpp COMPILE_FLAGS "-vt -p CISA") +FLEX_TARGET(CISAScanner CISA.l ${CMAKE_CURRENT_BINARY_DIR}/lex.CISA.cpp COMPILE_FLAGS "-PCISA ${WIN_FLEX_FLAG}") ADD_FLEX_BISON_DEPENDENCY(CISAScanner CISAParser) add_custom_target(CISAScanner_target DEPENDS ${FLEX_CISAScanner_OUTPUTS} ${BISON_CISAParser_OUTPUTS}) @@ -134,7 +134,7 @@ include_directories(${Jitter_inc_dirs}) # Tell cmake to generate code to compile the flex and bison generated source as c++ rather than c # (due to the fact that they are .c files rather than .cpp) -set_source_files_properties( CISA.tab.c lex.CISA.c PROPERTIES LANGUAGE CXX ) +set_source_files_properties( CISA.tab.cpp lex.CISA.cpp PROPERTIES LANGUAGE CXX ) set(LocalScheduler_SOURCES LocalScheduler/Dependencies_G4IR.cpp -- 2.17.1