Commit Graph

192 Commits

Author SHA1 Message Date
Daniel Dunbar 617e89231d x86_64 ABI: Two bug fixes.
1. Return of _Complex long double used wrong type.

2. va_arg of types passed in two SSE registers didn't account for
extra space in register save area.

Down to 18 failures on gcc/compat/x86_64. Combined 32/64 results are:
--
		=== gcc Summary ===

# of expected passes		1292
# of unexpected failures	34
# of unsupported tests		2
--

llvm-svn: 64880
2009-02-18 03:44:19 +00:00
Daniel Dunbar 0ee13255ee x86_64 ABI: Fix assert on return of _Complex long double.
llvm-svn: 64756
2009-02-17 07:55:55 +00:00
Daniel Dunbar 7f0e2368bb x86_64 ABI: Implement classification for bit-fields.
llvm-svn: 64727
2009-02-17 02:45:44 +00:00
Daniel Dunbar f2c6198eef x86_64 ABI: Handle va_arg arguments with alignment > 8.
llvm-svn: 64701
2009-02-16 23:38:56 +00:00
Daniel Dunbar 3d88672f64 x86_64 ABI: Need to use canonical types when comparing against
ASTContext types.

llvm-svn: 64533
2009-02-14 02:45:45 +00:00
Daniel Dunbar 019ef0bbfe x86_64 ABI: Pass simple types directly when possible. This is
important for both keeping the generated LLVM simple and for ensuring
that integer types are passed/promoted correctly.

llvm-svn: 64529
2009-02-14 02:09:24 +00:00
Daniel Dunbar abe6ef932f x86_64 ABI: Support va_arg passed in mixed registers.
- Now at 1274 passes on gcc compat suite vs 1262.

llvm-svn: 64469
2009-02-13 17:46:31 +00:00
Daniel Dunbar 753cc07d13 x86_64: Initial varargs support.
- Doesn't yet handle case where values are passed in mixed (general
   purpose & floating point) registers; otherwise largely
   functional. Code still needs some cleaning.

Fixes:
MultiSource/Applications/lua/lua
MultiSource/Applications/siod/siod
MultiSource/Applications/sqlite3/sqlite3
SingleSource/Regression/C/PR640
SingleSource/UnitTests/2003-07-09-SignedArgs
SingleSource/UnitTests/2007-03-02-VaCopy

gcc compat test suite results (Darwin x86-32 & -64):
--
# of expected passes		1262
# of unexpected failures	56
# of unresolved testcases	34
# of unsupported tests		2

Compare to: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090209/012050.html

llvm-svn: 64370
2009-02-12 09:04:14 +00:00
Daniel Dunbar 2d0746fb97 Pull CodeGenFunction::EmitVAArg into target specific ABIInfo classes.
llvm-svn: 64235
2009-02-10 20:44:09 +00:00
Daniel Dunbar 9403cd6d85 Tweak x86-64 ABI to allow reuse for vararg handling.
llvm-svn: 64221
2009-02-10 17:06:09 +00:00
Daniel Dunbar 9bfb4de38b ABI: Correctly handle load/store of values which have a different LLVM
memory representation (e.g., bool).
 - This upgrades (downgrades) MultiSource/Applications/ClamAV/clamscan
   to a miscompile and fixes
   SingleSource/UnitTests/2003-05-31-CastToBool.

llvm-svn: 64194
2009-02-10 01:51:39 +00:00
Daniel Dunbar d5f1f55e28 Make sure to initialize local variables, even if they were ignored by
ABI.

llvm-svn: 64187
2009-02-10 00:06:49 +00:00
Daniel Dunbar ee9e4c274b Set load/store alignment when doing ABI coercions.
- Currently, this is producing poor code, but we prefer correctness
   to performance for now. Eventually we should be able to generally
   avoid having to set the alignment when we control the alignment of
   the alloca.

 - This knocks out 33/1000 failures on my single argument ABI tests,
   down to 22/1000 and 18 of these appear to be gcc bugs. Woot.

