mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-21 07:13:13 +01:00
[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.
This commit is contained in:
16
gen/toir.cpp
16
gen/toir.cpp
@@ -444,7 +444,7 @@ DValue* StringExp::toElem(IRState* p)
|
||||
|
||||
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::Constant* StringExp::toConstElem(IRState* p)
|
||||
}
|
||||
|
||||
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 @@ DValue* NewExp::toElem(IRState* p)
|
||||
{
|
||||
// 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 @@ DValue* AssertExp::toElem(IRState* p)
|
||||
// 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();
|
||||
|
||||
@@ -764,6 +764,7 @@ tangotests/mem2.d
|
||||
tangotests/mem3.d
|
||||
tangotests/mem4.d
|
||||
tangotests/mem5.d
|
||||
tangotests/mem6.d
|
||||
tangotests/n.d
|
||||
tangotests/o.d
|
||||
tangotests/r.d
|
||||
|
||||
@@ -206,7 +206,7 @@ extern (C) void* _d_newarrayT(TypeInfo ti, size_t length)
|
||||
void* p;
|
||||
auto size = ti.next.tsize(); // array element size
|
||||
|
||||
debug(PRINTF) printf("_d_newarrayT(length = x%x, size = %d)\n", length, size);
|
||||
debug(PRINTF) printf("_d_newarrayT(length = %u, size = %d)\n", length, size);
|
||||
if (length == 0 || size == 0)
|
||||
return null;
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
# make clean
|
||||
# Delete unneeded files created by build process
|
||||
|
||||
LIB_TARGET=libtango-rt-llvmdc.a
|
||||
LIB_MASK=libtango-rt-llvmdc*.a
|
||||
LIB_TARGET=libtango-base-llvmdc.a
|
||||
LIB_MASK=libtango-base-llvmdc*.a
|
||||
|
||||
LIB_TARGET_C=libtango-rt-c-llvmdc.a
|
||||
LIB_MASK_C=libtango-rt-c-llvmdc*.a
|
||||
LIB_TARGET_C=libtango-base-c-llvmdc.a
|
||||
LIB_MASK_C=libtango-base-c-llvmdc*.a
|
||||
|
||||
CP=cp -f
|
||||
RM=rm -f
|
||||
|
||||
@@ -17,8 +17,8 @@ LIB_MASK_C=libtango-base-c-llvmdc*.a
|
||||
|
||||
DIR_CC=./common/tango
|
||||
DIR_RT=./compiler/llvmdc
|
||||
#DIR_GC=./gc/basic
|
||||
DIR_GC=./gc/stub
|
||||
DIR_GC=./gc/basic
|
||||
#DIR_GC=./gc/stub
|
||||
|
||||
CP=cp -f
|
||||
RM=rm -f
|
||||
|
||||
17
tangotests/mem6.d
Normal file
17
tangotests/mem6.d
Normal file
@@ -0,0 +1,17 @@
|
||||
module tangotests.mem6;
|
||||
|
||||
extern(C) int printf(char*,...);
|
||||
|
||||
int main(){
|
||||
int[] index;
|
||||
char[] value;
|
||||
|
||||
foreach(int i, char c; "_\U00012345-"){
|
||||
printf("str[%d] = %d\n", i , cast(int)c);
|
||||
index ~= i;
|
||||
//value ~= c;
|
||||
}
|
||||
printf("done\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user