summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
* 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
* IRgen: Add CGOptions to CGTypes.Daniel Dunbar2011-06-213-4/+8
| | | | llvm-svn: 133530
* A few tweaks to MaterializeTemporaryExpr suggested by John.Douglas Gregor2011-06-211-3/+1
| | | | llvm-svn: 133528
* Introduce a new AST node describing reference binding to temporaries.Douglas Gregor2011-06-214-2/+27
| | | | | | | | | | | | | | | | | | | | | | | | | MaterializeTemporaryExpr captures a reference binding to a temporary value, making explicit that the temporary value (a prvalue) needs to be materialized into memory so that its address can be used. The intended AST invariant here is that a reference will always bind to a glvalue, and MaterializeTemporaryExpr will be used to convert prvalues into glvalues for that binding to happen. For example, given const int& r = 1.0; The initializer of "r" will be a MaterializeTemporaryExpr whose subexpression is an implicit conversion from the double literal "1.0" to an integer value. IR generation benefits most from this new node, since it was previously guessing (badly) when to materialize temporaries for the purposes of reference binding. There are likely more refactoring and cleanups we could perform there, but the introduction of MaterializeTemporaryExpr fixes PR9565, a case where IR generation would effectively bind a const reference directly to a bitfield in a struct. Addresses <rdar://problem/9552231>. llvm-svn: 133521
* De-Unicode-ify in comments.NAKAMURA Takumi2011-06-211-1/+1
| | | | llvm-svn: 133501
* Add support for -Wa,--noexecstack when building from a non-assembly file. ForNick Lewycky2011-06-211-0/+2
| | | | | | | an assembly file it worked correctly, while for a .c file it would given an error about how --noexecstack is not a supported argument to -Wa. llvm-svn: 133489
* Canonicalize register names properly.Eric Christopher2011-06-211-0/+2
| | | | | | Fixes rdar://9425559 llvm-svn: 133486
* llvm-gcc treats a tentative definition with a previousFariborz Jahanian2011-06-201-1/+2
| | | | | | | | | (or follow up) extern declaration with weak_import as an actual definition. make clang follows this behavior. // rdar://9538608 llvm-gcc treats an extern declaration with weak_import llvm-svn: 133450
* Change how PHINodes store their operands.Jay Foad2011-06-201-3/+3
| | | | | | | | | | | | | | | | | | | Change PHINodes to store simple pointers to their incoming basic blocks, instead of full-blown Uses. Note that this loses an optimization in SplitCriticalEdge(), because we can no longer walk the use list of a BasicBlock to find phi nodes. See the comment I removed starting "However, the foreach loop is slow for blocks with lots of predecessors". Extend replaceAllUsesWith() on a BasicBlock to also update any phi nodes in the block's successors. This mimics what would have happened when PHINodes were proper Users of their incoming blocks. (Note that this only works if OldBB->replaceAllUsesWith(NewBB) is called when OldBB still has a terminator instruction, so it still has some successors.) llvm-svn: 133435
* Remove more unnecessary #include <llvm/ADT/SmallVector.h>Francois Pichet2011-06-201-1/+0
| | | | llvm-svn: 133418
* Update to match mainline ConstantStruct::get API change. Also, use Chris Lattner2011-06-207-59/+60
| | | | | | | | | | | ConvertType on InitListExprs as they are being converted. This is needed for a forthcoming patch, and improves the IR generated anyway (see additional type names in testcases). This patch also converts a bunch of std::vector's in CGObjCMac to use C arrays. There are a ton more that should be converted as well. llvm-svn: 133413
* update for api change.Chris Lattner2011-06-189-116/+66
| | | | llvm-svn: 133365
* Remove dead variables.Benjamin Kramer2011-06-183-6/+0
| | | | llvm-svn: 133346
* 80 cols.Benjamin Kramer2011-06-181-5/+5
| | | | llvm-svn: 133345
* When emitting a compound literal of POD type, continue to emit aDouglas Gregor2011-06-171-0/+10
| | | | | | | | | | | | | | | | | separate aggregate temporary and then memcpy it over to the destination. This fixes a regression I introduced with r133235, where the compound literal on the RHS of an assignment makes use of the structure on the LHS of the assignment. I'm deeply suspicious of AggExprEmitter::VisitBinAssign()'s optimization where it emits the RHS of an aggregate assignment directly into the LHS lvalue without checking whether there is any aliasing between the LHS/RHS. However, I'm not in a position to revisit this now. Big thanks to Eli for finding the regression! llvm-svn: 133261
* Perform an acquire memory barrier on the fast path of a thread-safeJohn McCall2011-06-171-11/+33
| | | | | | static initializer check, as required by the Itanium ABI. llvm-svn: 133250
* Objective-C fast enumeration loop variables are not retained in ARC, butJohn McCall2011-06-173-7/+47
| | | | | | | | | | | | they should still be officially __strong for the purposes of errors, block capture, etc. Make a new bit on variables, isARCPseudoStrong(), and set this for 'self' and these enumeration-loop variables. Change the code that was looking for the old patterns to look for this bit, and change IR generation to find this bit and treat the resulting variable as __unsafe_unretained for the purposes of init/destroy in the two places it can come up. llvm-svn: 133243
* Implement proper support for generating code for compound literals inDouglas Gregor2011-06-171-3/+8
| | | | | | | | | | | | | C++, which means: - binding the temporary as needed in Sema, so that we generate the appropriate call to the destructor, and - emitting the compound literal into the appropriate location for the aggregate, rather than trying to emit it as a temporary and memcpy() it. Fixes PR10138 / <rdar://problem/9615901>. llvm-svn: 133235
* Check the specific target to figure out if a constraint is a validEric Christopher2011-06-171-2/+5
| | | | | | | | | register constraint. Note that we're not checking if the register itself is valid for the constraint. Fixes rdar://9382985 llvm-svn: 133226
* Move computation of __private_extern__ visibilty toFariborz Jahanian2011-06-161-11/+2
| | | | | | getLVForNamespaceScopeDecl(). // rdar://9609649 llvm-svn: 133182
* Set the visibility to 'hidden' when previousFariborz Jahanian2011-06-161-2/+11
| | | | | | | declaration of global var is __private_extern__. // rdar://9609649 llvm-svn: 133157
* Restore correct use of GC barriers.John McCall2011-06-1610-133/+164
| | | | llvm-svn: 133144
* Suppress a warning in -Asserts builds.John McCall2011-06-151-0/+1
| | | | llvm-svn: 133110
* Automatic Reference Counting.John McCall2011-06-1527-238/+2899
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Per Chris's suggestion, simplify code using llvm::getOrEnforceKnownAlignment.Eli Friedman2011-06-151-36/+15
| | | | llvm-svn: 133095
* Use isAnyComplexType here so we don't pass complex numbers into the ↵Eli Friedman2011-06-151-1/+1
| | | | | | aggregate handling code; found by inspection. llvm-svn: 133070
* Fix a regression from r132957 involving complex integers. (Fixes failures ↵Eli Friedman2011-06-151-2/+6
| | | | | | on gcc-testsuite bot.) llvm-svn: 133069
* Do not emit stoppoint before emitting debug info for parameters.Devang Patel2011-06-151-3/+1
| | | | | | | - llvm.dbg.declare already receives line number information from ParmDecl - Additional extra stoppoint messes up gdb's understanding of where function body starts. llvm-svn: 133065
* Update the prefetch intrinsic usage. Now the last argument tells codegenBruno Cardoso Lopes2011-06-141-1/+2
| | | | | | whether it's a data or instruction cache access. llvm-svn: 132977
* Move GlobalDecl to ASTPeter Collingbourne2011-06-145-131/+4
| | | | llvm-svn: 132973
* The LLVM IR representation of byval arguments has a rather strange property: ↵Eli Friedman2011-06-141-5/+44
| | | | | | | | | | if the alignment of an argument to a call is less than the specified byval alignment for that argument, there is no way to specify the alignment of the implied copy. Therefore, we must ensure that the alignment of the argument is at least the byval alignment. To do this, we have to mess with the alignment of relevant alloca's in some cases, and insert a copy that conceptually shouldn't be necessary in some cases. This patch tries relatively hard to avoid creating an extra copy if it can be avoided (see test3 in the included testcase), but it is not possible to avoid in some cases (like test2 in the included testcase). rdar://9483886 llvm-svn: 132957
* Put local variables in appropriate debug info scope.Devang Patel2011-06-131-5/+5
| | | | | | This fixes radar 8757124. llvm-svn: 132949
* Implement support for C++11 in-class initialization of non-static data members.Richard Smith2011-06-113-5/+10
| | | | llvm-svn: 132878
* Implement Objective-C Related Result Type semantics.Douglas Gregor2011-06-111-23/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Related result types apply Cocoa conventions to the type of message sends and property accesses to Objective-C methods that are known to always return objects whose type is the same as the type of the receiving class (or a subclass thereof), such as +alloc and -init. This tightens up static type safety for Objective-C, so that we now diagnose mistakes like this: t.m:4:10: warning: incompatible pointer types initializing 'NSSet *' with an expression of type 'NSArray *' [-Wincompatible-pointer-types] NSSet *array = [[NSArray alloc] init]; ^ ~~~~~~~~~~~~~~~~~~~~~~ /System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:72:1: note: instance method 'init' is assumed to return an instance of its receiver type ('NSArray *') - (id)init; ^ It also means that we get decent type inference when writing code in Objective-C++0x: auto array = [[NSMutableArray alloc] initWithObjects:@"one", @"two",nil]; // ^ now infers NSMutableArray* rather than id llvm-svn: 132868
* PR10120: Make CodeGenModule::getVTableLinkage use NamedDecl::getLinkage to ↵Eli Friedman2011-06-101-1/+1
| | | | | | | | determine whether the vtable should be externally visible, instead of a rough approximation of it which messes up with templates. While I'm here, zap the other user of isInAnonymousNamespace outside of Decl.cpp. llvm-svn: 132861
* Clang support for ARM Uv/Uy/Uq inline-asm constraints.Stuart Hastings2011-06-071-1/+1
| | | | | | rdar://problem/9037836 llvm-svn: 132737
* When inferring the result type of a block based on a return statementDouglas Gregor2011-06-051-0/+1
| | | | | | | | with a type-dependent expression, infer the placeholder type 'Context.DependentTy' to indicate that this is just a placeholder. Fixes PR9982 / <rdar://problem/9486685>. llvm-svn: 132657
* Add support for builtin astype:Tanya Lattner2011-06-041-0/+51
| | | | | | | __builtin_astype(): Used to reinterpreted as another data type of the same size using for both scalar and vector data types. Added test case. llvm-svn: 132612
* Rework r132576.Devang Patel2011-06-042-2/+5
| | | | | | Emit debug info only if there is an insertion point. The debug info should not force an insertion point. Codegen may later on decide to not emit code for some reason, see extensive comment in CodeGenFunction::EmitStmt(), and debug info should not get in the way. llvm-svn: 132610
* Emit debug info only if there is an insertion point. The debug info should ↵Devang Patel2011-06-032-16/+10
| | | | | | not force an insertion point. Codegen may later on decide to not emit code for some reason, see extensive comment in CodeGenFunction::EmitStmt(), and debug info should not get in the way. llvm-svn: 132576
* Simplify.Devang Patel2011-06-031-4/+6
| | | | llvm-svn: 132560
* Fix typedef's context.Devang Patel2011-06-031-2/+3
| | | | llvm-svn: 132557
* 80-column cleanup.Eric Christopher2011-06-031-2/+2
| | | | llvm-svn: 132548
* Add stuff for o32 ABI conformance.Akira Hatanaka2011-06-021-1/+60
| | | | llvm-svn: 132443
* Robustify objc method type description (subroutine type) by walking ↵Devang Patel2011-05-311-11/+6
| | | | | | parameters directly. llvm-svn: 132368
* List objective-c ineterfaces as public types in dwarf debug info output.Devang Patel2011-05-311-0/+22
| | | | llvm-svn: 132361
* List c++ class type as public type in dwarf debug info output.Devang Patel2011-05-312-2/+13
| | | | llvm-svn: 132357
* Fix another incorrect type bug.David Chisnall2011-05-301-1/+1
| | | | llvm-svn: 132311
* Convert Clang over to resuming from landing pads with llvm.eh.resume.John McCall2011-05-283-76/+132
| | | | | | It's quite likely that this will explode, but I need to know how. :) llvm-svn: 132269
* Eliminate temporary argument vectors.Benjamin Kramer2011-05-286-49/+21
| | | | llvm-svn: 132260
OpenPOWER on IntegriCloud