llvm-svn: 64001
2009-02-07 02:46:03 +00:00
Daniel Dunbar 5d3dbd64e1 Implement Direct ABIInfo semantics.
- No intended functionality change, this is essentially enabling
   direct passing of complex and aggregate values, which no ABI is
   using.

llvm-svn: 63863
2009-02-05 11:13:54 +00:00
Daniel Dunbar cea3af4e54 Simplify test for whether we need an alloca to hold an indirect return
value.
 - No functionality change.

llvm-svn: 63859
2009-02-05 09:24:53 +00:00
Daniel Dunbar 747865af0c Implement ABI Indirect sematics for arguments.
- No intended functionality change, all current ABI implementations
   were only using indirect for complex/aggregate types, which were
   being passed indirectly with the Direct ABIInfo kind.

llvm-svn: 63858
2009-02-05 09:16:39 +00:00
Daniel Dunbar b8b1c679c4 Merge ABIInfo StructRet/ByVal into Indirect.
- No (intended) functionality change, the semantic changes are to come.

llvm-svn: 63850
2009-02-05 08:00:50 +00:00
Daniel Dunbar c79407fc40 Pull CodeGenFunction::GetUndefRValue() out of EmitUnsupportedRValue.
llvm-svn: 63845
2009-02-05 07:09:07 +00:00
Daniel Dunbar 70245be397 x86-32: Use Ignore to avoid passing empty structs (instead of Expand).
llvm-svn: 63813
2009-02-05 01:50:07 +00:00
Daniel Dunbar 0103574d55 Honor ByVal alignment. Patch by Nate Begeman!
llvm-svn: 63811
2009-02-05 01:31:19 +00:00
Daniel Dunbar fff09f335d Unbreak CGFunctionInfo::Profile method and reenable caching of ABI
information.

llvm-svn: 63799
2009-02-05 00:00:23 +00:00
Daniel Dunbar 56e7552c73 Add ABIArgInfo::dump()
llvm-svn: 63794
2009-02-04 23:24:38 +00:00
Daniel Dunbar fb5fdf1f14 Temporarily disable caching of ABI results; this is going horribly
wrong in some cases.

llvm-svn: 63780
2009-02-04 21:36:22 +00:00
Daniel Dunbar a45bdbbb6a Add asserts that the function signature matches the other arguments provide
to CGCall functions.

llvm-svn: 63775
2009-02-04 21:17:21 +00:00
Daniel Dunbar 6e3b7df125 Handle demotion of coerced arguments (as in void a(x) short x; { ... }).
llvm-svn: 63726
2009-02-04 07:22:24 +00:00
Daniel Dunbar a33461150d Use ConvertTypeForMem when creating alloca for scalar argument.
llvm-svn: 63681
2009-02-03 23:04:57 +00:00
Daniel Dunbar fc7c76159c x86_64 ABI: Initial implementation of ABI compliant parameter passing.
- Now only 27/500 failures on ABITest single argument tests; from
   350/500. :)
 - As with return types, a large percentage of these are likely to be
   gcc bugs, not yet reviewed.

Also, fix bug in handling of Ignore ABI type in argument lists.

llvm-svn: 63654
2009-02-03 20:00:13 +00:00
Daniel Dunbar 2f219b0770 ABI handling: Implement coercion for argument types (in addition to
return types).

llvm-svn: 63645
2009-02-03 19:12:28 +00:00
Daniel Dunbar 32931eb21d Change ABIInfo to compute information for a full signature at a time
(the main point of this restructing).

llvm-svn: 63619
2009-02-03 06:51:18 +00:00
Daniel Dunbar 0136282a9c Remove ABIArgInfo::Default kind, ABI is now responsible for specifying
acceptable kind with more precise semantics.

llvm-svn: 63617
2009-02-03 06:30:17 +00:00
Daniel Dunbar 67dace890f Add ABIArgInfo::Direct kind, which passes arguments using whatever the
native IRgen type is. This is like Default, but without any extra
semantics (like automatic tweaking of structures or void).

