From fe9b2b7efc51d03b22af54d12937026d0469bbda Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Sat, 16 Aug 2008 19:29:56 +0200 Subject: [PATCH] Fix TypeInfo_Tuple array initialization. Fixes: mini/emptytuple.d --- gen/typinf.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gen/typinf.cpp b/gen/typinf.cpp index e44a4d05..4331bf55 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -1146,8 +1146,17 @@ void TypeInfoTupleDeclaration::llvmDefine() const LLArrayType* arrTy = LLArrayType::get(tiTy, dim); LLConstant* arrC = llvm::ConstantArray::get(arrTy, arrInits); + // need the pointer to the first element of arrC, so create a global for it + llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;//WeakLinkage; + llvm::GlobalVariable* gvar = new llvm::GlobalVariable(arrTy,true,_linkage,arrC,".tupleelements",gIR->module); + + // get pointer to first element + llvm::ConstantInt* zero = DtoConstSize_t(0); + LLConstant* idxs[2] = { zero, zero }; + LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar, idxs, 2); + // build the slice - LLConstant* slice = DtoConstSlice(DtoConstSize_t(dim), arrC); + LLConstant* slice = DtoConstSlice(DtoConstSize_t(dim), arrptr); sinits.push_back(slice); // create the symbol