[llvm-commits] CVS: gcc-3.4/gcc/llvm-representation.c
Chris Lattner
lattner at cs.uiuc.edu
Sat Feb 14 21:11:00 PST 2004
Changes in directory gcc-3.4/gcc:
llvm-representation.c updated: 1.3 -> 1.4
---
Log message:
Fix the C front-end version of PR239: LLVM needs a new ConstantAggregateZero class
Instead of creating gigantic arrays of "zero" values, just use a string constant
that contains "zeroinitializer". Also, increase what we consider to be null
constants.
---
Diffs of the changes: (+4 -14)
Index: gcc-3.4/gcc/llvm-representation.c
diff -u gcc-3.4/gcc/llvm-representation.c:1.3 gcc-3.4/gcc/llvm-representation.c:1.4
--- gcc-3.4/gcc/llvm-representation.c:1.3 Sat Feb 14 20:26:46 2004
+++ gcc-3.4/gcc/llvm-representation.c Sat Feb 14 21:10:29 2004
@@ -338,20 +338,9 @@
else if (llvm_type_is_fp(Ty))
return llvm_constant_new(Ty, "0.0"); /* new null fp value */
else if (Ty->ID == StructTyID) {
- llvm_value **Vals =
- (llvm_value**)xmalloc(sizeof(llvm_value*) * Ty->NumElements);
- unsigned i;
- for (i = 0; i != Ty->NumElements; ++i)
- Vals[i] = llvm_constant_get_null(Ty->Elements[i]);
- return G2V(llvm_constant_aggregate_new(Ty, Vals));
+ return llvm_constant_new(Ty, "zeroinitializer");
} else if (Ty->ID == ArrayTyID) {
- llvm_value **Vals =
- (llvm_value**)xmalloc(sizeof(llvm_value*) * Ty->x.Array.Size);
- unsigned i;
- llvm_value *El = llvm_constant_get_null(Ty->Elements[0]);
- for (i = 0; i != Ty->x.Array.Size; ++i)
- Vals[i] = El;
- return G2V(llvm_constant_aggregate_new(Ty, Vals));
+ return llvm_constant_new(Ty, "zeroinitializer");
} else
return llvm_constant_new(Ty, "0"); /* New zero integral or FP */
}
@@ -459,7 +448,8 @@
}
default: return 0;
case Constant:
- return !strcmp("0", V2C(V)->Repr) || !strcmp("0.0", V2C(V)->Repr);
+ return !strcmp("0", V2C(V)->Repr) || !strcmp("0.0", V2C(V)->Repr) ||
+ !strcmp("null", V2C(V)->Repr) || !strcmp("zeroinitializer", V2C(V)->Repr);
}
}
More information about the llvm-commits
mailing list