From f7da527757140ae701be58274ce6db2f4234d9ff Mon Sep 17 00:00:00 2001 From: Jaebaek Seo Date: Fri, 30 Oct 2020 18:03:56 -0400 Subject: [PATCH] Temporarily add EmptyPass to prevent glslang from failing (#4004) Removing PropagateLineInfoPass and RedundantLineInfoElimPass from 56d0f5035 makes unit tests of many open source projects fail. It will happen before submitting this glslang PR https://github.com/KhronosGroup/glslang/pull/2440. This commit will be git-reverted after merging the glslang PR. --- BUILD.gn | 1 + include/spirv-tools/optimizer.hpp | 12 +++++++++++ source/opt/CMakeLists.txt | 1 + source/opt/empty_pass.h | 36 +++++++++++++++++++++++++++++++ source/opt/optimizer.cpp | 8 +++++++ source/opt/passes.h | 1 + 6 files changed, 59 insertions(+) create mode 100644 source/opt/empty_pass.h diff --git a/BUILD.gn b/BUILD.gn index 55eb9ada..2387fc6a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -561,6 +561,7 @@ static_library("spvtools_opt") { "source/opt/eliminate_dead_functions_util.h", "source/opt/eliminate_dead_members_pass.cpp", "source/opt/eliminate_dead_members_pass.h", + "source/opt/empty_pass.h", "source/opt/feature_manager.cpp", "source/opt/feature_manager.h", "source/opt/fix_storage_class.cpp", diff --git a/include/spirv-tools/optimizer.hpp b/include/spirv-tools/optimizer.hpp index 7f993cc3..f12774d6 100644 --- a/include/spirv-tools/optimizer.hpp +++ b/include/spirv-tools/optimizer.hpp @@ -536,6 +536,18 @@ Optimizer::PassToken CreateDeadInsertElimPass(); // eliminated with standard dead code elimination. Optimizer::PassToken CreateAggressiveDCEPass(); +// Creates an empty pass. +// This is deprecated and will be removed. +// TODO(jaebaek): remove this pass after handling glslang's broken unit tests. +// https://github.com/KhronosGroup/glslang/pull/2440 +Optimizer::PassToken CreatePropagateLineInfoPass(); + +// Creates an empty pass. +// This is deprecated and will be removed. +// TODO(jaebaek): remove this pass after handling glslang's broken unit tests. +// https://github.com/KhronosGroup/glslang/pull/2440 +Optimizer::PassToken CreateRedundantLineInfoElimPass(); + // Creates a compact ids pass. // The pass remaps result ids to a compact and gapless range starting from %1. Optimizer::PassToken CreateCompactIdsPass(); diff --git a/source/opt/CMakeLists.txt b/source/opt/CMakeLists.txt index 3ab43af6..f3ac5906 100644 --- a/source/opt/CMakeLists.txt +++ b/source/opt/CMakeLists.txt @@ -43,6 +43,7 @@ set(SPIRV_TOOLS_OPT_SOURCES eliminate_dead_functions_pass.h eliminate_dead_functions_util.h eliminate_dead_members_pass.h + empty_pass.h feature_manager.h fix_storage_class.h flatten_decoration_pass.h diff --git a/source/opt/empty_pass.h b/source/opt/empty_pass.h new file mode 100644 index 00000000..1fd2ae59 --- /dev/null +++ b/source/opt/empty_pass.h @@ -0,0 +1,36 @@ +// Copyright (c) 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SOURCE_OPT_EMPTY_PASS_H_ +#define SOURCE_OPT_EMPTY_PASS_H_ + +#include "source/opt/pass.h" + +namespace spvtools { +namespace opt { + +// Documented in optimizer.hpp +class EmptyPass : public Pass { + public: + EmptyPass() {} + + const char* name() const override { return "empty-pass"; } + + Status Process() override { return Status::SuccessWithoutChange; } +}; + +} // namespace opt +} // namespace spvtools + +#endif // SOURCE_OPT_EMPTY_PASS_H_ diff --git a/source/opt/optimizer.cpp b/source/opt/optimizer.cpp index 7a6a33b2..bc144111 100644 --- a/source/opt/optimizer.cpp +++ b/source/opt/optimizer.cpp @@ -753,6 +753,14 @@ Optimizer::PassToken CreateAggressiveDCEPass() { MakeUnique()); } +Optimizer::PassToken CreatePropagateLineInfoPass() { + return MakeUnique(MakeUnique()); +} + +Optimizer::PassToken CreateRedundantLineInfoElimPass() { + return MakeUnique(MakeUnique()); +} + Optimizer::PassToken CreateCompactIdsPass() { return MakeUnique( MakeUnique()); diff --git a/source/opt/passes.h b/source/opt/passes.h index acc30e1e..d47cc1ce 100644 --- a/source/opt/passes.h +++ b/source/opt/passes.h @@ -35,6 +35,7 @@ #include "source/opt/eliminate_dead_constant_pass.h" #include "source/opt/eliminate_dead_functions_pass.h" #include "source/opt/eliminate_dead_members_pass.h" +#include "source/opt/empty_pass.h" #include "source/opt/fix_storage_class.h" #include "source/opt/flatten_decoration_pass.h" #include "source/opt/fold_spec_constant_op_and_composite_pass.h"