Skip to content

Commit ce4c6ee

Browse files
committed
Move IRGraphCXXPrinter to the fuzz folder and fixup compilation, and make the simplify fuzzer print out the Expr.
1 parent 6ea527a commit ce4c6ee

File tree

7 files changed

+20
-22
lines changed

7 files changed

+20
-22
lines changed

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ SOURCE_FILES = \
529529
Interval.cpp \
530530
IR.cpp \
531531
IREquality.cpp \
532-
IRGraphCXXPrinter.cpp \
533532
IRMatch.cpp \
534533
IRMutator.cpp \
535534
IROperator.cpp \
@@ -733,7 +732,6 @@ HEADER_FILES = \
733732
IntrusivePtr.h \
734733
IR.h \
735734
IREquality.h \
736-
IRGraphCXXPrinter.h \
737735
IRMatch.h \
738736
IRMutator.h \
739737
IROperator.h \
@@ -1288,7 +1286,7 @@ PERFORMANCE_TESTS = $(shell ls $(ROOT_DIR)/test/performance/*.cpp)
12881286
ERROR_TESTS = $(shell ls $(ROOT_DIR)/test/error/*.cpp)
12891287
WARNING_TESTS = $(shell ls $(ROOT_DIR)/test/warning/*.cpp)
12901288
RUNTIME_TESTS = $(shell ls $(ROOT_DIR)/test/runtime/*.cpp)
1291-
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))
12921290
GENERATOR_EXTERNAL_TESTS := $(shell ls $(ROOT_DIR)/test/generator/*test.cpp)
12931291
GENERATOR_EXTERNAL_TEST_GENERATOR := $(shell ls $(ROOT_DIR)/test/generator/*_generator.cpp)
12941292
TUTORIALS = $(filter-out %_generate.cpp, $(shell ls $(ROOT_DIR)/tutorial/*.cpp))
@@ -1477,7 +1475,7 @@ $(BIN_DIR)/$(TARGET)/correctness_opencl_runtime: $(ROOT_DIR)/test/correctness/op
14771475
$(BIN_DIR)/performance_%: $(ROOT_DIR)/test/performance/%.cpp $(TEST_DEPS)
14781476
$(CXX) $(TEST_CXX_FLAGS) $(OPTIMIZE) $< -I$(INCLUDE_DIR) -I$(ROOT_DIR)/src/runtime -I$(ROOT_DIR)/test/common $(TEST_LD_FLAGS) -o $@
14791477

1480-
$(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)
14811479
$(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
14821480

14831481
# Error tests that link against libHalide

src/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ target_sources(
139139
IntrusivePtr.h
140140
IR.h
141141
IREquality.h
142-
IRGraphCXXPrinter.h
143142
IRMatch.h
144143
IRMutator.h
145144
IROperator.h
@@ -319,7 +318,6 @@ target_sources(
319318
Interval.cpp
320319
IR.cpp
321320
IREquality.cpp
322-
IRGraphCXXPrinter.cpp
323321
IRMatch.cpp
324322
IRMutator.cpp
325323
IROperator.cpp

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 ()

test/fuzz/IRGraphCXXPrinter.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
#include "IRGraphCXXPrinter.h"
22

3-
#include "Expr.h"
4-
#include "Function.h"
5-
#include "IR.h"
6-
#include "IREquality.h"
7-
#include "IROperator.h"
8-
93
#include <sstream>
104

115
namespace Halide {

test/fuzz/IRGraphCXXPrinter.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
#include <string>
77
#include <vector>
88

9-
#include "Expr.h"
10-
#include "IR.h"
11-
#include "IRVisitor.h"
9+
#include <Halide.h>
1210

1311
namespace Halide {
1412
namespace Internal {

test/fuzz/simplify.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "Halide.h"
22
#include <functional>
33

4+
#include "IRGraphCXXPrinter.h"
45
#include "fuzz_helpers.h"
56
#include "random_expr_generator.h"
67

@@ -153,6 +154,13 @@ FUZZ_TEST(simplify, FuzzingContext &fuzz) {
153154
return e;
154155
});
155156
std::cerr << "Final test case: " << test << "\n";
157+
158+
std::cerr << "\n\nC++ code:\n\n";
159+
IRGraphCXXPrinter printer(std::cerr);
160+
printer.print(test);
161+
std::cerr << "Expr final_expr = " << printer.node_names[test.get()] << ";\n";
162+
std::cerr << "\n\n";
163+
156164
return 1;
157165
}
158166

test/internal.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "Generator.h"
1010
#include "IR.h"
1111
#include "IREquality.h"
12-
#include "IRGraphCXXPrinter.h"
1312
#include "IRMatch.h"
1413
#include "IRPrinter.h"
1514
#include "Interval.h"
@@ -25,7 +24,6 @@ using namespace Halide::Internal;
2524

2625
int main(int argc, const char **argv) {
2726
IRPrinter::test();
28-
IRGraphCXXPrinter::test();
2927
CodeGen_C::test();
3028
ir_equality_test();
3129
bounds_test();

0 commit comments

Comments
 (0)