2016-06-28 18:58:17 +00:00
|
|
|
// Copyright (c) 2016 Google Inc.
|
|
|
|
//
|
2016-09-01 19:33:59 +00:00
|
|
|
// 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
|
2016-06-28 18:58:17 +00:00
|
|
|
//
|
2016-09-01 19:33:59 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2016-06-28 18:58:17 +00:00
|
|
|
//
|
2016-09-01 19:33:59 +00:00
|
|
|
// 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.
|
2016-06-28 18:58:17 +00:00
|
|
|
|
2018-08-03 19:06:09 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "test/opt/pass_fixture.h"
|
|
|
|
#include "test/opt/pass_utils.h"
|
2016-06-28 18:58:17 +00:00
|
|
|
|
2018-07-11 13:24:49 +00:00
|
|
|
namespace spvtools {
|
|
|
|
namespace opt {
|
2016-06-28 18:58:17 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
using StripLineDebugInfoTest = PassTest<::testing::Test>;
|
|
|
|
|
|
|
|
TEST_F(StripLineDebugInfoTest, LineNoLine) {
|
|
|
|
std::vector<const char*> text = {
|
2016-07-27 14:19:39 +00:00
|
|
|
// clang-format off
|
|
|
|
"OpCapability Shader",
|
|
|
|
"%1 = OpExtInstImport \"GLSL.std.450\"",
|
|
|
|
"OpMemoryModel Logical GLSL450",
|
|
|
|
"OpEntryPoint Vertex %2 \"main\"",
|
|
|
|
"%3 = OpString \"minimal.vert\"",
|
2017-10-20 22:04:20 +00:00
|
|
|
"OpModuleProcessed \"42\"",
|
|
|
|
"OpModuleProcessed \"43\"",
|
|
|
|
"OpModuleProcessed \"44\"",
|
2016-07-27 14:19:39 +00:00
|
|
|
"OpNoLine",
|
|
|
|
"OpLine %3 10 10",
|
|
|
|
"%void = OpTypeVoid",
|
|
|
|
"OpLine %3 100 100",
|
|
|
|
"%5 = OpTypeFunction %void",
|
|
|
|
"%2 = OpFunction %void None %5",
|
|
|
|
"OpLine %3 1 1",
|
|
|
|
"OpNoLine",
|
|
|
|
"OpLine %3 2 2",
|
|
|
|
"OpLine %3 3 3",
|
|
|
|
"%6 = OpLabel",
|
|
|
|
"OpLine %3 4 4",
|
|
|
|
"OpNoLine",
|
|
|
|
"OpReturn",
|
|
|
|
"OpLine %3 4 4",
|
|
|
|
"OpNoLine",
|
|
|
|
"OpFunctionEnd",
|
|
|
|
// clang-format on
|
2016-06-28 18:58:17 +00:00
|
|
|
};
|
2018-07-11 13:24:49 +00:00
|
|
|
SinglePassRunAndCheck<StripDebugInfoPass>(JoinAllInsts(text),
|
|
|
|
JoinNonDebugInsts(text),
|
|
|
|
/* skip_nop = */ false);
|
2016-06-28 18:58:17 +00:00
|
|
|
|
|
|
|
// Let's add more debug instruction before the "OpString" instruction.
|
|
|
|
const std::vector<const char*> more_text = {
|
|
|
|
"OpSourceContinued \"I'm a happy shader! Yay! ;)\"",
|
|
|
|
"OpSourceContinued \"wahahaha\"",
|
|
|
|
"OpSource ESSL 310",
|
|
|
|
"OpSource ESSL 310",
|
|
|
|
"OpSourceContinued \"wahahaha\"",
|
|
|
|
"OpSourceContinued \"wahahaha\"",
|
|
|
|
"OpSourceExtension \"save-the-world-extension\"",
|
|
|
|
"OpName %2 \"main\"",
|
|
|
|
};
|
|
|
|
text.insert(text.begin() + 4, more_text.cbegin(), more_text.cend());
|
2018-07-11 13:24:49 +00:00
|
|
|
SinglePassRunAndCheck<StripDebugInfoPass>(JoinAllInsts(text),
|
|
|
|
JoinNonDebugInsts(text),
|
|
|
|
/* skip_nop = */ false);
|
2016-06-28 18:58:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
using StripDebugInfoTest = PassTest<::testing::TestWithParam<const char*>>;
|
|
|
|
|
|
|
|
TEST_P(StripDebugInfoTest, Kind) {
|
|
|
|
std::vector<const char*> text = {
|
2017-11-27 15:16:41 +00:00
|
|
|
"OpCapability Shader",
|
|
|
|
"OpMemoryModel Logical GLSL450",
|
|
|
|
GetParam(),
|
2016-06-28 18:58:17 +00:00
|
|
|
};
|
2018-07-11 13:24:49 +00:00
|
|
|
SinglePassRunAndCheck<StripDebugInfoPass>(JoinAllInsts(text),
|
|
|
|
JoinNonDebugInsts(text),
|
|
|
|
/* skip_nop = */ false);
|
2016-06-28 18:58:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test each possible non-line debug instruction.
|
|
|
|
// clang-format off
|
|
|
|
INSTANTIATE_TEST_CASE_P(
|
|
|
|
SingleKindDebugInst, StripDebugInfoTest,
|
|
|
|
::testing::ValuesIn(std::vector<const char*>({
|
|
|
|
"OpSourceContinued \"I'm a happy shader! Yay! ;)\"",
|
|
|
|
"OpSource ESSL 310",
|
|
|
|
"OpSourceExtension \"save-the-world-extension\"",
|
|
|
|
"OpName %main \"main\"",
|
|
|
|
"OpMemberName %struct 0 \"field\"",
|
|
|
|
"%1 = OpString \"name.vert\"",
|
|
|
|
"OpModuleProcessed \"42\"",
|
|
|
|
})));
|
|
|
|
// clang-format on
|
|
|
|
|
2018-07-11 13:24:49 +00:00
|
|
|
} // namespace
|
|
|
|
} // namespace opt
|
|
|
|
} // namespace spvtools
|