Eliminating the 'void' type

Hello all,

I noticed Eliminating the ‘void’ type in Random LLVM notes. I am wondering to know what’s the
meaning of “eliminating” the void type. Is it means the goal is deleting VoidTyID from TypeID
enumeration in Type.h? And what Type::getVoidTy() returned is a pointer to a {}?

Thanks

Mitnick

The general concept is to replace void with {}. Void is a weird type in that it is only allowed as the return value of functions and as the type of instructions like store. It seems better (though also not particularly high priority) to eliminate it to make the type system more consistent.

-Chris

Hello Chris,

The general concept is to replace void with {}. Void is a weird type in

that it is only allowed as the return value of functions and as the type of
instructions like store. It seems better (though also not particularly
high priority) to eliminate it to make the type system more consistent.

-Chris

I also noticed a sentence "We can even make 'Type::VoidTy' be a pointer to
'{}' " in notes. Is
this idea conflict with replace void with {}?

Mitnick

The wording is confusion, but I meant that the C++ value “VoidTy” (which doesn’t even exist anymore) could be a C++ pointer to the IR type object for {}. VoidTy itself would be {}.

-Chris

Hello Chris

The general concept is to replace void with {}. Void is a weird type in

that it is only allowed as the return value of functions and as the type of
instructions like store. It seems better (though also not particularly
high priority) to eliminate it to make the type system more consistent.

MVT::isVoid and Type::VoidTyID (getVoidTy) have equivalent relation in
LLVM. I am
wondering to know whether the relation becomes MVT::isVoid corresponding to
{ } If
eliminating void type?

Thanks a lot

Mitnick

MVT is separate from the LLVM IR type system, I would not change it.

VoidTyID should go away, since there is no more distinct Void type anymore.

For API continuity, Type::getVoidTy() should still exist, but it should return {}.

-Chris

Hello,

The attachment is a patch which eliminate the "void" type only in
lib/VMCore. I can build libLLVMCore.a
successfully. However this patch didn't involve necessary modification of
the other part of LLVM. I
am wondering to know whether the modification is exactly what we want in
eliminating the "void" type?
I would like to use this patch as a starting point to eliminate the "void"
type in LLVM. And I have some
questions as follows:

(1) What is the API of ReturnInst constructor if eliminating the void type?
(2) I would like to eliminate void type progressively in LLVM. Is there any
method to test each library of
     LLVM part by part?

Thanks a lot

Mitnick

eliminate_void.patch (7.08 KB)