llvm-svn: 63615
2009-02-03 06:17:37 +00:00
Daniel Dunbar 5a0acdc982 Add two FIXMEs.
llvm-svn: 63613
2009-02-03 06:02:10 +00:00
Daniel Dunbar b52d077d8b Always use CGFunctionInfo to access ABI information.
llvm-svn: 63612
2009-02-03 05:59:18 +00:00
Daniel Dunbar 313321ea23 Move ABIArgInfo into CGFunctionInfo, computed on creation.
- Still have to convert some consumers over.

llvm-svn: 63610
2009-02-03 05:31:23 +00:00
Daniel Dunbar 6d6b0d309a Move ABIInfo/ABIArgInfo classes into ABIInfo.h
llvm-svn: 63586
2009-02-03 01:05:53 +00:00
Daniel Dunbar e0be82956b Memoize CGFunctionInfo construction.
llvm-svn: 63576
2009-02-03 00:07:12 +00:00
Daniel Dunbar 3668cb2d3c Change CGFunctionInfo args iterator to not include the return type.
llvm-svn: 63571
2009-02-02 23:43:58 +00:00
Daniel Dunbar bf8c24ad89 Thread CGFunctionInfo construction through CodeGenTypes.
- Inefficient & leaks memory currently, will be cleaned up subsequently.

llvm-svn: 63567
2009-02-02 23:23:47 +00:00
Daniel Dunbar d931a87f90 More ABI API cleanup.
- Lift CGFunctionInfo creation above ReturnTypeUsesSret and
   EmitFunction{Epi,Pro}log.

llvm-svn: 63553
2009-02-02 22:03:45 +00:00
Daniel Dunbar 7633cbf005 ABI handling API changes.
- Lift CGFunctionInfo creation up to callers of EmitCall.

 - Move isVariadic bit out of CGFunctionInfo, take as argument to
   GetFunctionType instead.

No functionality change.

llvm-svn: 63550
2009-02-02 21:43:58 +00:00
Daniel Dunbar f5589ac5a9 Shuffle some functions around, no functionality change.
llvm-svn: 63538
2009-02-02 19:06:38 +00:00
Daniel Dunbar 50f520171c Add FIXME.
llvm-svn: 63531
2009-02-02 18:06:39 +00:00
Daniel Dunbar 5df2b0baaa Remove unused overload of GetFunctionType.
llvm-svn: 63472
2009-01-31 03:05:44 +00:00
Daniel Dunbar a8b7f6bb13 Initialize CGFunctionInfo isVariadic bit correctly.
llvm-svn: 63471
2009-01-31 02:54:56 +00:00
Daniel Dunbar a37249c663 Err, unbreak my previous "no functionality change commit", will fix properly later.
llvm-svn: 63467
2009-01-31 02:20:43 +00:00
Daniel Dunbar 3cd20632ff Kill off CGCallInfo, always use CGFunctionInfo for encapsulating
function/call info.

llvm-svn: 63466
2009-01-31 02:19:00 +00:00
Daniel Dunbar 34aa3ca8c4 x86_64 ABI: Retool classification to compute lo & hi classifications
in terms of where the type resides in the containing object. This is a
more clear embodiement of the spec & fixes a merging issue with
unions. Down to 3/1000 failures.

llvm-svn: 63455
2009-01-31 00:06:58 +00:00
Daniel Dunbar 6a046c64d9 x86_64 ABI: Fix more thinkos, straddling computation for complex was
computing in bytes not bits. We are now down to 22/1000 failures on
the return types tests, and 18 of those are gcc bugs I believe.

llvm-svn: 63438
2009-01-30 22:40:15 +00:00
Daniel Dunbar c35dca92f5 x86_64 ABI: Fix thinko in prev commit, 64-bit vectors should have SSE
class, not integer.

llvm-svn: 63426
2009-01-30 21:50:20 +00:00
Daniel Dunbar 4d22eaeb44 x86_64 ABI: Pass <1 x double> in memory. This is arguably wrong, but
matches gcc 4.2 (not llvm-gcc).

