Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build web
run: docker-compose up
run: docker-compose -f source/wasm/docker-compose.yml --project-directory . up
- name: Run tests
run: node test/wasm/test.js
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.17.2)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif()
Expand Down
12 changes: 11 additions & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ vars = {
'github': 'https://github.com',

'effcee_revision': '35912e1b7778ec2ddcff7e7188177761539e59e0',
'googletest_revision': 'd9bb8412d60b993365abb53f00b6dad9b2c01b62',

# Pin to the last version of googletest that supports C++11.
# Anything later requires C++14
'googletest_revision': 'v1.12.0',

# Use protobufs before they gained the dependency on abseil
'protobuf_revision': 'v3.13.0.1',

're2_revision': 'd2836d1b1c34c4e330a85a1006201db474bf2c8a',
'spirv_headers_revision': '34d04647d384e0aed037e7a2662a655fc39841bb',
}
Expand All @@ -16,6 +23,9 @@ deps = {
'external/googletest':
Var('github') + '/google/googletest.git@' + Var('googletest_revision'),

'external/protobuf':
Var('github') + '/protocolbuffers/protobuf.git@' + Var('protobuf_revision'),

'external/re2':
Var('github') + '/google/re2.git@' + Var('re2_revision'),

Expand Down
6 changes: 4 additions & 2 deletions build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ COMMON_COPTS = [
"-DSPIRV_CHECK_CONTEXT",
"-DSPIRV_COLOR_TERMINAL",
] + select({
"@bazel_tools//src/conditions:windows": [],
# On Windows, assume MSVC.
# C++14 is the default in VisualStudio 2017.
"@platforms//os:windows": [],
"//conditions:default": [
"-DSPIRV_LINUX",
"-DSPIRV_TIMER_ENABLED",
Expand All @@ -27,7 +29,7 @@ COMMON_COPTS = [

TEST_COPTS = COMMON_COPTS + [
] + select({
"@bazel_tools//src/conditions:windows": [
"@platforms//os:windows": [
# Disable C4503 "decorated name length exceeded" warning,
# triggered by some heavily templated types.
# We don't care much about that in test code.
Expand Down
16 changes: 2 additions & 14 deletions kokoro/scripts/linux/build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ fi

cd $ROOT_DIR

function clone_if_missing() {
url=$1
dir=$2
if [[ ! -d "$dir" ]]; then
git clone ${@:3} "$url" "$dir"
fi
}

function clean_dir() {
dir=$1
if [[ -d "$dir" ]]; then
Expand All @@ -46,12 +38,8 @@ function clean_dir() {
mkdir "$dir"
}

clone_if_missing https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers --depth=1
clone_if_missing https://github.com/google/googletest external/googletest
pushd external/googletest; git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31dc610fec7; popd
clone_if_missing https://github.com/google/effcee external/effcee --depth=1
clone_if_missing https://github.com/google/re2 external/re2 --depth=1
clone_if_missing https://github.com/protocolbuffers/protobuf external/protobuf --branch v3.13.0.1
# Get source for dependencies, as specified in the DEPS file
/usr/bin/python3 utils/git-sync-deps --treeless

if [ $TOOL = "cmake" ]; then
using cmake-3.17.2
Expand Down
7 changes: 1 addition & 6 deletions kokoro/scripts/macos/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ chmod +x ninja
export PATH="$PWD:$PATH"

cd $SRC
git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers
git clone https://github.com/google/googletest external/googletest
cd external && cd googletest && git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31dc610fec7 && cd .. && cd ..
git clone --depth=1 https://github.com/google/effcee external/effcee
git clone --depth=1 https://github.com/google/re2 external/re2
git clone --depth=1 --branch v3.13.0.1 https://github.com/protocolbuffers/protobuf external/protobuf
python3 utils/git-sync-deps --treeless

mkdir build && cd $SRC/build

Expand Down
10 changes: 2 additions & 8 deletions kokoro/scripts/windows/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ set VS_VERSION=%2
:: Force usage of python 3.6
set PATH=C:\python36;"C:\Program Files\cmake-3.23.1-windows-x86_64\bin";%PATH%

cd %SRC%
git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers
git clone https://github.com/google/googletest external/googletest
cd external && cd googletest && git reset --hard 1fb1bb23bb8418dc73a5a9a82bbed31dc610fec7 && cd .. && cd ..
git clone --depth=1 https://github.com/google/effcee external/effcee
git clone --depth=1 https://github.com/google/re2 external/re2
git clone --depth=1 --branch v3.13.0.1 https://github.com/protocolbuffers/protobuf external/protobuf

:: #########################################
:: set up msvc build env
:: #########################################
Expand All @@ -41,6 +33,8 @@ if %VS_VERSION% == 2017 (
)

cd %SRC%
python utils/git-sync-deps --treeless

mkdir build
cd build

Expand Down
2 changes: 1 addition & 1 deletion source/val/validate_cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ spv_result_t StructuredSwitchChecks(ValidationState_t& _, Function* function,
target_block->structurally_reachable() &&
!header->structurally_dominates(*target_block)) {
return _.diag(SPV_ERROR_INVALID_CFG, header->label())
<< "Selection header " << _.getIdName(header->id())
<< "Switch header " << _.getIdName(header->id())
<< " does not structurally dominate its case construct "
<< _.getIdName(target);
}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml → source/wasm/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3"
services:
build:
image: emscripten/emsdk:2.0.2
image: emscripten/emsdk:3.1.28
environment:
GITHUB_RUN_NUMBER: ${GITHUB_RUN_NUMBER:-}
working_dir: /app
Expand Down
100 changes: 100 additions & 0 deletions test/val/val_cfg_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,106 @@ OpFunctionEnd
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}

TEST_F(ValidateCFG, OpSwitchTargetCannotBeOuterLoopMergeBlock) {
std::string text = R"(
OpCapability Shader
OpCapability Linkage
OpMemoryModel Logical GLSL450

%1 = OpTypeVoid
%2 = OpTypeFunction %1
%3 = OpTypeBool
%4 = OpUndef %3
%5 = OpTypeInt 32 0
%6 = OpConstant %5 0

%7 = OpFunction %1 None %2

%8 = OpLabel
OpBranch %9

%9 = OpLabel
OpLoopMerge %10 %11 None
OpBranch %12

%12 = OpLabel
OpSelectionMerge %13 None
OpSwitch %6 %13 0 %10 1 %14

%14 = OpLabel
OpBranch %13

%13 = OpLabel
OpBranch %11

%11 = OpLabel
OpBranch %9

%10 = OpLabel
OpReturn

OpFunctionEnd
)";

CompileSuccessfully(text);
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
EXPECT_THAT(
getDiagnosticString(),
HasSubstr(
"Switch header '12[%12]' does not structurally dominate its case construct '10[%10]'\n"
" %12 = OpLabel"));
}

TEST_F(ValidateCFG, OpSwitchTargetCannotBeOuterLoopContinueBlock) {
std::string text = R"(
OpCapability Shader
OpCapability Linkage
OpMemoryModel Logical GLSL450

%1 = OpTypeVoid
%2 = OpTypeFunction %1
%3 = OpTypeBool
%4 = OpUndef %3
%5 = OpTypeInt 32 0
%6 = OpConstant %5 0

%7 = OpFunction %1 None %2

%8 = OpLabel
OpBranch %9

%9 = OpLabel
OpLoopMerge %10 %11 None
OpBranch %12

%12 = OpLabel
OpSelectionMerge %13 None
OpSwitch %6 %13 0 %11 1 %14

%14 = OpLabel
OpBranch %13

%13 = OpLabel
OpBranch %11

%11 = OpLabel
OpBranch %9

%10 = OpLabel
OpReturn

OpFunctionEnd
)";

CompileSuccessfully(text);
ASSERT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions());
EXPECT_THAT(
getDiagnosticString(),
HasSubstr(
"Switch header '12[%12]' does not structurally dominate its case construct '11[%11]'\n"
" %12 = OpLabel"));
}

TEST_F(ValidateCFG, WrongOperandList) {
std::string text = R"(
OpCapability Shader
Expand Down
18 changes: 17 additions & 1 deletion tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ if (NOT ${SPIRV_SKIP_EXECUTABLES})
endif(SPIRV_BUILD_FUZZER)

if(ENABLE_SPIRV_TOOLS_INSTALL)
install(TARGETS ${SPIRV_INSTALL_TARGETS} DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS ${SPIRV_INSTALL_TARGETS} EXPORT SPIRV-Tools-toolsTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
export(EXPORT SPIRV-Tools-toolsTargets FILE SPIRV-Tools-toolsTargets.cmake)

spvtools_config_package_dir(SPIRV-Tools-tools PACKAGE_DIR)
install(EXPORT SPIRV-Tools-toolsTargets FILE SPIRV-Tools-toolsTargets.cmake
DESTINATION ${PACKAGE_DIR})

file(WRITE ${CMAKE_BINARY_DIR}/SPIRV-Tools-toolsConfig.cmake
"include(CMakeFindDependencyMacro)\n"
"find_dependency(${SPIRV_TOOLS})\n"
"include(\${CMAKE_CURRENT_LIST_DIR}/SPIRV-Tools-toolsTargets.cmake)\n"
)

install(FILES ${CMAKE_BINARY_DIR}/SPIRV-Tools-toolsConfig.cmake DESTINATION ${PACKAGE_DIR})
endif(ENABLE_SPIRV_TOOLS_INSTALL)
endif()
Loading