Use the regular LL type for all init symbols and most globals

There's no <Type>_init type for aggregates (structs and classes) anymore,
effectively eliminating a *lot* of named LLVM types, some bitcasts as well
as replacements of globals etc.

To get there, it was even required to use the regular type for compatible
literals too, otherwise structs embedded as fields in other aggregates had
an anonymous type (well, the LLVM constant for the field initializer had)
and so the container initializer wasn't compatible with the regular type
anymore.

What was also necessary was a fix wrt. static arrays of bools (LLVM
constant of type `[N x i1]` vs. `[N x i8]` for regular type).
I also had to change the initializer for `char[2][3] x = 0xff` from
`[6 x i8]` to `[3 x [2 x i8]]`, i.e., NOT flattening multi-dimensional
inits from a scalar.

So only literals with overlapping (union) fields and an explicit
initializer initializing dominated non-alias union fields should still
have a mismatching anonymous type - i.e., very, very few cases.
This commit is contained in:
Martin 2016-10-22 20:00:15 +02:00
parent e6537ba4dc
commit ab1432ed06
8 changed files with 164 additions and 71 deletions

View file

@ -544,6 +544,9 @@ llvm::Constant *arrayLiteralToConst(IRState *p, ArrayLiteralExp *ale) {
vals.reserve(ale->elements->dim);
for (unsigned i = 0; i < ale->elements->dim; ++i) {
llvm::Constant *val = toConstElem(indexArrayLiteral(ale, i), p);
// extend i1 to i8
if (val->getType() == LLType::getInt1Ty(p->context()))
val = llvm::ConstantExpr::getZExt(val, LLType::getInt8Ty(p->context()));
if (!elementType) {
elementType = val->getType();
} else {