llvm-svn: 63413
2009-01-30 19:38:39 +00:00
Daniel Dunbar 7da8d0b321 Remove testing -use-x86_64-abi option; current implementation is
robust enough for general use.

llvm-svn: 63406
2009-01-30 18:47:53 +00:00
Daniel Dunbar 890c6b5520 x86_64 ABI: Split small vectors which cross an eightbyte boundary. Down to 33/500 return type failures.
llvm-svn: 63404
2009-01-30 18:40:10 +00:00
Daniel Dunbar f5222fa0ad x86_64 ABI: Implement classification for arrays.
- This brings us down to an 8% failure rate on the first 500 return
   types tests (from 12%).

llvm-svn: 63383
2009-01-30 08:09:32 +00:00
Daniel Dunbar 62dc51c395 Use uint64_t not unsigned for type sizes/offsets.
llvm-svn: 63352
2009-01-30 00:47:38 +00:00
Daniel Dunbar 5537b8bc6c x86_64 ABI: Handle fields / complex components which straddle
eightbyte boundaries.
 - Getting harder to test now that we handle cases gcc & llvm-gcc get
   wrong ( { _Complex char; _Complex int; } is a good example). :)

llvm-svn: 63305
2009-01-29 09:42:07 +00:00
Daniel Dunbar 7cd7d47c5c x86_64 ABI: Tweak merging algorithm so that we always bail early when
we see a Memory classification.

llvm-svn: 63295
2009-01-29 08:35:40 +00:00
Daniel Dunbar 012468aa7f ABI: When emitting calls which return an ignored argument, make sure
to still return an RValue of the correct type.

llvm-svn: 63294
2009-01-29 08:24:57 +00:00
Daniel Dunbar 17aa941534 x86_64 ABI: Implement classification for records.
- This is my best initial guess at what the "spec" means, although it is not
   particularly clear on a number of points. Will refine through testing.

llvm-svn: 63292
2009-01-29 08:13:58 +00:00
Daniel Dunbar 227e1a77ff x86_64: Support cases which map to returning multiple values in LLVM
(e.g., _Complex double -> { double, double } return).

llvm-svn: 63285
2009-01-29 07:36:07 +00:00
Daniel Dunbar 8e6652affc x86_64 ABI: Classify _Complex ints as integer.
llvm-svn: 63283
2009-01-29 07:22:20 +00:00
Daniel Dunbar d678d3d970 x86_64: Classify __m64 and __m128 "correctly".
- gcc appears to be classifying <1 x double> as INTEGER which is
   odd. Will investigate later.

llvm-svn: 63086
2009-01-27 02:01:34 +00:00
Daniel Dunbar 0f4aa3cbb1 Implement support for coercion to wider types during ABI handling.
- Code quality is poor, but simple.

llvm-svn: 63083
2009-01-27 01:36:03 +00:00
Daniel Dunbar 94a6f25738 Add Ignore ABIArgInfo kind, for handling void & empty structures.
llvm-svn: 63039
2009-01-26 21:26:08 +00:00
Daniel Dunbar 3334a44501 Start filling in x86_64 ABI implementation.
- No functionality change, moved behind -use-x86_64-abi option until
   it becomes non-experimental.

llvm-svn: 62915
2009-01-24 08:32:22 +00:00
Daniel Dunbar 707f6436e0 Add dummy X86_64 ABIInfo implementation.
llvm-svn: 62268
2009-01-15 18:18:40 +00:00
Douglas Gregor ffca3a21f1 Provide a new kind of iterator, the specific_decl_iterator, that
filters the decls seen by decl_iterator with two criteria: the dynamic
type of the declaration and a run-time predicate described by a member
function. This simplifies EnumDecl, RecordDecl, and ObjCContainerDecl
considerably. It has no measurable performance impact.

