summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add support for declaring register contraints in variables. They are only usedRafael Espindola2010-12-301-3/+0
| | | | | | | | | | | | | | in asm statements: register int foo asm("rdi"); asm("..." : ... "r" (foo) ... We also only accept these variables if the constraint in the asm statement is "r". This fixes most of PR3933. llvm-svn: 122643
* Correct function name in comment.Nick Lewycky2010-12-301-1/+1
| | | | llvm-svn: 122640
* Simplify mem{cpy, move, set} creation with IRBuilder.Benjamin Kramer2010-12-301-12/+4
| | | | llvm-svn: 122634
* IR Gen. part of API support for __block cxxFariborz Jahanian2010-12-021-2/+5
| | | | | | | | objects imported into blocks. //rdar://8594790. Will have a test case coming (as well as one sent to llvm test suite). llvm-svn: 120713
* Improve codegen for initializer lists to use memset more aggressivelyChris Lattner2010-12-021-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when an initializer is variable (I handled the constant case in a previous patch). This has three pieces: 1. Enhance AggValueSlot to have a 'isZeroed' bit to tell CGExprAgg that the memory being stored into has previously been memset to zero. 2. Teach CGExprAgg to not emit stores of zero to isZeroed memory. 3. Teach CodeGenFunction::EmitAggExpr to scan initializers to determine whether they are profitable to emit a memset + inividual stores vs stores for everything. The heuristic used is that a global has to be more than 16 bytes and has to be 3/4 zero to be candidate for this xform. The two testcases are illustrative of the scenarios this catches. We now codegen test9 into: call void @llvm.memset.p0i8.i64(i8* %0, i8 0, i64 400, i32 4, i1 false) %.array = getelementptr inbounds [100 x i32]* %Arr, i32 0, i32 0 %tmp = load i32* %X.addr, align 4 store i32 %tmp, i32* %.array and test10 into: call void @llvm.memset.p0i8.i64(i8* %0, i8 0, i64 392, i32 8, i1 false) %tmp = getelementptr inbounds %struct.b* %S, i32 0, i32 0 %tmp1 = getelementptr inbounds %struct.a* %tmp, i32 0, i32 0 %tmp2 = load i32* %X.addr, align 4 store i32 %tmp2, i32* %tmp1, align 4 %tmp5 = getelementptr inbounds %struct.b* %S, i32 0, i32 3 %tmp10 = getelementptr inbounds %struct.a* %tmp5, i32 0, i32 4 %tmp11 = load i32* %X.addr, align 4 store i32 %tmp11, i32* %tmp10, align 4 Previously we produced 99 stores of zero for test9 and also tons for test10. This xforms should substantially speed up -O0 builds when it kicks in as well as reducing code size and optimizer heartburn on insane cases. This resolves PR279. llvm-svn: 120692
* attempt to fix a buildbot failure, apparently apache fails to build.Chris Lattner2010-12-021-11/+8
| | | | llvm-svn: 120688
* Enhance the init generation logic to emit a memset followed by a few stores whenChris Lattner2010-12-021-6/+41
| | | | | | | | | | | | | | | | | | | | | | | | | a global is larger than 32 bytes and has fewer than 6 non-zero values in the initializer. Previously we'd turn something like this: char test8(int X) { char str[10000] = "abc"; into a 10K global variable which we then memcpy'd from. Now we generate: %str = alloca [10000 x i8], align 16 %tmp = getelementptr inbounds [10000 x i8]* %str, i64 0, i64 0 call void @llvm.memset.p0i8.i64(i8* %tmp, i8 0, i64 10000, i32 16, i1 false) store i8 97, i8* %tmp, align 16 %0 = getelementptr [10000 x i8]* %str, i64 0, i64 1 store i8 98, i8* %0, align 1 %1 = getelementptr [10000 x i8]* %str, i64 0, i64 2 store i8 99, i8* %1, align 2 Which is much smaller in space and also likely faster. This is part of PR279 llvm-svn: 120645
* add some infrastructure that will let us codegenChris Lattner2010-12-011-6/+67
| | | | | | | | http://llvm.org/bugs/show_bug.cgi?id=279#c3 better. No functionality change yet. llvm-svn: 120530
* get some i32/i8/i1 constants from Builder, which is much less painful thanChris Lattner2010-12-011-18/+9
| | | | | | using ConstantInt::get. llvm-svn: 120527
* Declaring local static in global blockFariborz Jahanian2010-11-301-3/+13
| | | | | | | literal declaration caused crash in CodeGen. This patch fixes it. pr8707 llvm-svn: 120486
* Fix warning: enumeration value 'IndirectField' not handled in switch.Francois Pichet2010-11-211-0/+1
| | | | llvm-svn: 119924
* Fixes synthesis of type for the object which holds info.Fariborz Jahanian2010-11-171-1/+2
| | | | | | about a __block cxx object. llvm-svn: 119411
* Some cleanup of block API code.Fariborz Jahanian2010-11-151-1/+1
| | | | llvm-svn: 119174
* Simplify the logic for emitting guard variables for template staticJohn McCall2010-11-061-1/+1
| | | | | | | | | data members by delaying the emission of the initializer until after linkage and visibility have been set on the global. Also, don't emit a guard unless the variable actually ends up with vague linkage, and don't use thread-safe statics in any case. llvm-svn: 118336
* Ensure that static local variables in function templates inherit theJohn McCall2010-11-021-1/+5
| | | | | | visibility of their function. llvm-svn: 118065
* Death to blocks, or at least the word "block" in one particular obnoxiouslyJohn McCall2010-10-151-22/+21
| | | | | | ambiguous context. llvm-svn: 116567
* Re-enable EH cleanups to destroy __block variables, now that we have a moment toJohn McCall2010-10-061-2/+1
| | | | | | deal with the consequences. Fixes rdar://problem/8224178. llvm-svn: 115816
* one piece of code is responsible for the lifetime of every aggregateJohn McCall2010-09-151-1/+1
| | | | | | | | | | | | | slot. The easiest way to do that was to bundle up the information we care about for aggregate slots into a new structure which demands that its creators at least consider the question. I could probably be convinced that the ObjC 'needs GC' bit should be rolled into this structure. Implement generalized copy elision. The main obstacle here is that IR-generation must be much more careful about making sure that exactly llvm-svn: 113962
* Implement ARM static local initialization guards, which are more compact thanJohn McCall2010-09-081-3/+3
| | | | | | Itanium guards and use a slightly different compiled-in API. llvm-svn: 113330
* Local static block variable referecned in itsFariborz Jahanian2010-09-071-3/+4
| | | | | | | | block-literal initializer expression causes IRgen to crash. This patch fixes by saving it in StaticLocalDecl map already used for such purposes. (radar 8390455). llvm-svn: 113307
* Truncate block variable of bool type to i1 when itsFariborz Jahanian2010-09-031-1/+1
| | | | | | | value is used. This matches with non-block variable use of bool type. (Fixes radar 8390062). llvm-svn: 113027
* A constant initializer never matches the type of the variable it'sJohn McCall2010-09-031-1/+1
| | | | | | | initializing; it at best matches the element type of the variable it's initializing. Fixes PR8073. llvm-svn: 112992
* Revert "Another i1 vs. i8 type mismatch issue. This time", it breaks some ↵Daniel Dunbar2010-09-031-1/+1
| | | | | | projects. llvm-svn: 112922
* Another i1 vs. i8 type mismatch issue. This timeFariborz Jahanian2010-09-021-1/+1
| | | | | | a 'bool' byref variable in memory. Fixes radar 8382559. llvm-svn: 112835
* De-memberify the VarDecl and FunctionDecl StorageClass enums.John McCall2010-08-261-7/+7
| | | | | | This lets us remove Sema.h's dependency on Expr.h and Decl.h. llvm-svn: 112156
* IRgen: Change Emit{Load,Store}OfScalar to take a required Alignment argument andDaniel Dunbar2010-08-211-3/+5
| | | | | | | | update callers as best I can. - This is a work in progress, our alignment handling is very horrible / sketchy -- I am just aiming for monotonic improvement. - Serious review appreciated. llvm-svn: 111707
* IRgen: Use Ty consistently in this function.Daniel Dunbar2010-08-211-5/+4
| | | | llvm-svn: 111705
* Further adjustments to -Wglobal-constructors; works for references and directJohn McCall2010-08-021-2/+2
| | | | | | initializations now. llvm-svn: 110063
* Turn off EH cleanups for __block variables; they caused some internal buildbotJohn McCall2010-07-221-1/+3
| | | | | | failures. There's a radar tracking this. llvm-svn: 109170
* Rename LazyCleanup -> Cleanup. No functionality change for these last threeJohn McCall2010-07-211-13/+13
| | | | | | commits. llvm-svn: 109000
* Switch some random local-decl cleanups over to using lazy cleanups. Turn onJohn McCall2010-07-211-52/+57
| | | | | | | the block-release unwind cleanup: we're never going to test it if we don't turn it on. llvm-svn: 108992
* When deferring the emission of declarations with initializers in C++, rememberJohn McCall2010-07-151-2/+2
| | | | | | | the order they appeared in the translation unit. If they get emitted, put them in their proper order. Fixes rdar://problem/7458115 llvm-svn: 108477
* Teach IR generation how to lazily emit cleanups. This has a lot of advantages,John McCall2010-07-131-46/+56
| | | | | | | | | | | | | | | mostly in avoiding unnecessary work at compile time but also in producing more sensible block orderings. Move the destructor cleanups for local variables over to use lazy cleanups. Eventually all cleanups will do this; for now we have some awkward code duplication. Tell IR generation just to never produce landing pads in -fno-exceptions. This is a much more comprehensive solution to a problem which previously was half-solved by checks in most cleanup-generation spots. llvm-svn: 108270
* Validated by nightly-test runs on x86 and x86-64 darwin, including afterJohn McCall2010-07-061-54/+58
| | | | | | | | | | | | | | | | | | | | | | | | self-host. Hopefully these results hold up on different platforms. I tried to keep the GNU ObjC runtime happy, but it's hard for me to test. Reimplement how clang generates IR for exceptions. Instead of creating new invoke destinations which sequentially chain to the previous destination, push a more semantic representation of *why* we need the cleanup/catch/filter behavior, then collect that information into a single landing pad upon request. Also reorganizes how normal cleanups (i.e. cleanups triggered by non-exceptional control flow) are generated, since it's actually fairly closely tied in with the former. Remove the need to track which cleanup scope a block is associated with. Document a lot of previously poorly-understood (by me, at least) behavior. The new framework implements the Horrible Hack (tm), which requires every landing pad to have a catch-all so that inlining will work. Clang no longer requires the Horrible Hack just to make exceptions flow correctly within a function, however. The HH is an unfortunate requirement of LLVM's EH IR. llvm-svn: 107631
* Remove unnecessary ASTContext parameter fromDouglas Gregor2010-07-011-1/+1
| | | | | | CXXRecordDecl::getDestructor(); no functionality change. llvm-svn: 107394
* finally get around to doing a significant cleanup to irgen:Chris Lattner2010-06-271-7/+6
| | | | | | | | have CGF create and make accessible standard int32,int64 and intptr types. This fixes a ton of 80 column violations introduced by LLVMContextification and cleans up stuff a lot. llvm-svn: 106977
* Change EmitReferenceBindingToExpr to take a decl instead of a boolean.Anders Carlsson2010-06-261-1/+1
| | | | llvm-svn: 106949
* Switch over to the new caching version of getMangledName.Anders Carlsson2010-06-221-6/+4
| | | | llvm-svn: 106549
* Move CodeGenOptions.h *back* into Frontend. This should have been done when theChandler Carruth2010-06-151-1/+1
| | | | | | dependency edge was reversed such that CodeGen depends on Frontend. llvm-svn: 106065
* Added AccessSpecDecl node.Abramo Bagnara2010-06-051-0/+1
| | | | llvm-svn: 105525
* Convert DeclNodes to use TableGen.Alexis Hunt2010-05-301-1/+1
| | | | | | | | The macros required for DeclNodes use have changed to match the use of StmtNodes. The FooFirst enumerator constants have been named firstFoo to match usage elsewhere. llvm-svn: 105165
* This cast is no longer required.Dan Gohman2010-05-281-4/+0
| | | | llvm-svn: 104916
* Patch to fix a irgen crash accessing an initialized local staticFariborz Jahanian2010-05-261-2/+3
| | | | | | variable in a local function. Fixes pr7101. llvm-svn: 104743
* If a function definition has any sort of weak linkage, its static localJohn McCall2010-05-251-8/+8
| | | | | | | | | | | | variables should have that linkage. Otherwise, its static local variables should have internal linkage. To avoid computing this excessively, set a function's linkage before we emit code for it. Previously we were assigning weak linkage to the static variables of static inline functions in C++, with predictably terrible results. This fixes that and also gives better linkage than 'weak' when merging is required. llvm-svn: 104581
* Ensure that destructors are called for NRVO'd objects when theDouglas Gregor2010-05-171-3/+31
| | | | | | | function does not return. Thanks to Eli for pointing out this corner case. llvm-svn: 103941
* When applying the named return value optimization, we still need toDouglas Gregor2010-05-151-2/+5
| | | | | | | destroy the variable along the exceptional edge; it's only during normal execution that we avoid destroying this variable. llvm-svn: 103872
* Implement a simple form of the C++ named return value optimization forDouglas Gregor2010-05-151-22/+36
| | | | | | | | | return statements. We perform NRVO only when all of the return statements in the function return the same variable. Fixes some link failures in Boost.Interprocess (which is relying on NRVO), and probably improves performance for some C++ applications. llvm-svn: 103867
* Emit the globals, metadata, etc. associated with static variables even whenJohn McCall2010-05-041-5/+2
| | | | | | | | they're unreachable. This matters because (if they're POD, or if this is C) the scope containing the variable might be reachable even if the variable isn't. Fixes PR7044. llvm-svn: 103052
* Fixes a Code Gen. Crash when calling destructor on a __blockFariborz Jahanian2010-05-041-4/+9
| | | | | | | variabe. Blocks and their construction/destruction is wip though. llvm-svn: 102985
* Just bail out immediately when emitting an unreachable function-local staticJohn McCall2010-05-031-0/+3
| | | | | | variable. Surprisingly, this does seem to be the right way to solve this. llvm-svn: 102961
OpenPOWER on IntegriCloud