Commit 5375f478 by Ben Clayton

Put LLVM IR verification behind a default-disabled flag

Verification can take upwards of 10% of a dEQP test's execution time. Verification is enabled for Kokoro builds and unit tests as silently regressing would be a Bad Thing. Verification is also enabled for debug (!NDEBUG) builds. Bug: b/135609394 Change-Id: I6c354c40f524e1e8f3e08f24129b7e008163b4bd Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/33215 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 900e1dac
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
{ {
"name": "Linux", "name": "Linux",
"defines": [ "defines": [
"ENABLE_RR_DEBUG_INFO=1" "ENABLE_RR_DEBUG_INFO=1",
"VERIFY_LLVM_IR=1"
], ],
"includePath": [ "includePath": [
"${workspaceFolder}/src", "${workspaceFolder}/src",
...@@ -19,7 +20,8 @@ ...@@ -19,7 +20,8 @@
{ {
"name": "Mac", "name": "Mac",
"defines": [ "defines": [
"ENABLE_RR_DEBUG_INFO=1" "ENABLE_RR_DEBUG_INFO=1",
"VERIFY_LLVM_IR=1"
], ],
"includePath": [ "includePath": [
"${workspaceFolder}/src", "${workspaceFolder}/src",
...@@ -35,7 +37,8 @@ ...@@ -35,7 +37,8 @@
{ {
"name": "Win32", "name": "Win32",
"defines": [ "defines": [
"ENABLE_RR_DEBUG_INFO=1" "ENABLE_RR_DEBUG_INFO=1",
"VERIFY_LLVM_IR=1"
], ],
"includePath": [ "includePath": [
"${workspaceFolder}/src", "${workspaceFolder}/src",
......
...@@ -69,7 +69,8 @@ ...@@ -69,7 +69,8 @@
"-GNinja", "-GNinja",
"-DCMAKE_BUILD_TYPE=${input:buildType}", "-DCMAKE_BUILD_TYPE=${input:buildType}",
"-DWARNINGS_AS_ERRORS=1", "-DWARNINGS_AS_ERRORS=1",
"-DDCHECK_ALWAYS_ON=1" "-DDCHECK_ALWAYS_ON=1",
"-DREACTOR_VERIFY_LLVM_IR=1",
], ],
"options": { "options": {
"cwd": "${workspaceRoot}/build" "cwd": "${workspaceRoot}/build"
......
...@@ -89,6 +89,7 @@ option(WARNINGS_AS_ERRORS "Treat all warnings as errors" 1) ...@@ -89,6 +89,7 @@ option(WARNINGS_AS_ERRORS "Treat all warnings as errors" 1)
option(DCHECK_ALWAYS_ON "Check validation macros even in release builds" 0) option(DCHECK_ALWAYS_ON "Check validation macros even in release builds" 0)
option(REACTOR_EMIT_DEBUG_INFO "Emit debug info for JIT functions" 0) option(REACTOR_EMIT_DEBUG_INFO "Emit debug info for JIT functions" 0)
option(REACTOR_EMIT_PRINT_LOCATION "Emit printing of location info for JIT functions" 0) option(REACTOR_EMIT_PRINT_LOCATION "Emit printing of location info for JIT functions" 0)
option(REACTOR_VERIFY_LLVM_IR "Check reactor-generated LLVM IR is valid even in release builds" 0)
if(ARCH STREQUAL "arm") if(ARCH STREQUAL "arm")
set(DEFAULT_REACTOR_BACKEND "Subzero") set(DEFAULT_REACTOR_BACKEND "Subzero")
...@@ -464,6 +465,10 @@ if(REACTOR_EMIT_DEBUG_INFO) ...@@ -464,6 +465,10 @@ if(REACTOR_EMIT_DEBUG_INFO)
list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_DEBUG_INFO") list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_DEBUG_INFO")
endif() endif()
if(REACTOR_VERIFY_LLVM_IR)
list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_LLVM_IR_VERIFICATION")
endif()
if(WIN32) if(WIN32)
add_definitions(-DWINVER=0x501 -DNOMINMAX -DSTRICT) add_definitions(-DWINVER=0x501 -DNOMINMAX -DSTRICT)
set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "" "lib") set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "" "lib")
......
...@@ -1051,14 +1051,13 @@ namespace rr ...@@ -1051,14 +1051,13 @@ namespace rr
::module->print(file, 0); ::module->print(file, 0);
} }
// FIXME: Disable for release builds once heavy development is over. #if defined(ENABLE_RR_LLVM_IR_VERIFICATION) || !defined(NDEBUG)
bool verifyIR = true;
if(verifyIR)
{ {
llvm::legacy::PassManager pm; llvm::legacy::PassManager pm;
pm.add(llvm::createVerifierPass()); pm.add(llvm::createVerifierPass());
pm.run(*::module); pm.run(*::module);
} }
#endif // defined(ENABLE_RR_LLVM_IR_VERIFICATION) || !defined(NDEBUG)
if(runOptimizations) if(runOptimizations)
{ {
......
...@@ -15,7 +15,7 @@ if [[ -z "${REACTOR_BACKEND}" ]]; then ...@@ -15,7 +15,7 @@ if [[ -z "${REACTOR_BACKEND}" ]]; then
REACTOR_BACKEND="LLVM" REACTOR_BACKEND="LLVM"
fi fi
cmake .. "-DREACTOR_BACKEND=${REACTOR_BACKEND}" cmake .. "-DREACTOR_BACKEND=${REACTOR_BACKEND}" "-DREACTOR_VERIFY_LLVM_IR=1"
make --jobs=$(nproc) make --jobs=$(nproc)
# Run the reactor unit tests. # Run the reactor unit tests.
......
...@@ -17,7 +17,7 @@ SET CONFIG=Debug ...@@ -17,7 +17,7 @@ SET CONFIG=Debug
cd %SRC%\build cd %SRC%\build
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
cmake .. -G "Visual Studio 15 2017 Win64" -Thost=x64 "-DREACTOR_BACKEND=%REACTOR_BACKEND%" cmake .. -G "Visual Studio 15 2017 Win64" -Thost=x64 "-DREACTOR_BACKEND=%REACTOR_BACKEND%" "-DREACTOR_VERIFY_LLVM_IR=1"
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
%MSBUILD% /p:Configuration=%CONFIG% SwiftShader.sln %MSBUILD% /p:Configuration=%CONFIG% SwiftShader.sln
......
...@@ -15,7 +15,7 @@ if [[ -z "${REACTOR_BACKEND}" ]]; then ...@@ -15,7 +15,7 @@ if [[ -z "${REACTOR_BACKEND}" ]]; then
REACTOR_BACKEND="LLVM" REACTOR_BACKEND="LLVM"
fi fi
cmake .. "-DASAN=ON -DREACTOR_BACKEND=${REACTOR_BACKEND} -DCMAKE_BUILD_TYPE=RelWithDebInfo" cmake .. "-DASAN=ON -DREACTOR_BACKEND=${REACTOR_BACKEND} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DREACTOR_VERIFY_LLVM_IR=1"
make -j$(sysctl -n hw.logicalcpu) make -j$(sysctl -n hw.logicalcpu)
# Run the reactor unit tests. # Run the reactor unit tests.
......
...@@ -720,6 +720,7 @@ func (t *test) build() error { ...@@ -720,6 +720,7 @@ func (t *test) build() error {
if err := shell.Shell(buildTimeout, t.r.cmake, t.buildDir, if err := shell.Shell(buildTimeout, t.r.cmake, t.buildDir,
"-DCMAKE_BUILD_TYPE=Release", "-DCMAKE_BUILD_TYPE=Release",
"-DDCHECK_ALWAYS_ON=1", "-DDCHECK_ALWAYS_ON=1",
"-DREACTOR_VERIFY_LLVM_IR=1",
".."); err != nil { ".."); err != nil {
return err return err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment