Skip to content

Commit 75e1be7

Browse files
IRGraph C++ Printer. (#9042)
* First version of the IRGraph printer for C++ code. * typo and clang violation * Try again * Moved implementation of the IRGraphCXXPrinter to the cpp file. * Cleanup * Apply pre-commit auto-fixes * Expand test. * Don't pretend that we will IR print Stmts. * more clang-tidy; * Support printing Call statements. * Add string-based testing for IRGraphCXXPrinter. * Move IRGraphCXXPrinter to test/fuzz * Move IRGraphCXXPrinter to the fuzz folder and fixup compilation, and make the simplify fuzzer print out the Expr. --------- Co-authored-by: halide-ci[bot] <266445882+halide-ci[bot]@users.noreply.github.com>
1 parent 1a0e8d3 commit 75e1be7

5 files changed

Lines changed: 484 additions & 7 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ PERFORMANCE_TESTS = $(shell ls $(ROOT_DIR)/test/performance/*.cpp)
12861286
ERROR_TESTS = $(shell ls $(ROOT_DIR)/test/error/*.cpp)
12871287
WARNING_TESTS = $(shell ls $(ROOT_DIR)/test/warning/*.cpp)
12881288
RUNTIME_TESTS = $(shell ls $(ROOT_DIR)/test/runtime/*.cpp)
1289-
FUZZ_TESTS = $(filter-out %halide_fuzz_main.cpp, $(shell ls $(ROOT_DIR)/test/fuzz/*.cpp))
1289+
FUZZ_TESTS = $(filter-out %halide_fuzz_main.cpp %IRGraphCXXPrinter.cpp, $(shell ls $(ROOT_DIR)/test/fuzz/*.cpp))
12901290
GENERATOR_EXTERNAL_TESTS := $(shell ls $(ROOT_DIR)/test/generator/*test.cpp)
12911291
GENERATOR_EXTERNAL_TEST_GENERATOR := $(shell ls $(ROOT_DIR)/test/generator/*_generator.cpp)
12921292
TUTORIALS = $(filter-out %_generate.cpp, $(shell ls $(ROOT_DIR)/tutorial/*.cpp))
@@ -1475,7 +1475,7 @@ $(BIN_DIR)/$(TARGET)/correctness_opencl_runtime: $(ROOT_DIR)/test/correctness/op
14751475
$(BIN_DIR)/performance_%: $(ROOT_DIR)/test/performance/%.cpp $(TEST_DEPS)
14761476
$(CXX) $(TEST_CXX_FLAGS) $(OPTIMIZE) $< -I$(INCLUDE_DIR) -I$(ROOT_DIR)/src/runtime -I$(ROOT_DIR)/test/common $(TEST_LD_FLAGS) -o $@
14771477

1478-
$(BIN_DIR)/fuzz_%: $(ROOT_DIR)/test/fuzz/%.cpp $(ROOT_DIR)/test/fuzz/halide_fuzz_main.cpp $(ROOT_DIR)/test/fuzz/fuzz_helpers.h $(ROOT_DIR)/test/fuzz/halide_fuzz_main.h $(TEST_DEPS)
1478+
$(BIN_DIR)/fuzz_%: $(ROOT_DIR)/test/fuzz/%.cpp $(ROOT_DIR)/test/fuzz/halide_fuzz_main.cpp $(ROOT_DIR)/test/fuzz/fuzz_helpers.h $(ROOT_DIR)/test/fuzz/halide_fuzz_main.h $(ROOT_DIR)/test/fuzz/IRGraphCXXPrinter.cpp $(ROOT_DIR)/test/fuzz/IRGraphCXXPrinter.h $(TEST_DEPS)
14791479
$(CXX) $(TEST_CXX_FLAGS) -I$(ROOT_DIR)/src/runtime -I$(ROOT_DIR)/test/common $(OPTIMIZE_FOR_BUILD_TIME) $(filter %.cpp,$^) -I$(INCLUDE_DIR) $(TEST_LD_FLAGS) -o $@ -DHALIDE_FUZZER_BACKEND=0
14801480

14811481
# Error tests that link against libHalide

test/fuzz/CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,24 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, std::size_t Size) {
3636
}
3737
]] HAVE_LIBFUZZER_FLAGS)
3838

39-
add_library(Halide_fuzz INTERFACE)
39+
add_library(Halide_fuzz OBJECT)
4040
add_library(Halide::fuzz ALIAS Halide_fuzz)
4141

42+
target_sources(Halide_fuzz PRIVATE IRGraphCXXPrinter.cpp)
43+
target_link_libraries(Halide_fuzz PRIVATE Halide::Test)
44+
4245
if (NOT HAVE_LIBFUZZER_FLAGS)
4346
if (LIB_FUZZING_ENGINE)
4447
message(FATAL_ERROR "Cannot set LIB_FUZZING_ENGINE when not building with -fsanitize=fuzzer or a compatible fuzzing engine.")
4548
endif ()
46-
target_sources(Halide_fuzz INTERFACE halide_fuzz_main.cpp halide_fuzz_main.h)
47-
target_compile_definitions(Halide_fuzz INTERFACE HALIDE_FUZZER_BACKEND=HALIDE_FUZZER_BACKEND_STDLIB)
49+
target_sources(Halide_fuzz PRIVATE halide_fuzz_main.cpp halide_fuzz_main.h)
50+
target_compile_definitions(Halide_fuzz PUBLIC HALIDE_FUZZER_BACKEND=HALIDE_FUZZER_BACKEND_STDLIB)
4851
else ()
49-
target_link_libraries(Halide_fuzz INTERFACE ${LIB_FUZZING_ENGINE})
50-
target_compile_definitions(Halide_fuzz INTERFACE HALIDE_FUZZER_BACKEND=HALIDE_FUZZER_BACKEND_LIBFUZZER)
52+
target_link_libraries(Halide_fuzz PUBLIC ${LIB_FUZZING_ENGINE})
53+
target_compile_definitions(Halide_fuzz PUBLIC HALIDE_FUZZER_BACKEND=HALIDE_FUZZER_BACKEND_LIBFUZZER)
5154
endif ()
5255

56+
5357
foreach (fuzzer IN LISTS TEST_NAMES)
5458
target_link_libraries("${fuzzer}" PRIVATE Halide::fuzz)
5559
endforeach ()

0 commit comments

Comments
 (0)