Skip to content

Commit

Permalink
Allow call_intrin to call an LLVM intrinsic with void return type. (h…
Browse files Browse the repository at this point in the history
…alide#7048)

Have ```CodeGen_LLVM::get_vector_type``` return the void type if passed the void type as a scalar base. This makes it possible to call intrinsics returning void via ```CodeGenn_LLVM::call_intrin```.

Should be very safe as currently this anything doing this would fail inside the routine. The change breaks the invariant that any thing returned from get_vector_type is a vector type, but propagating void for function return types is a pretty standard behavior and if this was not intended, it will very likely fail just outside this instead of having failed inside the use. I.e. very low chance of spurious errors from this.
  • Loading branch information
Zalman Stern authored and ardier committed Mar 3, 2024
1 parent ce68b52 commit 0cbf442
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4528,7 +4528,9 @@ Value *CodeGen_LLVM::call_intrin(const llvm::Type *result_type, int intrin_lanes
llvm::Function *intrin, vector<Value *> arg_values) {
internal_assert(intrin);
int arg_lanes = 1;
if (result_type->isVectorTy()) {
if (result_type->isVoidTy()) {
arg_lanes = intrin_lanes;
} else if (result_type->isVectorTy()) {
arg_lanes = get_vector_num_elements(result_type);
}

Expand Down Expand Up @@ -4913,6 +4915,10 @@ llvm::Type *CodeGen_LLVM::get_vector_type(llvm::Type *t, int n,
VectorTypeConstraint type_constraint) const {
bool scalable;

if (t->isVoidTy()) {
return t;
}

switch (type_constraint) {
case VectorTypeConstraint::None:
scalable = effective_vscale != 0 &&
Expand Down

0 comments on commit 0cbf442

Please sign in to comment.