summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* First pass at abstracting out a class for the target C++ ABI.John McCall2013-01-251-1/+1
| | | | llvm-svn: 173514
* Fix signed/unsigned CompareDavid Greene2013-01-151-1/+2
| | | | | | Do some casting to avoid a signed/unsigned compare. llvm-svn: 172571
* Rewrite #includes for llvm/Foo.h to llvm/IR/Foo.h as appropriate toChandler Carruth2013-01-021-3/+3
| | | | | | | | reflect the migration in r171366. Re-sort the #include lines to reflect the new paths. llvm-svn: 171369
* Fix a compilation warning with gcc 4.6Eli Bendersky2012-12-181-1/+1
| | | | llvm-svn: 170440
* Cleanup and fix an assert that was mis-firing.Chandler Carruth2012-12-091-5/+13
| | | | | | | | | | | | | | | | Note that there is no test suite update. This was found by a couple of tests failing when the test suite was run on a powerpc64 host (thanks Roman!). The tests don't specify a triple, which might seem surprising for a codegen test. But in fact, these tests don't even inspect their output. Not at all. I could add a bunch of triples to these tests so that we'd get the test coverage for normal builds, but really someone needs to go through and add actual *tests* to these tests. =[ The ones in question are: test/CodeGen/bitfield-init.c test/CodeGen/union.c llvm-svn: 169694
* Fix the bitfield record layout in codegen for big endian targets.Chandler Carruth2012-12-091-3/+7
| | | | | | | | | | | | | | | | | | This was an egregious bug due to the several iterations of refactorings that took place. Size no longer meant what it original did by the time I finished, but this line of code never got updated. Unfortunately we had essentially zero tests for this in the regression test suite. =[ I've added a PPC64 run over the bitfield test case I've been primarily using. I'm still looking at adding more tests and making sure this is the *correct* bitfield access code on PPC64 linux, but it looks pretty close to me, and it is *worlds* better than before this patch as it no longer asserts! =] More commits to follow with at least additional tests and maybe more fixes. Sorry for the long breakage due to this.... llvm-svn: 169691
* Rework the bitfield access IR generation to address PR13619 andChandler Carruth2012-12-061-227/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | generally support the C++11 memory model requirements for bitfield accesses by relying more heavily on LLVM's memory model. The primary change this introduces is to move from a manually aligned and strided access pattern across the bits of the bitfield to a much simpler lump access of all bits in the bitfield followed by math to extract the bits relevant for the particular field. This simplifies the code significantly, but relies on LLVM to intelligently lowering these integers. I have tested LLVM's lowering both synthetically and in benchmarks. The lowering appears to be functional, and there are no really significant performance regressions. Different code patterns accessing bitfields will vary in how this impacts them. The only real regressions I'm seeing are a few patterns where the LLVM code generation for loads that feed directly into a mask operation don't take advantage of the x86 ability to do a smaller load and a cheap zero-extension. This doesn't regress any benchmark in the nightly test suite on my box past the noise threshold, but my box is quite noisy. I'll be watching the LNT numbers, and will look into further improvements to the LLVM lowering as needed. llvm-svn: 169489
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-4/+4
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Make -mms-bitfields behave consistently.Eli Friedman2012-10-121-2/+2
| | | | | | Patch by Jeremiah Zanin. llvm-svn: 165849
* Move TargetData to DataLayout.Micah Villmow2012-10-081-11/+11
| | | | llvm-svn: 165395
* Propagate lvalue alignment into bitfields. Per report on cfe-dev.Eli Friedman2012-06-271-0/+2
| | | | llvm-svn: 159295
* Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie2012-06-061-5/+5
| | | | | | | | | | | | | | value_type In addition, I've made the pointer and reference typedef 'void' rather than T* just so they can't get misused. I would've omitted them entirely but std::distance likes them to be there even if it doesn't use them. This rolls back r155808 and r155869. Review by Doug Gregor incorporating feedback from Chandler Carruth. llvm-svn: 158104
* Add support for laying out vtordisps according to our currentJohn McCall2012-05-011-3/+1
| | | | | | | working knowledge of the Microsoft ABI. Based on a patch by Dmitry Sokolov. llvm-svn: 155905
* Remove the ref/value inconsistency in filter_decl_iterator.David Blaikie2012-04-301-5/+5
| | | | | | | | | | | | | filter_decl_iterator had a weird mismatch where both op* and op-> returned T* making it difficult to generalize this filtering behavior into a reusable library of any kind. This change errs on the side of value, making op-> return T* and op* return T&. (reviewed by Richard Smith) llvm-svn: 155808
* Add a missing check in CodeGen of packed classes with vtables. ↵Eli Friedman2012-04-271-1/+7
| | | | | | <rdar://problem/11324125>. llvm-svn: 155689
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-2/+2
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Silence a GCC warning about a set-but-not-used variable in release builds.Chandler Carruth2012-03-041-0/+1
| | | | llvm-svn: 152005
* A base subobject type doesn't make sense for unions; don't try to compute ↵Eli Friedman2012-01-131-1/+1
| | | | | | it. Based on patch by Yin Ma. Fixes PR11751. llvm-svn: 148093
* Make CGRecordLayoutBuilder correctly switch over to a packed class when a ↵Eli Friedman2011-12-121-36/+50
| | | | | | class has a base whose alignment will break the class layout. <rdar://problem/10551376>. llvm-svn: 146443
* Make sure we correctly zero-initialize unions containing a pointer to data ↵Eli Friedman2011-12-071-0/+6
| | | | | | member as the first field. PR11487. llvm-svn: 146009
* Fix the layout of vb-tables and vf-tables in the MS C++ ABI.John McCall2011-11-081-33/+77
| | | | | | Based on work by Dmitry Sokolov! llvm-svn: 144072
* Rewrite parts of MS ABI C++ layout. Based on work by r4start; I ended up ↵Eli Friedman2011-10-181-6/+8
| | | | | | doing this while I was trying to review his patch. llvm-svn: 142325
* Constant expression evaluation refactoring:Richard Smith2011-10-101-4/+2
| | | | | | | | | | | - Remodel Expr::EvaluateAsInt to behave like the other EvaluateAs* functions, and add Expr::EvaluateKnownConstInt to capture the current fold-or-assert behaviour. - Factor out evaluation of bitfield bit widths. - Fix a few places which would evaluate an expression twice: once to determine whether it is a constant expression, then again to get the value. llvm-svn: 141561
* Extend the ASTContext constructor to delay the initialization ofDouglas Gregor2011-09-021-2/+2
| | | | | | | | builtin types (When requested). This is another step toward making ASTUnit build the ASTContext as needed when loading an AST file, rather than doing so after the fact. No actual functionality change (yet). llvm-svn: 138985
* switch clang to use the new-new way of creating llvm::StructType's.Chris Lattner2011-08-121-2/+2
| | | | llvm-svn: 137472
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-3/+3
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* de-constify llvm::Type, patch by David Blaikie!Chris Lattner2011-07-181-6/+6
| | | | llvm-svn: 135370
* clang side to match the LLVM IR type system rewrite patch.Chris Lattner2011-07-091-29/+27
| | | | llvm-svn: 134831
* IRgen: Add a -fuse-register-sized-bitfield-access option, for testing.Daniel Dunbar2011-06-211-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Changes bit-field access policy to try to use (aligned) register sized accesses. The idea here is that by using larger accesses we expose more coalescing potential to the backend when we have situations like adjacent bit-fields in the same structure (which is common), and that the backend should be smart enough to narrow the accesses down when no coalescing is done or when it is shown not to be profitable. -- $ clang -m32 -O3 -S -o - t.c _f0: ## @f0 pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax movb (%eax), %cl andb $-128, %cl orb $1, %cl movb %cl, (%eax) movb 1(%eax), %cl andb $-128, %cl orb $1, %cl movb %cl, 1(%eax) movb 2(%eax), %cl andb $-128, %cl orb $1, %cl movb %cl, 2(%eax) movb 3(%eax), %cl andb $-128, %cl orb $1, %cl movb %cl, 3(%eax) popl %ebp ret $ clang -m32 -O3 -S -o - t.c -Xclang -fuse-register-sized-bitfield-access _f0: ## @f0 pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax movl $-2139062144, %ecx ## imm = 0xFFFFFFFF80808080 andl (%eax), %ecx orl $16843009, %ecx ## imm = 0x1010101 movl %ecx, (%eax) popl %ebp ret -- llvm-svn: 133532
* Introduce Type::isSignedIntegerOrEnumerationType() andDouglas Gregor2011-05-201-1/+1
| | | | | | | | | | | | | Type::isUnsignedIntegerOrEnumerationType(), which are like Type::isSignedIntegerType() and Type::isUnsignedIntegerType() but also consider the underlying type of a C++0x scoped enumeration type. Audited all callers to the existing functions, switching those that need to also handle scoped enumeration types (e.g., those that deal with constant values) over to the new functions. Fixes PR9923 / <rdar://problem/9447851>. llvm-svn: 131735
* Finish off rules for z-length bitfields in ms_structFariborz Jahanian2011-05-031-4/+2
| | | | | | structs. // rdar://8823265 llvm-svn: 130783
* More rule enforcement of zero bitfields for ms_struct.Fariborz Jahanian2011-05-021-2/+4
| | | | llvm-svn: 130696
* Some refactoring of my ms_struct patch.Fariborz Jahanian2011-04-271-7/+2
| | | | | | // rdar://8823265 related. llvm-svn: 130311
* With ms_struct attribut, Zero-length bitfields following Fariborz Jahanian2011-04-261-4/+42
| | | | | | non-bitfield members are ignore. // rdar://8823265 wip llvm-svn: 130257
* Simplify AppendTailPadding() by converting its parameter to CharUnits. NoKen Dyck2011-04-241-11/+7
| | | | | | change in functionality intended. llvm-svn: 130108
* Eliminate literal 8s from LayoutUnionField by converting NumBytesToAppend toKen Dyck2011-04-241-4/+5
| | | | | | CharUnits. No change in functionality intended. llvm-svn: 130107
* Eliminate literal 8s from LayoutBitField(), converting variables toKen Dyck2011-04-241-10/+16
| | | | | | | CharUnits or replacing the 8s with char align. No change in functionality intended. llvm-svn: 130106
* Convert AccessInfo::AccessAlignment to CharUnits. No change in functionalityKen Dyck2011-04-241-2/+3
| | | | | | intended. llvm-svn: 130087
* Convert CGBitFieldInfo::FieldByteOffset to CharUnits. No change inKen Dyck2011-04-241-4/+5
| | | | | | functionality intended. llvm-svn: 130085
* When laying out bases in, always try the "base subobject" LLVM type. If itAnders Carlsson2011-04-171-14/+66
| | | | | | | | | | | | | turns out that a field or base needs to be laid out in the tail padding of the base, CGRecordLayoutBuilder::ResizeLastBaseFieldIfNecessary will convert it to an array of i8. I've audited the new test results to make sure that they are still valid. I've also verified that we pass a self-host with this change. This (finally) fixes PR5589! llvm-svn: 129673
* Use a SmallVector for field types in CGRecordLayoutBuilder now that ↵Anders Carlsson2011-04-171-1/+1
| | | | | | llvm::StructType::get takes an ArrayRef. llvm-svn: 129667
* Fix typo in comment.Nick Lewycky2011-03-221-1/+1
| | | | llvm-svn: 128088
* A much-delayed response to Ken Dyck's review: make this somewhat moreJohn McCall2011-02-261-10/+16
| | | | | | char-width agnostic. llvm-svn: 126542
* improve support for big endian targets, fixing PR8171, patchChris Lattner2011-02-171-2/+15
| | | | | | by Heikki Kultala! llvm-svn: 125784
* Refactor CGRecordLayoutBuilder to use CharUnits more consistently.John McCall2011-02-151-144/+162
| | | | llvm-svn: 125605
* Perform zero-initialization of virtual base classes when emitting John McCall2011-02-151-112/+100
| | | | | | | | | | | | a zero constant for a complete class. rdar://problem/8424975 To make this happen, track the field indexes for virtual bases in the complete object. I'm curious whether we might be better off making CGRecordLayoutBuilder *much* more reliant on ASTRecordLayout; we're currently duplicating an awful lot of the ABI layout logic. llvm-svn: 125555
* Convert RecordLayout::Alignment to CharUnits from bit units. No change inKen Dyck2011-02-151-3/+4
| | | | | | functionality intended. llvm-svn: 125549
* Add a helper function, ASTContext::toBits(), that converts sizes inKen Dyck2011-02-111-7/+4
| | | | | | | CharUnits to sizes in bits, and use it to tidy up the places where the conversion was done explicitly. llvm-svn: 125332
* Drop the 'InBits' part from the name of RecordSizeInBits as the value is inKen Dyck2011-02-101-5/+5
| | | | | | character units. llvm-svn: 125281
* Eliminate some signed-to-unsigned comparision warnings introduced inKen Dyck2011-02-101-2/+4
| | | | | | r125156. llvm-svn: 125280
OpenPOWER on IntegriCloud