llvm-svn: 61994
2009-01-09 17:18:27 +00:00
Daniel Dunbar 9ae0afdcd6 Allow ABI to use StructRet even for scalar values.
- Update comment to reflect fact that StructRet is now supported for
   any type (modulo LLVM support).

 - No functionality change, no scalar types currently use this
   feature.

llvm-svn: 61192
2008-12-18 04:52:14 +00:00
Anders Carlsson 32ef8ceaa1 Handle returning complex types that get coerced. Fixes PR3131
llvm-svn: 60058
2008-11-25 22:21:48 +00:00
Chris Lattner 1cbaacc4a0 Migrate some stuff from NamedDecl::getName() to
NamedDecl::getNameAsString() to make it more explicit.

llvm-svn: 59937
2008-11-24 04:00:27 +00:00
Anders Carlsson 312045115e Fix silly bug spotted by Daniel Dunbar
llvm-svn: 59358
2008-11-15 06:35:36 +00:00
Anders Carlsson d0e4f2b106 Handle complex return values.
llvm-svn: 59345
2008-11-15 01:29:05 +00:00
Daniel Dunbar d9eff3d4e4 Lift out ABIInfo abstract base class.
- Currently still lives in CGCall.cpp but is intended to be the
   target specific place for hooking ABI information.
 - Select ABIInfo to use based on Target's prefix and pointer width.

llvm-svn: 57445
2008-10-13 17:02:26 +00:00
Anders Carlsson b83162840f Implement support for the const and pure attributes.
llvm-svn: 57142
2008-10-05 23:32:53 +00:00
Devang Patel 597e70876e Now Attributes are divided in three groups
- return attributes - inreg, zext and sext
- parameter attributes
- function attributes - nounwind, readonly, readnone, noreturn

Return attributes use 0 as the index.
Function attributes use ~0U as the index.

llvm-svn: 56705
2008-09-26 22:53:57 +00:00
Devang Patel 322300d1c2 Large mechanical patch.
s/ParamAttr/Attribute/g
s/PAList/AttrList/g
s/FnAttributeWithIndex/AttributeWithIndex/g
s/FnAttr/Attribute/g

This sets the stage 
- to implement function notes as function attributes and 
- to distinguish between function attributes and return value attributes.

llvm-svn: 56623
2008-09-25 21:02:23 +00:00
Devang Patel e2aef07b2d Adjust whitespaces.
llvm-svn: 56538
2008-09-24 01:03:00 +00:00
Devang Patel 3e1f51b53f s/ParamAttrsWithIndex/FnAttributeWithIndex/g
Rename to match changes done on llvm side.

llvm-svn: 56537
2008-09-24 01:01:36 +00:00
Daniel Dunbar 86d97c7985 Improve x86 ABI compatibility.
- Enables use of ABIArgInfo::Expand when needed. This greatly
   improves our x86 ABI compatibility.

 - As the infrastructure for target specific ABI handling isn't built
   yet, this change means ABI compatibility on other platforms is once
   again broken in a different way than before.

 - Upcoming: Figure out how to refactor ABI handling into
   targets. More documentation.

llvm-svn: 56293
2008-09-17 21:22:33 +00:00
Daniel Dunbar d34d6dc458 Drop CodeGenTypes parameter to classifyArgumentType.
Ensure that ABIArgInfo::Default implementation for aggregrate types
is sensible (StructRet on return and ByVal on arguments).

No functionality change.

llvm-svn: 56289
2008-09-17 20:11:04 +00:00
Daniel Dunbar 8fc81b02e2 Add support for ABIArgInfo::Expand
- No functionality change.

llvm-svn: 56269
2008-09-17 00:51:38 +00:00
Daniel Dunbar d3674e6f40 Use ABIArgInfo for decisions about function arguments (not just return
value).
 - Added ABIArgInfo::ByVal (mostly supported) and ABIArgInfo::Expand
   (asserted out).

 - Added classifyArgumentType which currently just uses
   ABIArgInfo::Default or ByVal. This nearly matches old behavior, but
   we now set ByVal in a few situations we may have left it off before
   (on complex, for example).

