Use null instead of undef for unneeded nested context pointers.

This commit is contained in:
David Nadlinger 2012-10-06 13:07:17 +02:00
parent 0fb39ee912
commit 2d54a02295
2 changed files with 7 additions and 1 deletions

View file

@ -235,7 +235,10 @@ LLValue* DtoNestedContext(Loc loc, Dsymbol* sym)
} }
else else
{ {
return llvm::UndefValue::get(getVoidPtrType()); // Use null instead of e.g. LLVM's undef to not break bitwise
// comparison for instances of nested struct types which don't have any
// nested references.
return llvm::ConstantPointerNull::get(getVoidPtrType());
} }
struct FuncDeclaration* fd = 0; struct FuncDeclaration* fd = 0;

View file

@ -2951,6 +2951,7 @@ DValue* StructLiteralExp::toElem(IRState* p)
offset = vd->offset + vd->type->size(); offset = vd->offset + vd->type->size();
IF_LOG Logger::println("initializing field: %s %s (+%u)", vd->type->toChars(), vd->toChars(), vd->offset); IF_LOG Logger::println("initializing field: %s %s (+%u)", vd->type->toChars(), vd->toChars(), vd->offset);
LOG_SCOPE
// get initializer // get initializer
Expression* expr = (it.index < nexprs) ? exprs[it.index] : NULL; Expression* expr = (it.index < nexprs) ? exprs[it.index] : NULL;
@ -2965,6 +2966,7 @@ DValue* StructLiteralExp::toElem(IRState* p)
#if DMDV2 #if DMDV2
else if (vd == sd->vthis) { else if (vd == sd->vthis) {
IF_LOG Logger::println("initializing vthis"); IF_LOG Logger::println("initializing vthis");
LOG_SCOPE
val = new DImValue(vd->type, DtoBitCast(DtoNestedContext(loc, sd), DtoType(vd->type))); val = new DImValue(vd->type, DtoBitCast(DtoNestedContext(loc, sd), DtoType(vd->type)));
} }
#endif #endif
@ -2973,6 +2975,7 @@ DValue* StructLiteralExp::toElem(IRState* p)
if (vd->init && vd->init->isVoidInitializer()) if (vd->init && vd->init->isVoidInitializer())
continue; continue;
IF_LOG Logger::println("using default initializer"); IF_LOG Logger::println("using default initializer");
LOG_SCOPE
cv.c = get_default_initializer(vd, NULL); cv.c = get_default_initializer(vd, NULL);
val = &cv; val = &cv;
} }