From 04c465b268ef8d77e5f2674ffd243c733406bbc9 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Thu, 21 Jul 2022 22:11:22 +0300 Subject: [PATCH] [Codegen] Fail to codegen `Call::undef`, just like `Call::signed_integer_overflow` (#6871) See discussion in https://github.com/halide/Halide/pull/6866. It's not obvious if that codepath is ever hit, let's optimistically assume that it is not. If this turns out to be not true, we'll have to deal with a more complicated question of the proper lowering for it, can it be `poison`, or must it be a `freeze poison`. --- src/CodeGen_C.cpp | 2 ++ src/CodeGen_LLVM.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CodeGen_C.cpp b/src/CodeGen_C.cpp index de4cd010a7d3..c5b64f0610f5 100644 --- a/src/CodeGen_C.cpp +++ b/src/CodeGen_C.cpp @@ -2558,6 +2558,8 @@ void CodeGen_C::visit(const Call *op) { user_error << "Signed integer overflow occurred during constant-folding. Signed" " integer overflow for int32 and int64 is undefined behavior in" " Halide.\n"; + } else if (op->is_intrinsic(Call::undef)) { + user_error << "undef not eliminated before code generation. Please report this as a Halide bug.\n"; } else if (op->is_intrinsic(Call::prefetch)) { user_assert((op->args.size() == 4) && is_const_one(op->args[2])) << "Only prefetch of 1 cache line is supported in C backend.\n"; diff --git a/src/CodeGen_LLVM.cpp b/src/CodeGen_LLVM.cpp index ae1acdaf5bcd..938d7a0e23b6 100644 --- a/src/CodeGen_LLVM.cpp +++ b/src/CodeGen_LLVM.cpp @@ -3183,7 +3183,7 @@ void CodeGen_LLVM::visit(const Call *op) { " integer overflow for int32 and int64 is undefined behavior in" " Halide.\n"; } else if (op->is_intrinsic(Call::undef)) { - value = UndefValue::get(llvm_type_of(op->type)); + user_error << "undef not eliminated before code generation. Please report this as a Halide bug.\n"; } else if (op->is_intrinsic(Call::size_of_halide_buffer_t)) { llvm::DataLayout d(module.get()); value = ConstantInt::get(i32_t, (int)d.getTypeAllocSize(halide_buffer_t_type));