comparison gen/tocall.cpp @ 1350:15e9762bb620

Adds explicit alignment information for alloca instructions in general, there's a few cases that still needs to be looked at but this should catch the majority. Fixes ticket #293 .
author Tomas Lindquist Olsen <tomas.l.olsen gmail com>
date Thu, 14 May 2009 13:26:40 +0200
parents 459b6b6f9a8d
children 46f6365a50d7
comparison
equal deleted inserted replaced
1349:a376776e2301 1350:15e9762bb620
167 const LLStructType* vtype = LLStructType::get(vtypes); 167 const LLStructType* vtype = LLStructType::get(vtypes);
168 168
169 if (Logger::enabled()) 169 if (Logger::enabled())
170 Logger::cout() << "d-variadic argument struct type:\n" << *vtype << '\n'; 170 Logger::cout() << "d-variadic argument struct type:\n" << *vtype << '\n';
171 171
172 LLValue* mem = DtoAlloca(vtype,"_argptr_storage"); 172 LLValue* mem = DtoRawAlloca(vtype, 0, "_argptr_storage");
173 173
174 // store arguments in the struct 174 // store arguments in the struct
175 for (int i=begin,k=0; i<n_arguments; i++,k++) 175 for (int i=begin,k=0; i<n_arguments; i++,k++)
176 { 176 {
177 Expression* argexp = (Expression*)arguments->data[i]; 177 Expression* argexp = (Expression*)arguments->data[i];
314 args.reserve(tf->fty.args.size()); 314 args.reserve(tf->fty.args.size());
315 315
316 // return in hidden ptr is first 316 // return in hidden ptr is first
317 if (retinptr) 317 if (retinptr)
318 { 318 {
319 LLValue* retvar = DtoAlloca(argiter->get()->getContainedType(0), ".rettmp"); 319 LLValue* retvar = DtoRawAlloca(argiter->get()->getContainedType(0), 0, ".rettmp");
320 ++argiter; 320 ++argiter;
321 args.push_back(retvar); 321 args.push_back(retvar);
322 322
323 // add attrs for hidden ptr 323 // add attrs for hidden ptr
324 Attr.Index = 1; 324 Attr.Index = 1;
550 // Hack around LDC assuming structs are in memory: 550 // Hack around LDC assuming structs are in memory:
551 // If the function returns a struct, and the return value is not a 551 // If the function returns a struct, and the return value is not a
552 // pointer to a struct, store it to a stack slot before continuing. 552 // pointer to a struct, store it to a stack slot before continuing.
553 if (tf->next->ty == Tstruct && !isaPointer(retllval)) { 553 if (tf->next->ty == Tstruct && !isaPointer(retllval)) {
554 Logger::println("Storing return value to stack slot"); 554 Logger::println("Storing return value to stack slot");
555 LLValue* mem = DtoAlloca(retllval->getType()); 555 LLValue* mem = DtoRawAlloca(retllval->getType(), 0);
556 DtoStore(retllval, mem); 556 DtoStore(retllval, mem);
557 retllval = mem; 557 retllval = mem;
558 } 558 }
559 559
560 // repaint the type if necessary 560 // repaint the type if necessary