diff --git a/.circleci/config.yml b/.circleci/config.yml
index e590cb7b1..70b42d537 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -88,10 +88,8 @@ defaults:
- test/tools/ossfuzz/abiv2_proto_ossfuzz
- test/tools/ossfuzz/abiv2_isabelle_ossfuzz
- test/tools/ossfuzz/const_opt_ossfuzz
- - test/tools/ossfuzz/solc_noopt_mutator_ossfuzz
- - test/tools/ossfuzz/solc_noopt_ossfuzz
- - test/tools/ossfuzz/solc_opt_mutator_ossfuzz
- - test/tools/ossfuzz/solc_opt_ossfuzz
+ - test/tools/ossfuzz/solc_mutator_ossfuzz
+ - test/tools/ossfuzz/solc_ossfuzz
- test/tools/ossfuzz/strictasm_assembly_ossfuzz
- test/tools/ossfuzz/strictasm_diff_ossfuzz
- test/tools/ossfuzz/strictasm_opt_ossfuzz
diff --git a/test/tools/fuzzer_common.cpp b/test/tools/fuzzer_common.cpp
index 9b0909bb3..16342c1c9 100644
--- a/test/tools/fuzzer_common.cpp
+++ b/test/tools/fuzzer_common.cpp
@@ -81,7 +81,13 @@ void FuzzerUtil::forceSMT(StringMap& _input)
sourceUnit.second += smtPragma;
}
-void FuzzerUtil::testCompiler(StringMap& _input, bool _optimize, unsigned _rand, bool _forceSMT)
+void FuzzerUtil::testCompiler(
+ StringMap& _input,
+ bool _optimize,
+ unsigned _rand,
+ bool _forceSMT,
+ bool _compileViaYul
+)
{
frontend::CompilerStack compiler;
EVMVersion evmVersion = s_evmVersions[_rand % s_evmVersions.size()];
@@ -98,6 +104,7 @@ void FuzzerUtil::testCompiler(StringMap& _input, bool _optimize, unsigned _rand,
compiler.setSources(_input);
compiler.setEVMVersion(evmVersion);
compiler.setOptimiserSettings(optimiserSettings);
+ compiler.enableIRGeneration(_compileViaYul);
try
{
compiler.compile();
diff --git a/test/tools/fuzzer_common.h b/test/tools/fuzzer_common.h
index de8d52f8f..6da501d92 100644
--- a/test/tools/fuzzer_common.h
+++ b/test/tools/fuzzer_common.h
@@ -41,7 +41,8 @@ struct FuzzerUtil
solidity::StringMap& _input,
bool _optimize,
unsigned _rand,
- bool _forceSMT
+ bool _forceSMT,
+ bool _compileViaYul
);
/// Adds the experimental SMTChecker pragma to each source file in the
/// source map.
diff --git a/test/tools/ossfuzz/CMakeLists.txt b/test/tools/ossfuzz/CMakeLists.txt
index dbfdbf1a1..4f73ac98c 100644
--- a/test/tools/ossfuzz/CMakeLists.txt
+++ b/test/tools/ossfuzz/CMakeLists.txt
@@ -1,9 +1,7 @@
add_custom_target(ossfuzz)
add_dependencies(ossfuzz
- solc_opt_ossfuzz
- solc_opt_mutator_ossfuzz
- solc_noopt_ossfuzz
- solc_noopt_mutator_ossfuzz
+ solc_ossfuzz
+ solc_mutator_ossfuzz
const_opt_ossfuzz
strictasm_diff_ossfuzz
strictasm_opt_ossfuzz
@@ -24,41 +22,23 @@ if (OSSFUZZ)
endif()
if (OSSFUZZ)
- add_executable(solc_opt_ossfuzz
- solc_opt_ossfuzz.cpp
+ add_executable(solc_ossfuzz
+ solc_ossfuzz.cpp
../fuzzer_common.cpp
../../TestCaseReader.cpp
)
- target_link_libraries(solc_opt_ossfuzz PRIVATE libsolc evmasm)
- set_target_properties(solc_opt_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
+ target_link_libraries(solc_ossfuzz PRIVATE libsolc evmasm)
+ set_target_properties(solc_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
- add_executable(solc_opt_mutator_ossfuzz
- solc_opt_ossfuzz.cpp
+ add_executable(solc_mutator_ossfuzz
+ solc_ossfuzz.cpp
../fuzzer_common.cpp
../../TestCaseReader.cpp
SolidityGenerator.cpp
SolidityCustomMutatorInterface.cpp
)
- target_link_libraries(solc_opt_mutator_ossfuzz PRIVATE libsolc evmasm)
- set_target_properties(solc_opt_mutator_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
-
- add_executable(solc_noopt_ossfuzz
- solc_noopt_ossfuzz.cpp
- ../fuzzer_common.cpp
- ../../TestCaseReader.cpp
- )
- target_link_libraries(solc_noopt_ossfuzz PRIVATE libsolc evmasm)
- set_target_properties(solc_noopt_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
-
- add_executable(solc_noopt_mutator_ossfuzz
- solc_noopt_ossfuzz.cpp
- ../fuzzer_common.cpp
- ../../TestCaseReader.cpp
- SolidityGenerator.cpp
- SolidityCustomMutatorInterface.cpp
- )
- target_link_libraries(solc_noopt_mutator_ossfuzz PRIVATE libsolc evmasm)
- set_target_properties(solc_noopt_mutator_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
+ target_link_libraries(solc_mutator_ossfuzz PRIVATE libsolc evmasm)
+ set_target_properties(solc_mutator_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
add_executable(const_opt_ossfuzz const_opt_ossfuzz.cpp ../fuzzer_common.cpp)
target_link_libraries(const_opt_ossfuzz PRIVATE libsolc evmasm)
@@ -189,29 +169,17 @@ if (OSSFUZZ)
set_target_properties(sol_proto_ossfuzz PROPERTIES LINK_FLAGS ${LIB_FUZZING_ENGINE})
target_compile_options(sol_proto_ossfuzz PUBLIC ${COMPILE_OPTIONS} -Wno-sign-conversion -Wno-suggest-destructor-override -Wno-inconsistent-missing-destructor-override)
else()
- add_library(solc_opt_ossfuzz
- solc_opt_ossfuzz.cpp
+ add_library(solc_ossfuzz
+ solc_ossfuzz.cpp
../fuzzer_common.cpp
)
- target_link_libraries(solc_opt_ossfuzz PRIVATE libsolc evmasm)
+ target_link_libraries(solc_ossfuzz PRIVATE libsolc evmasm)
- add_library(solc_opt_mutator_ossfuzz
- solc_opt_ossfuzz.cpp
+ add_library(solc_mutator_ossfuzz
+ solc_ossfuzz.cpp
../fuzzer_common.cpp
)
- target_link_libraries(solc_opt_mutator_ossfuzz PRIVATE libsolc evmasm)
-
- add_library(solc_noopt_ossfuzz
- solc_noopt_ossfuzz.cpp
- ../fuzzer_common.cpp
- )
- target_link_libraries(solc_noopt_ossfuzz PRIVATE libsolc evmasm)
-
- add_library(solc_noopt_mutator_ossfuzz
- solc_noopt_ossfuzz.cpp
- ../fuzzer_common.cpp
- )
- target_link_libraries(solc_noopt_mutator_ossfuzz PRIVATE libsolc evmasm)
+ target_link_libraries(solc_mutator_ossfuzz PRIVATE libsolc evmasm)
add_library(const_opt_ossfuzz
const_opt_ossfuzz.cpp
diff --git a/test/tools/ossfuzz/solc_opt_ossfuzz.cpp b/test/tools/ossfuzz/solc_opt_ossfuzz.cpp
deleted file mode 100644
index fab83166d..000000000
--- a/test/tools/ossfuzz/solc_opt_ossfuzz.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- This file is part of solidity.
-
- solidity is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- solidity is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with solidity. If not, see .
-*/
-// SPDX-License-Identifier: GPL-3.0
-
-#include
-
-#include
-
-#include
-
-using namespace solidity::frontend::test;
-using namespace std;
-
-// Prototype as we can't use the FuzzerInterface.h header.
-extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size);
-
-extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
-{
- if (_size <= 600)
- {
- string input(reinterpret_cast(_data), _size);
- map sourceCode;
- try
- {
- TestCaseReader t = TestCaseReader(std::istringstream(input));
- sourceCode = t.sources().sources;
- }
- catch (runtime_error const&)
- {
- return 0;
- }
- FuzzerUtil::testCompiler(
- sourceCode,
- /*optimize=*/true,
- /*rand=*/static_cast(_size),
- /*forceSMT=*/true
- );
- }
- return 0;
-}
diff --git a/test/tools/ossfuzz/solc_noopt_ossfuzz.cpp b/test/tools/ossfuzz/solc_ossfuzz.cpp
similarity index 75%
rename from test/tools/ossfuzz/solc_noopt_ossfuzz.cpp
rename to test/tools/ossfuzz/solc_ossfuzz.cpp
index 0ca9eac2b..620ef332b 100644
--- a/test/tools/ossfuzz/solc_noopt_ossfuzz.cpp
+++ b/test/tools/ossfuzz/solc_ossfuzz.cpp
@@ -38,17 +38,23 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
{
TestCaseReader t = TestCaseReader(std::istringstream(input));
sourceCode = t.sources().sources;
+ map settings = t.settings();
+ bool compileViaYul =
+ settings.count("compileViaYul") &&
+ (settings.at("compileViaYul") == "also" || settings.at("compileViaYul") == "true");
+ bool optimize = settings.count("optimize") && settings.at("optimize") == "true";
+ FuzzerUtil::testCompiler(
+ sourceCode,
+ optimize,
+ /*_rand=*/static_cast(_size),
+ /*forceSMT=*/true,
+ compileViaYul
+ );
}
catch (runtime_error const&)
{
return 0;
}
- FuzzerUtil::testCompiler(
- sourceCode,
- /*optimize=*/false,
- /*_rand=*/static_cast(_size),
- /*forceSMT=*/true
- );
}
return 0;
}