llvm-svn: 56086
2008-09-11 01:48:57 +00:00
Daniel Dunbar 83876b4594 Bug fix, apply default argument promotion in message sends for which
no method declaration was found.
 - This was allowing arrays to pass "by value" among other things.

Add assert in CodeGen that arguments cannot have array type.

llvm-svn: 56080
2008-09-11 00:04:36 +00:00
Daniel Dunbar 573884eaf7 Implement ABIArgType::Coerce support.
- As a test, enable basic usage for some common x86-32 cases. This
    increases our x86-32 compliance (on other targets our compliance
    will just be broken in a different way).

llvm-svn: 56051
2008-09-10 07:04:09 +00:00
Daniel Dunbar b8b4759462 Add CodeGenTypes::GetFunctionType overload for getting the effective
type of a call.

Change NeXT runtime to use this instead of trying to bitcasting
internally (which doesn't respect the ABI).

Fix subtle bug, use of ConvertTypeRecursive instead of ConvertType is
bad inside GetFunctionType.

llvm-svn: 56050
2008-09-10 07:00:50 +00:00
Daniel Dunbar 7a95ca3197 Move FunctionType conversion into CGCall.cpp:
- Added CodeGenTypes::GetFunctionType, taking a CGFunctionInfo.
 - Updated Obj-C runtimes to use this instead of rolling the
   llvm::FunctionType by hand.
 - Killed CodeGenTypes::{ConvertReturnType, DecodeArgumentTypes}.

Add ABIArgInfo class to encapsulate ABI decision of how to lower types
to LLVM.
 - Will move to target sometime soon.

llvm-svn: 56047
2008-09-10 04:01:49 +00:00
Daniel Dunbar a72d4aece6 Add ABIArgInfo class to encapsulate ABI decision of how to lower types
to LLVM.
 - Will move to target sometime soon.

llvm-svn: 56046
2008-09-10 02:41:04 +00:00
Daniel Dunbar c68897d2c3 Tweak CGCall functions again:
- Realized these functions will eventually need access to more data,
   moved to CodeGenModule. Eventually they should probably live
   together in some other helper class.

llvm-svn: 56039
2008-09-10 00:41:16 +00:00
Daniel Dunbar 76c8eb75b1 Tweak CGCall functions:
- Move actual param attr list creation to
   CodeGenFunction::ConstructParamAttrList.
 - Make ReturnTypeUsesSret static.

llvm-svn: 56038
2008-09-10 00:32:18 +00:00
Daniel Dunbar 81cf67fa0b Add CodeGenFunction::ReturnTypeUsesSret
- Hook so NeXT runtime doesn't depend on ABI.

llvm-svn: 56034
2008-09-09 23:48:28 +00:00
Daniel Dunbar 613855c8af Move ABI specific code for functions / calls to CGCall.cpp:
- Factor out EmitFunction{Pro,Epi}log

llvm-svn: 56031
2008-09-09 23:27:19 +00:00
Daniel Dunbar 41cf9dedc6 Change CodeGen to emit calls using (RValue,Type) list:
- Add CodeGenFunction::EmitAnyExprToTemp
   o Like EmitAnyExpr, but emits aggregates to a temporary location if
     none is available. Seems like this should be simpler (even aside
     from using first class aggregates).

 - Killed CodeGenFunction::EmitCallArg (just append the pair)

 - Conversion of RValues to actual call arguments is now isolated in
   CodeGenFunction::EmitCall.

llvm-svn: 55970
2008-09-09 01:06:48 +00:00
Daniel Dunbar 3d7c90b8ec Refactor parameter attribute handling:
- Add CGCall.h for dealing with ABI issues related to calls.
  - Add CGFunctionInfo and CGCallInfo for capturing ABI relevant
    information about functions and calls.
  - Isolate LLVM parameter attribute handling inside CGCall.cpp

llvm-svn: 55963
2008-09-08 21:33:45 +00:00