1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

add support for zero initialized unions, patch by Tim Northover!

llvm-svn: 99818
This commit is contained in:
Chris Lattner 2010-03-29 17:36:02 +00:00
parent cfd24dc84c
commit f21a1afe81
2 changed files with 5 additions and 1 deletions

View File

@ -59,6 +59,7 @@ Constant *Constant::getNullValue(const Type *Ty) {
case Type::PointerTyID: case Type::PointerTyID:
return ConstantPointerNull::get(cast<PointerType>(Ty)); return ConstantPointerNull::get(cast<PointerType>(Ty));
case Type::StructTyID: case Type::StructTyID:
case Type::UnionTyID:
case Type::ArrayTyID: case Type::ArrayTyID:
case Type::VectorTyID: case Type::VectorTyID:
return ConstantAggregateZero::get(Ty); return ConstantAggregateZero::get(Ty);
@ -944,7 +945,8 @@ bool ConstantFP::isValueValidForType(const Type *Ty, const APFloat& Val) {
// Factory Function Implementation // Factory Function Implementation
ConstantAggregateZero* ConstantAggregateZero::get(const Type* Ty) { ConstantAggregateZero* ConstantAggregateZero::get(const Type* Ty) {
assert((Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()) && assert((Ty->isStructTy() || Ty->isUnionTy()
|| Ty->isArrayTy() || Ty->isVectorTy()) &&
"Cannot create an aggregate zero of non-aggregate type!"); "Cannot create an aggregate zero of non-aggregate type!");
LLVMContextImpl *pImpl = Ty->getContext().pImpl; LLVMContextImpl *pImpl = Ty->getContext().pImpl;

View File

@ -6,7 +6,9 @@
@union1 = constant union { i32, i8 } { i32 4 } @union1 = constant union { i32, i8 } { i32 4 }
@union2 = constant union { i32, i8 } insertvalue(union { i32, i8 } undef, i32 4, 0) @union2 = constant union { i32, i8 } insertvalue(union { i32, i8 } undef, i32 4, 0)
@union3 = common global %union.anon zeroinitializer, align 8
define void @"Unions" () { define void @"Unions" () {
ret void ret void
} }