Mercurial > projects > ldc
diff gen/toir.cpp @ 212:4c2689d57ba4 trunk
[svn r228] Fixed: when new'ing basic types, the storage was not default initialized.
Fixed: the tango/lib/compiler/llvmdc/llvmdc.mak makefile was a bit incorrect.
Changed: the basic gc is now the default.
Changed: renamed a few temporary names in the LLVM IR output.
author | lindquist |
---|---|
date | Tue, 27 May 2008 22:14:24 +0200 |
parents | 1d6cfdbc97f0 |
children | 7816aafeea3c |
line wrap: on
line diff
--- a/gen/toir.cpp Tue May 27 19:53:29 2008 +0200 +++ b/gen/toir.cpp Tue May 27 22:14:24 2008 +0200 @@ -444,7 +444,7 @@ llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;//WeakLinkage; Logger::cout() << "type: " << *at << "\ninit: " << *_init << '\n'; - llvm::GlobalVariable* gvar = new llvm::GlobalVariable(at,true,_linkage,_init,"stringliteral",gIR->module); + llvm::GlobalVariable* gvar = new llvm::GlobalVariable(at,true,_linkage,_init,".stringliteral",gIR->module); llvm::ConstantInt* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); llvm::Constant* idxs[2] = { zero, zero }; @@ -534,7 +534,7 @@ } llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;//WeakLinkage; - llvm::GlobalVariable* gvar = new llvm::GlobalVariable(_init->getType(),true,_linkage,_init,"stringliteral",gIR->module); + llvm::GlobalVariable* gvar = new llvm::GlobalVariable(_init->getType(),true,_linkage,_init,".stringliteral",gIR->module); llvm::ConstantInt* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); llvm::Constant* idxs[2] = { zero, zero }; @@ -1979,8 +1979,14 @@ { // allocate llvm::Value* mem = DtoNew(newtype); - // BUG: default initialize - // return + DVarValue tmpvar(newtype, mem, true); + + // default initialize + Expression* exp = newtype->defaultInit(loc); + DValue* iv = exp->toElem(gIR); + DtoAssign(&tmpvar, iv); + + // return as pointer-to return new DImValue(type, mem, false); } @@ -2082,7 +2088,7 @@ // create basic blocks llvm::BasicBlock* oldend = p->scopeend(); llvm::BasicBlock* assertbb = llvm::BasicBlock::Create("assert", p->topfunc(), oldend); - llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endassert", p->topfunc(), oldend); + llvm::BasicBlock* endbb = llvm::BasicBlock::Create("noassert", p->topfunc(), oldend); // test condition llvm::Value* condval = cond->getRVal();