Просмотр исходного кода

[spirv] Use invalid instruction replacement legalization pass (#1051)

Lei Zhang 7 лет назад
Родитель
Сommit
67770e37d4
2 измененных файлов с 5 добавлено и 2 удалено
  1. 1 1
      external/SPIRV-Tools
  2. 4 1
      tools/clang/lib/SPIRV/SPIRVEmitter.cpp

+ 1 - 1
external/SPIRV-Tools

@@ -1 +1 @@
-Subproject commit 18618061cb87652246d35b45b3c401d2f0510b04
+Subproject commit 50e85c865ca9c4b53e2724f36a84fb2566c1ce97

+ 4 - 1
tools/clang/lib/SPIRV/SPIRVEmitter.cpp

@@ -208,6 +208,8 @@ bool spirvToolsLegalize(std::vector<uint32_t> *module, std::string *messages) {
 
 
   optimizer.RegisterLegalizationPasses();
   optimizer.RegisterLegalizationPasses();
 
 
+  optimizer.RegisterPass(spvtools::CreateReplaceInvalidOpcodePass());
+
   optimizer.RegisterPass(spvtools::CreateCompactIdsPass());
   optimizer.RegisterPass(spvtools::CreateCompactIdsPass());
 
 
   return optimizer.Run(module->data(), module->size(), module);
   return optimizer.Run(module->data(), module->size(), module);
@@ -556,6 +558,8 @@ void SPIRVEmitter::HandleTranslationUnit(ASTContext &context) {
                  "with source code if possible",
                  "with source code if possible",
                  {});
                  {});
         return;
         return;
+      } else if (!messages.empty()) {
+        emitWarning("SPIR-V legalization: %0", {}) << messages;
       }
       }
     }
     }
 
 
@@ -1918,7 +1922,6 @@ SpirvEvalInfo SPIRVEmitter::doCastExpr(const CastExpr *expr) {
           32)
           32)
     hint.setHint(astContext.FloatTy);
     hint.setHint(astContext.FloatTy);
 
 
-
   // TODO: We could provide other useful hints. For instance:
   // TODO: We could provide other useful hints. For instance:
   // For the case of toType being a boolean, if the fromType is a literal float,
   // For the case of toType being a boolean, if the fromType is a literal float,
   // we could provide a FloatTy hint and if the fromType is a literal integer,
   // we could provide a FloatTy hint and if the fromType is a literal integer,