diff --git a/Makefile b/Makefile index 56b921d73f65..d90af0e12971 100644 --- a/Makefile +++ b/Makefile @@ -758,6 +758,7 @@ RUNTIME_CPP_COMPONENTS = \ fake_get_symbol \ fake_thread_pool \ float16_t \ + force_include_types \ fuchsia_clock \ fuchsia_host_cpu_count \ fuchsia_yield \ @@ -773,7 +774,6 @@ RUNTIME_CPP_COMPONENTS = \ linux_host_cpu_count \ linux_yield \ matlab \ - metadata \ metal \ metal_objc_arm \ metal_objc_x86 \ @@ -978,6 +978,8 @@ $(BIN_DIR)/build_halide_h: $(ROOT_DIR)/tools/build_halide_h.cpp -include $(OBJECTS:.o=.d) -include $(INITIAL_MODULES:.o=.d) +.SECONDARY: + # Compile generic 32- or 64-bit code # (The 'nacl' is a red herring. This is just a generic 32-bit little-endian target.) RUNTIME_TRIPLE_32 = "le32-unknown-nacl-unknown" @@ -1136,8 +1138,6 @@ clean: rm -rf $(DISTRIB_DIR) rm -rf $(ROOT_DIR)/apps/*/bin -.SECONDARY: - CORRECTNESS_TESTS = $(shell ls $(ROOT_DIR)/test/correctness/*.cpp) $(shell ls $(ROOT_DIR)/test/correctness/*.c) PERFORMANCE_TESTS = $(shell ls $(ROOT_DIR)/test/performance/*.cpp) ERROR_TESTS = $(shell ls $(ROOT_DIR)/test/error/*.cpp) diff --git a/src/CodeGen_LLVM.cpp b/src/CodeGen_LLVM.cpp index 53de525c8ca5..578c8373555a 100644 --- a/src/CodeGen_LLVM.cpp +++ b/src/CodeGen_LLVM.cpp @@ -490,12 +490,6 @@ void CodeGen_LLVM::init_codegen(const std::string &name, bool any_strict_float) semaphore_t_type = get_llvm_struct_type_by_name(module.get(), "struct.halide_semaphore_t"); internal_assert(semaphore_t_type) << "Did not find halide_semaphore_t in initial module"; - - semaphore_acquire_t_type = get_llvm_struct_type_by_name(module.get(), "struct.halide_semaphore_acquire_t"); - internal_assert(semaphore_acquire_t_type) << "Did not find halide_semaphore_acquire_t in initial module"; - - parallel_task_t_type = get_llvm_struct_type_by_name(module.get(), "struct.halide_parallel_task_t"); - internal_assert(parallel_task_t_type) << "Did not find halide_parallel_task_t in initial module"; } std::unique_ptr CodeGen_LLVM::compile(const Module &input) { diff --git a/src/CodeGen_LLVM.h b/src/CodeGen_LLVM.h index 2811c1be9c31..dcdc6eee07e1 100644 --- a/src/CodeGen_LLVM.h +++ b/src/CodeGen_LLVM.h @@ -197,9 +197,7 @@ class CodeGen_LLVM : public IRVisitor { *scalar_value_t_type, *device_interface_t_type, *pseudostack_slot_t_type, - *semaphore_t_type, - *semaphore_acquire_t_type, - *parallel_task_t_type; + *semaphore_t_type; // @} diff --git a/src/LLVM_Runtime_Linker.cpp b/src/LLVM_Runtime_Linker.cpp index c4be37a2b4ea..c00bc006e83a 100644 --- a/src/LLVM_Runtime_Linker.cpp +++ b/src/LLVM_Runtime_Linker.cpp @@ -91,6 +91,7 @@ DECLARE_CPP_INITMOD(errors) DECLARE_CPP_INITMOD(fake_get_symbol) DECLARE_CPP_INITMOD(fake_thread_pool) DECLARE_CPP_INITMOD(float16_t) +DECLARE_CPP_INITMOD(force_include_types) DECLARE_CPP_INITMOD(fuchsia_clock) DECLARE_CPP_INITMOD(fuchsia_host_cpu_count) DECLARE_CPP_INITMOD(fuchsia_yield) @@ -102,7 +103,6 @@ DECLARE_CPP_INITMOD(linux_clock) DECLARE_CPP_INITMOD(linux_host_cpu_count) DECLARE_CPP_INITMOD(linux_yield) DECLARE_CPP_INITMOD(matlab) -DECLARE_CPP_INITMOD(metadata) DECLARE_CPP_INITMOD(module_aot_ref_count) DECLARE_CPP_INITMOD(module_jit_ref_count) DECLARE_CPP_INITMOD(msan) @@ -783,7 +783,7 @@ std::unique_ptr link_with_wasm_jit_runtime(llvm::LLVMContext *c, c modules.push_back(get_initmod_to_string(c, bits_64, debug)); modules.push_back(get_initmod_alignment_32(c, bits_64, debug)); modules.push_back(get_initmod_device_interface(c, bits_64, debug)); - modules.push_back(get_initmod_metadata(c, bits_64, debug)); + modules.push_back(get_initmod_force_include_types(c, bits_64, debug)); modules.push_back(get_initmod_float16_t(c, bits_64, debug)); modules.push_back(get_initmod_errors(c, bits_64, debug)); modules.push_back(get_initmod_msan_stubs(c, bits_64, debug)); @@ -1014,7 +1014,6 @@ std::unique_ptr get_initial_module_for_target(Target t, llvm::LLVM modules.push_back(get_initmod_allocation_cache(c, bits_64, debug)); modules.push_back(get_initmod_device_interface(c, bits_64, debug)); - modules.push_back(get_initmod_metadata(c, bits_64, debug)); modules.push_back(get_initmod_float16_t(c, bits_64, debug)); modules.push_back(get_initmod_errors(c, bits_64, debug)); @@ -1220,6 +1219,8 @@ std::unique_ptr get_initial_module_for_target(Target t, llvm::LLVM modules.push_back(get_initmod_runtime_api(c, bits_64, debug)); } + modules.push_back(get_initmod_force_include_types(c, bits_64, debug)); + link_modules(modules, t); if (t.os == Target::Windows && diff --git a/src/runtime/CMakeLists.txt b/src/runtime/CMakeLists.txt index 34d5a27b181b..285369f758d1 100644 --- a/src/runtime/CMakeLists.txt +++ b/src/runtime/CMakeLists.txt @@ -22,6 +22,7 @@ set(RUNTIME_CPP fake_get_symbol fake_thread_pool float16_t + force_include_types fuchsia_clock fuchsia_host_cpu_count fuchsia_yield @@ -37,7 +38,6 @@ set(RUNTIME_CPP linux_host_cpu_count linux_yield matlab - metadata metal metal_objc_arm metal_objc_x86 diff --git a/src/runtime/force_include_types.cpp b/src/runtime/force_include_types.cpp new file mode 100644 index 000000000000..8dc9d1ccc244 --- /dev/null +++ b/src/runtime/force_include_types.cpp @@ -0,0 +1,24 @@ +#include "HalideRuntime.h" +#include "runtime_internal.h" + +extern "C" struct mxArray { int32_t unused; }; + +namespace Halide { +namespace Runtime { +namespace Internal { + +struct AllTheTypes { + halide_filter_metadata_t a; + halide_filter_argument_t b; + halide_scalar_value_t c; + halide_semaphore_t d; + mxArray e; +}; + +WEAK void halide_unused_force_include_types() { + static __attribute__((used)) AllTheTypes a; +} + +} // namespace Internal +} // namespace Runtime +} // namespace Halide diff --git a/src/runtime/metadata.cpp b/src/runtime/metadata.cpp deleted file mode 100644 index b90ba174a146..000000000000 --- a/src/runtime/metadata.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "HalideRuntime.h" - -namespace Halide { -namespace Runtime { -namespace Internal { - -// This is unused and expected to be optimized away; it exists solely to ensure -// that the halide_filter_metadata_t type is in the runtime module, so that -// Codegen_LLVM can access its description. -WEAK const halide_filter_metadata_t *unused_function_to_get_halide_filter_metadata_t_declared() { - return nullptr; -} - -} // namespace Internal -} // namespace Runtime -} // namespace Halide diff --git a/src/runtime/runtime_api.cpp b/src/runtime/runtime_api.cpp index 3d36bd7b67e7..a9a3e7ca15fd 100644 --- a/src/runtime/runtime_api.cpp +++ b/src/runtime/runtime_api.cpp @@ -18,6 +18,8 @@ // Can be generated via the following: // cat src/runtime/runtime_internal.h src/runtime/HalideRuntime*.h | grep "^[^ ][^(]*halide_[^ ]*(" | grep -v '#define' | sed "s/[^(]*halide/halide/" | sed "s/(.*//" | sed "s/^h/ \(void *)\&h/" | sed "s/$/,/" | sort | uniq +extern "C" void halide_unused_force_include_types(); + extern "C" __attribute__((used)) void *halide_runtime_api_functions[] = { (void *)&halide_buffer_copy, (void *)&halide_buffer_to_string, @@ -210,4 +212,5 @@ extern "C" __attribute__((used)) void *halide_runtime_api_functions[] = { (void *)&halide_d3d12compute_finalize_kernels, (void *)&halide_d3d12compute_release_context, (void *)&halide_d3d12compute_run, + (void *)&halide_unused_force_include_types, };