Mercurial > projects > ldc
comparison gen/abi-x86-64.cpp @ 1346:6f4154b318ef
Remove an old workaround that was kept around for ABI-compatibility on x86-64
between different LLVM versions.
This means LLVM r67588 is required if you want to compile for x86-64, otherwise
the backend will assert when you try to return e.g. struct { int i; char c; }
from a function. (In particular, this is no longer compatible with LLVM 2.5)
It also means that any code returning small structs on x86-64 will probably
need to be recompiled in order to be linkable to code compiled with this change.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Tue, 12 May 2009 15:50:48 +0200 |
parents | 3d6a908a34e9 |
children | f3b92d26ad0f |
comparison
equal
deleted
inserted
replaced
1345:712662f45ee4 | 1346:6f4154b318ef |
---|---|
41 #include "gen/logger.h" | 41 #include "gen/logger.h" |
42 #include "gen/dvalue.h" | 42 #include "gen/dvalue.h" |
43 #include "gen/llvmhelpers.h" | 43 #include "gen/llvmhelpers.h" |
44 #include "gen/abi.h" | 44 #include "gen/abi.h" |
45 #include "gen/abi-x86-64.h" | 45 #include "gen/abi-x86-64.h" |
46 //#include "gen/llvm-version.h" // only use is commented out. | |
47 #include "ir/irfunction.h" | 46 #include "ir/irfunction.h" |
48 | 47 |
49 #include <cassert> | 48 #include <cassert> |
50 #include <map> | 49 #include <map> |
51 #include <string> | 50 #include <string> |
399 // Returns true if the struct fits in return registers in the x86-64 fastcc | 398 // Returns true if the struct fits in return registers in the x86-64 fastcc |
400 // calling convention. | 399 // calling convention. |
401 bool retStructInRegs(TypeStruct* st) { | 400 bool retStructInRegs(TypeStruct* st) { |
402 // 'fastcc' allows returns in up to two registers of each kind: | 401 // 'fastcc' allows returns in up to two registers of each kind: |
403 DRegCount state(2, 2, 2); | 402 DRegCount state(2, 2, 2); |
404 #if 1 //LLVM_REV < 67588 | |
405 // (If uncommenting the LLVM_REV line above, also uncomment llvm-version #include | |
406 | |
407 // LLVM before trunk r67588 doesn't allow a second int to be an i1 or | |
408 // i8. (See <http://llvm.org/PR3861>) | |
409 // Rather than complicating shouldPassStructInRegs(), just disallow | |
410 // second integers for now. | |
411 // FIXME: Disabling this for older LLVM only makes the abi dependent on | |
412 // LLVM revision, which seems like a bad idea. We could extend | |
413 // i8 parts to i16 to work around this issue until 2.6... | |
414 // TODO: Remove this workaround when support for LLVM 2.5 is dropped. | |
415 state.ints = 1; | |
416 #endif | |
417 return shouldPassStructInRegs(st, state); | 403 return shouldPassStructInRegs(st, state); |
418 } | 404 } |
419 | 405 |
420 // Heuristic for determining whether to pass a struct type directly or | 406 // Heuristic for determining whether to pass a struct type directly or |
421 // bump it to memory. | 407 // bump it to memory. |