summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
* Include <string> header to allow compiling for MSVC.Argyrios Kyrtzidis2008-06-011-0/+1
| | | | llvm-svn: 51847
* Don't name the ObjC types if there aren't any ObjC objects in the file. Eli Friedman2008-06-011-4/+6
| | | | | | Patch by David Chisnall. llvm-svn: 51840
* First cut at setting attributes for functions and calls; this puts us Eli Friedman2008-06-014-34/+90
| | | | | | | | | | | | | | | much closer to passing the gcc struct layout tests. It might be possible to refactor this a bit, but I'm not sure there's actually enough common code for that to be useful. To get the calling convention completely correct, a bit of platform-specific code is necessary even for x86-Linux. On x86-Linux, the alignment of function parameters is extremely strange; as far as I can tell, it's always 4 except for SSE vectors or structs containing SSE vectors. I'm continuing to investigate this. llvm-svn: 51839
* Make sure _Bool globals have the correct type.Eli Friedman2008-06-011-3/+8
| | | | llvm-svn: 51838
* Minor cleanup to use the ConvertTypeForMem helper.Eli Friedman2008-06-011-5/+3
| | | | llvm-svn: 51837
* Remove spurious == 0Anton Korobeynikov2008-06-011-1/+1
| | | | llvm-svn: 51836
* Support for code generation of Objective-C top-level language constructs.Anton Korobeynikov2008-06-018-44/+1027
| | | | | | Implemented by David Chisnall! llvm-svn: 51835
* Calculate alignment for local variables.Eli Friedman2008-05-311-2/+6
| | | | llvm-svn: 51826
* PR1893: Fix up the type of tentative definitions of incomplete array Eli Friedman2008-05-301-2/+22
| | | | | | types so that they end up the correct size. llvm-svn: 51787
* Fix and enable generating general union initializers. Essentially, what Eli Friedman2008-05-301-9/+26
| | | | | | | | | | | | this does is reconstruct the type for structs and arrays if the type wouldn't be compatible otherwise. The assertion about packing in the struct type reconstruction code sucks, but I don't see any obvious way to fix it. Maybe we need a general utility method to take a list of types and alignments and try to construct an unpacked type if possible? llvm-svn: 51785
* Allow the type of a global to be different from the type of its Eli Friedman2008-05-301-69/+62
| | | | | | | | | | | | | | | | | associated declaration. This is a prerequisite to handling general union initializations; for example, an array of unions involving pointers has to be turned into a struct because the elements can have incompatible types. I refactored the code a bit to make it more readable; now, the logic for definitions is all in EmitGlobalVarInit. The second parameter for GetAddrOfGlobalVar is now dead; I'll remove it separately. By itself, this patch should not cause any visible changes. llvm-svn: 51783
* Fix constant vector init for initializer lists with an incomplete list Eli Friedman2008-05-301-6/+9
| | | | | | of elements. llvm-svn: 51769
* Always check that the definition of a function has the correct type. Eli Friedman2008-05-301-1/+1
| | | | | | This fixes a crash on the included testcase (found in NetHack). llvm-svn: 51767
* Emit parameter and local variable debug information with -g.Sanjiv Gupta2008-05-303-3/+78
| | | | llvm-svn: 51765
* Add FIXME to CodeGen struct layout.Eli Friedman2008-05-301-1/+5
| | | | llvm-svn: 51764
* Some additions to constant initializer generation code. Adds Eli Friedman2008-05-301-28/+132
| | | | | | | | | | | | | | bit-field initialization; ugly code, X86-only, but it works, at least for basic stuff. Separates/adds union initialization; currently disabled, though, because the struct/array code needs modifications to support elements of the wrong type. Fixes PR2381 and PR2309 with the bit-field initialization. And NetHack compiles and appears to work with a few tweaks (to work around the lack of transparent_union support, and clang being a bit strict about conflicting declarations). llvm-svn: 51763
* - Move ObjC Expresssion AST's from Expr.h => ExprObjC.hSteve Naroff2008-05-291-1/+1
| | | | | | - #include ExprObjC.h in many places llvm-svn: 51703
* More complete/correct implementation of the comparison operators for Eli Friedman2008-05-291-7/+47
| | | | | | constant expressions. llvm-svn: 51682
* Fix an extremely subtle bug with pointer comparisons: they have to be Eli Friedman2008-05-291-4/+4
| | | | | | | unsigned because it's possible (at least in theory) to have have both positive and negative pointers pointing to the same object. llvm-svn: 51681
* Rearrange EmitLValueForField a bit to work properly for _Bool bitfields Eli Friedman2008-05-291-10/+9
| | | | | | | in unions (we don't want to do the union-specific bitcast for bit-fields). llvm-svn: 51678
* Add codegen support for a few more kinds of initializer constant Eli Friedman2008-05-291-0/+35
| | | | | | expressions. llvm-svn: 51677
* Add CodeGen support for alignment on globals, both for unusual natural Eli Friedman2008-05-291-0/+6
| | | | | | alignment and alignment attributes. llvm-svn: 51676
* A couple minor fixes to make debug info usable for arbitrary code: don't Eli Friedman2008-05-292-1/+8
| | | | | | | | emit incomplete types, because they crash llc, and always use the logical location as the current location so we don't crash doing invalid queries on CurLoc. llvm-svn: 51675
* Tentative declarations are supposed to have common linkage, not weak. Eli Friedman2008-05-291-1/+1
| | | | | | This change makes clang generate the same thing as llvm-gcc. llvm-svn: 51674
* Always use packed structs. This isn't really very nice, but there's Eli Friedman2008-05-291-9/+2
| | | | | | | | | | | | | nothing fundamentally wrong with it. Emitting unpacked structs where possible is more work for almost no practical benefit. We'll probably want to fix it at some point anyway, but it's low priority. The issue with long double in particular is that LLVM thinks an X86 long double is 10 bytes, while clang considers it for all purposes to be either 12 or 16 bytes, depending on the platform, even in a packed struct. llvm-svn: 51673
* Check first member alignment and uses packed struct if required.Devang Patel2008-05-271-0/+2
| | | | llvm-svn: 51619
* A few more cases for aggregate values.Eli Friedman2008-05-271-0/+10
| | | | llvm-svn: 51596
* Implementation of __builtin_ctlz.Eli Friedman2008-05-271-0/+14
| | | | llvm-svn: 51595
* The cache is working again; re-enable it.Eli Friedman2008-05-271-3/+0
| | | | llvm-svn: 51587
* Add a more reliable check for whether a static declaration has already Eli Friedman2008-05-271-17/+12
| | | | | | | been used. In preparation for the fix to PR2360, but also a minor bug in its own right. llvm-svn: 51583
* Stop leaking the target data. (Leak found with valgrind.)Eli Friedman2008-05-271-0/+1
| | | | llvm-svn: 51579
* Generalize the float type generation code, and specifically fix the Eli Friedman2008-05-271-5/+19
| | | | | | codegen of X86 long double. llvm-svn: 51578
* Rewrite struct/union layout. This is mostly cleanup; this might also fix Eli Friedman2008-05-271-192/+80
| | | | | | | | | a few bugs, but I don't know of any in particular. This has good effects besides cleanup, though: it also should make it easier to implement the aligned and packed attributes, and also target-specific struct layouts, because the code won't have to be duplicated in codegen. llvm-svn: 51576
* Emit memmove, not memcpy, for structure copies; this is unfortunately Eli Friedman2008-05-263-4/+18
| | | | | | | | | | | | | | | | | required for correctness in cases of copying a struct to itself or to an overlapping struct (itself for cases like *a = *a, and overlapping is possible with unions). Hopefully, this won't end up being a perf issue; LLVM *should* be able to optimize memmove to memcpy in a lot of cases, and for small copies the generated code *should* be mostly comparable. (In reality, LLVM is currently horrible at optimizing memmove, but that's a bug, not a fundamental issue.) gcc currently generates wrong code; that's http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32667. llvm-svn: 51566
* Fix for PR2001. I'm not really fond of it, but it is correct (unless Eli Friedman2008-05-251-1/+10
| | | | | | | | someone tries to make a bitfield volatile?). Not sure how to write a test; any suggestions? llvm-svn: 51558
* Generate subprogram debug info with -g.Sanjiv Gupta2008-05-254-86/+438
| | | | | | Also take care of freeing memory at the right places. llvm-svn: 51553
* Change uses of llvm::Type::isFirstClassType to use the newDan Gohman2008-05-225-11/+11
| | | | | | | | | | | | llvm::Type::isSingleValueType. Currently these two functions have the same behavior, but soon isFirstClassType will return true for struct and array types. Clang may some day want to use of isFirstClassType for some of these some day as an optimization, but it'll require some consideration. llvm-svn: 51446
* Make debugging information usable. This is barebones, but it makes -g Eli Friedman2008-05-224-50/+96
| | | | | | | | | | | | | | actually work (instead of crashing llc), and there's enough info emitted to get line number information in gdb. This should hopefully be helpful for debugging non-working programs. I got rid of the begin/endregion calls because the implementation wasn't working; someone who knows the debugging info a bit better might try to add it. I really have no clue how a compiler is supposed to emit them. This commit shouldn't have any effect without -g. llvm-svn: 51404
* Minor refactoring: compute the return value separately from emitting the Eli Friedman2008-05-221-8/+17
| | | | | | ret. llvm-svn: 51403
* Make CurFuncDecl more specific; I have some code I'm going to land in a Eli Friedman2008-05-221-1/+1
| | | | | | bit that wants to use CurFuncDecl as a FunctionDecl. llvm-svn: 51402
* Move getAccessedFieldNo out of lib/AST/Expr.cpp intoDan Gohman2008-05-225-7/+46
| | | | | | | | | lib/CodeGen/CGExpr.cpp and to change include/clang/AST/Attr.h to use its own enum for visibility types instead of using llvm::GlobalValue::VisibilityTypes. These changes eliminate dependencies in the AST library on LLVM's VMCore library. llvm-svn: 51398
* Remove an unnecessary/buggy if check. Ran into this with some other Eli Friedman2008-05-211-6/+4
| | | | | | changes in my tree, so I don't have a testcase which affects trunk. llvm-svn: 51371
* Disable the function address cache; this doesn't have any ill effects, Eli Friedman2008-05-201-1/+4
| | | | | | | | | | as far as I can tell, and it fixes code like test/CodeGen/functions.c. (Whatever performance effect it might have, crashing on a construct like this isn't really acceptable; I've run into this multiple times.) llvm-svn: 51312
* Add codegen support for stack address intrinsics.Eli Friedman2008-05-201-0/+8
| | | | llvm-svn: 51309
* Implement codegen for comma operator for structs.Eli Friedman2008-05-201-0/+7
| | | | llvm-svn: 51304
* Restructure constant structure init codegen so that it's possible to Eli Friedman2008-05-201-29/+20
| | | | | | | | implement bitfield codegen (although I don't envy the person who implements it). This also prevents a crash on code like that from PR2309 (it's still broken, but it fails more gracefully). llvm-svn: 51285
* Remove code that shouldn't have any effect anymore.Eli Friedman2008-05-201-18/+0
| | | | llvm-svn: 51284
* Implement CodeGen for __builtin_memcpy.Eli Friedman2008-05-191-0/+10
| | | | llvm-svn: 51282
* Fix the emission of expressions like char a[10] = "asdf"; previously, Eli Friedman2008-05-192-2/+16
| | | | | | | | they were causing bad code to be emitted. There are two fixes here: one makes sure we emit a string that is long enough, and one makes sure we properly handle string initialization in init lists. llvm-svn: 51259
* Fix support for _Bool bitfields. The issue is that the bitfield width Eli Friedman2008-05-171-4/+20
| | | | | | | | | | | | used for _Bool is not the same as the primitive width (which for _Bool is 1 bit). The load and store changes add some casts to make the types consistent. The EmitLValue changes make sure that the pointer is of an appropriate type for loading the bitfield. This isn't perfect, but it's an improvement, and getting everything right depends on actually laying out structs in an ABI-compliant way. llvm-svn: 51224
OpenPOWER on IntegriCloud