Skip to content

Commit

Permalink
[Codegen] Fail to codegen Call::undef, just like `Call::signed_inte…
Browse files Browse the repository at this point in the history
…ger_overflow`

See discussion in halide#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`.
  • Loading branch information
LebedevRI committed Jul 21, 2022
1 parent 967c3bf commit 716e25a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/CodeGen_C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3227,7 +3227,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));
Expand Down

0 comments on commit 716e25a

Please sign in to comment.