Mercurial > projects > ldc
comparison gen/tocall.cpp @ 1050:32ead42679d1
Fix a bug in the X86 ABI. The size of a struct is different from the size of a
pointer to that struct...
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Fri, 06 Mar 2009 21:15:13 +0100 |
parents | 6bb04dbee21f |
children | dc608dc33081 |
comparison
equal
deleted
inserted
replaced
1049:afe271b0e271 | 1050:32ead42679d1 |
---|---|
371 // otherwise we're looking at a normal function call | 371 // otherwise we're looking at a normal function call |
372 // or a C style vararg call | 372 // or a C style vararg call |
373 else | 373 else |
374 { | 374 { |
375 Logger::println("doing normal arguments"); | 375 Logger::println("doing normal arguments"); |
376 if (Logger::enabled()) { | |
377 Logger::println("Arguments so far: (%d)", (int)args.size()); | |
378 Logger::indent(); | |
379 for (size_t i = 0; i < args.size(); i++) { | |
380 Logger::cout() << *args[i] << '\n'; | |
381 } | |
382 Logger::undent(); | |
383 Logger::cout() << "Function type: " << tf->toChars() << '\n'; | |
384 Logger::cout() << "LLVM functype: " << *callable->getType() << '\n'; | |
385 } | |
376 | 386 |
377 size_t n = Argument::dim(tf->parameters); | 387 size_t n = Argument::dim(tf->parameters); |
378 | 388 |
379 LLSmallVector<unsigned, 10> attrptr(n, 0); | 389 LLSmallVector<unsigned, 10> attrptr(n, 0); |
380 | 390 |
384 { | 394 { |
385 Argument* fnarg = Argument::getNth(tf->parameters, i); | 395 Argument* fnarg = Argument::getNth(tf->parameters, i); |
386 assert(fnarg); | 396 assert(fnarg); |
387 DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); | 397 DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); |
388 | 398 |
399 if (Logger::enabled()) { | |
400 Logger::cout() << "Argument before ABI: " << *argval->getRVal() << '\n'; | |
401 Logger::cout() << "Argument type before ABI: " << *DtoType(argval->getType()) << '\n'; | |
402 } | |
403 | |
389 // give the ABI a say | 404 // give the ABI a say |
390 LLValue* arg = tf->fty->putParam(argval->getType(), i, argval); | 405 LLValue* arg = tf->fty->putParam(argval->getType(), i, argval); |
406 | |
407 if (Logger::enabled()) { | |
408 Logger::cout() << "Argument after ABI: " << *arg << '\n'; | |
409 Logger::cout() << "Argument type after ABI: " << *arg->getType() << '\n'; | |
410 } | |
391 | 411 |
392 int j = tf->fty->reverseParams ? beg + n - i - 1 : beg + i; | 412 int j = tf->fty->reverseParams ? beg + n - i - 1 : beg + i; |
393 | 413 |
394 // Hack around LDC assuming structs are in memory: | 414 // Hack around LDC assuming structs are in memory: |
395 // If the function wants a struct, and the argument value is a | 415 // If the function wants a struct, and the argument value is a |