Граф коммитов

318 Коммитов

Автор SHA1 Сообщение Дата
Fariborz Jahanian 8fefc8e245 objc-arc: fix a IRGen crash when checking for
accessibility of an initializer which is a compound 
statement. // rdar://9694706


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134091 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 20:00:16 +00:00
John McCall 545d996ec5 LValue carries a type now, so simplify the main EmitLoad/Store APIs
by removing the redundant type parameter.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133860 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-25 02:11:03 +00:00
John McCall 0c24c808e4 Honor objc_precise_lifetime in GC mode by feeding the value
in the variable to an inline asm which gets run when the variable
goes out of scope.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133840 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 23:21:27 +00:00
John McCall bc8d40d85f Change the IR-generation of VLAs so that we capture bounds,
not sizes;  so that we use well-typed allocas;  and so that we
properly recurse through the full set of variably-modified types.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133827 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 21:55:10 +00:00
Benjamin Kramer 19bd77c649 Remove dead variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133346 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-18 10:34:07 +00:00
John McCall 7acddacc92 Objective-C fast enumeration loop variables are not retained in ARC, but
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133243 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 06:42:21 +00:00
John McCall a07398ed98 Restore correct use of GC barriers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133144 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 04:16:24 +00:00
John McCall 175d6596a5 Suppress a warning in -Asserts builds.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133110 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 23:40:09 +00:00
John McCall f85e193739 Automatic Reference Counting.
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133103 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 23:02:42 +00:00
Devang Patel 98703d32ff Do not emit stoppoint before emitting debug info for parameters.
- llvm.dbg.declare already receives line number information from ParmDecl
- Additional extra stoppoint messes up gdb's understanding of where function body starts.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133065 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 17:57:08 +00:00
Devang Patel 9198126067 Rework r132576.
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.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132610 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 00:38:02 +00:00
Devang Patel c594abdb78 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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132576 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-03 19:21:47 +00:00
Eli Friedman 460980d3b9 Add unnamed_addr to internal globals which are only used as an operand to memcpy. (Spotted by looking at IR.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132226 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 22:32:55 +00:00
Richard Smith 3e4c6c4c79 Implement support for C++0x alias templates.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130953 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-05 21:57:07 +00:00
Eli Friedman 04c9a49ee2 Simplify code a bit by using CallArgList::add. No intended functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130699 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-02 17:57:46 +00:00
Richard Smith 162e1c1b48 Support for C++11 (non-template) alias declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129567 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-15 14:24:37 +00:00
Devang Patel 12e6d838e2 Fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128921 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-05 20:28:21 +00:00
John McCall 5af02db5a4 Move all the significant __block code into CGBlocks.cpp. No functionality
change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128608 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-31 01:59:53 +00:00
Peter Collingbourne 207f4d8543 Add support for language-specific address spaces. On top of that,
add support for the OpenCL __private, __local, __constant and
__global address spaces, as well as the __read_only, _read_write and
__write_only image access specifiers.  Patch originally by ARM;
language-specific address space support by myself.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127915 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-18 22:38:29 +00:00
John McCall 60d3365b46 Extract a function to emit an arbitrary expression as if it were the initializer
for a local variable.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127227 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-08 09:11:50 +00:00
Douglas Gregor 4707b9acf7 Revert r126422 "Use private linkage to avoid symbol conflicts in
corner cases like the one in PR9301." which caused PR9416. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127136 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-06 23:28:21 +00:00
Devang Patel 093ac461b3 Encode argument numbering in debug info so that code generator can emit them in order.
This fixes few blocks.exp regressions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126960 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-03 20:13:15 +00:00
Devang Patel 41ba26701d revert r126858.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126874 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-02 20:31:22 +00:00
Devang Patel 810b07ccf7 Encode argument numbering in debug info so that code generator can emit them in order.
This fixes few blocks.exp regressions.

Reapply r126795 with a fix (one character change) for gdb testsuite regressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126858 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-02 19:11:22 +00:00
Devang Patel 3da5cb2d6e Revert r126794.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126848 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-02 17:54:58 +00:00
Devang Patel 8a04585eba Encode argument numbering in debug info so that code generator can emit them in order.
This fixes few blocks.exp regressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126795 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-01 22:59:40 +00:00
Rafael Espindola bab380c2c8 Use private linkage to avoid symbol conflicts in corner cases like the one
in PR9301.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126422 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-24 20:31:44 +00:00
John McCall 8178df3b39 Emit the structure layout of the block literal parameter to a block
invocation function into the debug info.  Rather than faking up a class,
which is tricky because of the custom layout we do, we just emit a struct
directly from the layout information we've already got.

Also, don't emit an unnecessarily parameter alloca for this "variable".



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126255 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-22 22:38:33 +00:00
John McCall 57b3b6a608 Establish the iteration variable of an ObjC for-in loop before
emitting the collection expression.  Fixes some really, really broken
code.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126193 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-22 07:16:58 +00:00
John McCall 34695856c0 Reorganize the emission of local variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126189 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-22 06:44:22 +00:00
John McCall 0d3c985ad5 The flags we're supposed to write into a byref struct are *not* the
_Block_object_* flags;  it's just BLOCK_HAS_COPY_DISPOSE or not.

Also, we don't need to chase forwarding pointers prior to calling
_Block_object_dispose;  _Block_object_dispose in fact already does
this.

rdar://problem/9006315



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125823 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-18 02:58:31 +00:00
Chris Lattner 4ae493cccb implement basic support for __label__. I wouldn't be shocked if there are
bugs from other clients that don't expect to see a LabelDecl in a DeclStmt,
but if so they should be easy to fix.

This implements most of PR3429 and rdar://8287027



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125817 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-18 02:08:43 +00:00
Chris Lattner ad8dcf4a9d Step #1/N of implementing support for __label__: split labels into
LabelDecl and LabelStmt.  There is a 1-1 correspondence between the
two, but this simplifies a bunch of code by itself.  This is because
labels are the only place where we previously had references to random
other statements, causing grief for AST serialization and other stuff.

This does cause one regression (attr(unused) doesn't silence unused
label warnings) which I'll address next.

This does fix some minor bugs:
1. "The only valid attribute " diagnostic was capitalized.
2. Various diagnostics printed as ''labelname'' instead of 'labelname'
3. This reduces duplication of label checking between functions and blocks.

Review appreciated, particularly for the cindex and template bits.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125733 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-17 07:39:24 +00:00
Nick Lewycky a03733b28b Ensure that the NRVO flag has some block to insert into. Fixes PR9178!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125694 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-16 23:59:08 +00:00
Devang Patel 3475380293 Simplify test to check an aggregate argument that has non trivial constructor or destructor.
This patch rewrites r125142.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125632 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-16 01:11:51 +00:00
John McCall 5936e33bf7 Assorted cleanup:
- Have CGM precompute a number of commonly-used types
  - Have CGF copy that during initialization instead of recomputing them
  - Use TBAA info when initializing a parameter variable
  - Refactor the scalar ++/-- code



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125562 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-15 09:22:45 +00:00
Devang Patel 570729e716 If an aggregate argument is passed indirectly because it has non trivial
destructor or copy constructor than let debug info know about it.

Radar 8945514.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125142 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-09 00:37:30 +00:00
John McCall d16c2cf1ca Reorganize CodeGen{Function,Module} to eliminate the unfortunate
Block{Function,Module} base class.  Minor other refactorings.

Fixed a few address-space bugs while I was there.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125085 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-08 08:22:06 +00:00
John McCall 6b5a61b6dc A few more tweaks to the blocks AST representation:
- BlockDeclRefExprs always store VarDecls
  - BDREs no longer store copy expressions
  - BlockDecls now store a list of captured variables, information about
    how they're captured, and a copy expression if necessary
    
With that in hand, change IR generation to use the captures data in       
blocks instead of walking the block independently.        

Additionally, optimize block layout by emitting fields in descending
alignment order, with a heuristic for filling in words when alignment
of the end of the block header is insufficient for the most aligned
field.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125005 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-07 10:33:21 +00:00
John McCall 3ad32c8d93 Convert the exception-freeing cleanup over to the conditional cleanups code,
fixing a crash which probably nobody was ever going to see.  In doing so,
fix a horrendous number of problems with the conditional-cleanups code.
Also, make conditional cleanups re-use the cleanup's activation variable,
which avoids some unfortunate repetitiveness.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124481 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-28 08:37:24 +00:00
Fariborz Jahanian 52a80e19ad Fixes an IRgen bug where __block variable is
referenced in the block-literal initializer
of that variable. // rdar://8893785


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124332 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 23:08:27 +00:00
Ken Dyck 06f486ecd0 Replace calls to CharUnits::fromQuantity() with ones to
ASTContext::toCharUnitsFromBits() when converting from bit sizes to char units.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123720 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-18 02:01:14 +00:00
Peter Collingbourne 1411047788 Move name mangling support from CodeGen to AST. In the
process, perform a number of refactorings:

- Move MiscNameMangler member functions to MangleContext
- Remove GlobalDecl dependency from MangleContext
- Make MangleContext abstract and move Itanium/Microsoft functionality
  to their own classes/files
- Implement ASTContext::createMangleContext and have CodeGen use it

No (intended) functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123386 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-13 18:57:25 +00:00
Rafael Espindola 0ec89f928c Add support for declaring register contraints in variables. They are only used
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122643 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-30 22:59:32 +00:00
Nick Lewycky a9de3fa8a9 Correct function name in comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122640 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-30 20:21:55 +00:00
Benjamin Kramer 9f0c7cc36d Simplify mem{cpy, move, set} creation with IRBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122634 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-30 00:13:21 +00:00
Fariborz Jahanian 830937bc11 IR Gen. part of API support for __block cxx
objects imported into blocks. //rdar://8594790.
Will have a test case coming (as well as one
sent to llvm test suite).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120713 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-02 17:02:11 +00:00
Chris Lattner 1b726771d0 Improve codegen for initializer lists to use memset more aggressively
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120692 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-02 07:07:26 +00:00
Chris Lattner c0f31fd085 attempt to fix a buildbot failure, apparently apache fails to build.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120688 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-02 04:27:29 +00:00
Chris Lattner 70b02943dd Enhance the init generation logic to emit a memset followed by a few stores when
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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120645 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-02 01:58:41 +00:00
Chris Lattner 94cd011edc add some infrastructure that will let us codegen
http://llvm.org/bugs/show_bug.cgi?id=279#c3 better.

No functionality change yet.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120530 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-01 02:05:19 +00:00
Chris Lattner 4c53dc1ebd get some i32/i8/i1 constants from Builder, which is much less painful than
using ConstantInt::get.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120527 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-01 01:47:15 +00:00
Fariborz Jahanian faa5bfcaaf Declaring local static in global block
literal declaration caused crash in CodeGen.
This patch fixes it. pr8707


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120486 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-30 23:07:14 +00:00
Francois Pichet 41f5e66d44 Fix warning: enumeration value 'IndirectField' not handled in switch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119924 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-21 06:49:41 +00:00
Fariborz Jahanian e38be61743 Fixes synthesis of type for the object which holds info.
about a __block cxx object.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119411 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-17 00:21:28 +00:00
Fariborz Jahanian 2715b207a6 Some cleanup of block API code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119174 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-15 19:19:38 +00:00
John McCall 3030eb8259 Simplify the logic for emitting guard variables for template static
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118336 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-06 09:44:32 +00:00
John McCall 112c967bd5 Ensure that static local variables in function templates inherit the
visibility of their function.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118065 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-02 21:04:24 +00:00
John McCall b6bbcc9995 Death to blocks, or at least the word "block" in one particular obnoxiously
ambiguous context.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116567 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-15 04:57:14 +00:00
John McCall 34fdee3771 Re-enable EH cleanups to destroy __block variables, now that we have a moment to
deal with the consequences.  Fixes rdar://problem/8224178.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115816 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-06 18:56:43 +00:00
John McCall 558d2abc7f one piece of code is responsible for the lifetime of every aggregate
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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113962 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-15 10:14:12 +00:00
John McCall 5cd91b5134 Implement ARM static local initialization guards, which are more compact than
Itanium guards and use a slightly different compiled-in API.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113330 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-08 01:44:27 +00:00
Fariborz Jahanian 09349145d7 Local static block variable referecned in its
block-literal initializer expression causes IRgen to crash.
This patch fixes by saving it in StaticLocalDecl map
already used for such purposes. (radar 8390455).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113307 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-07 23:26:17 +00:00
Fariborz Jahanian 469a20de75 Truncate block variable of bool type to i1 when its
value is used. This matches with non-block variable
use of bool type. (Fixes radar 8390062).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113027 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-03 23:07:53 +00:00
John McCall 9c20fa9d46 A constant initializer never matches the type of the variable it's
initializing;  it at best matches the element type of the variable
it's initializing.  Fixes PR8073.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112992 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-03 18:58:50 +00:00
Daniel Dunbar 3e7cf38810 Revert "Another i1 vs. i8 type mismatch issue. This time", it breaks some projects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112922 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-03 00:35:23 +00:00
Fariborz Jahanian 73556e0d96 Another i1 vs. i8 type mismatch issue. This time
a 'bool' byref variable in memory. Fixes radar 8382559.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112835 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-02 17:28:31 +00:00
John McCall d931b08698 De-memberify the VarDecl and FunctionDecl StorageClass enums.
This lets us remove Sema.h's dependency on Expr.h and Decl.h.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112156 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-26 03:08:43 +00:00
Daniel Dunbar 91a16fa326 IRgen: Change Emit{Load,Store}OfScalar to take a required Alignment argument and
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111707 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-21 02:24:36 +00:00
Daniel Dunbar 4cac2a157c IRgen: Use Ty consistently in this function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111705 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-21 02:17:08 +00:00
John McCall 4204f07fc8 Further adjustments to -Wglobal-constructors; works for references and direct
initializations now.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110063 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-02 21:13:48 +00:00
John McCall db2cfecf0e Turn off EH cleanups for __block variables; they caused some internal buildbot
failures.  There's a radar tracking this.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109170 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-22 21:25:44 +00:00
John McCall 1f0fca5467 Rename LazyCleanup -> Cleanup. No functionality change for these last three
commits.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109000 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-21 07:22:38 +00:00
John McCall d871509998 Switch some random local-decl cleanups over to using lazy cleanups. Turn on
the block-release unwind cleanup:  we're never going to test it if we don't turn
it on.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108992 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-21 06:13:08 +00:00
John McCall bf40cb5183 When deferring the emission of declarations with initializers in C++, remember
the order they appeared in the translation unit.  If they get emitted, put them
in their proper order.  Fixes rdar://problem/7458115



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108477 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-15 23:40:35 +00:00
John McCall da65ea8648 Teach IR generation how to lazily emit cleanups. This has a lot of advantages,
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108270 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-13 20:32:21 +00:00
John McCall f1549f66a8 Validated by nightly-test runs on x86 and x86-64 darwin, including after
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.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107631 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-06 01:34:17 +00:00
Douglas Gregor 1d110e05e0 Remove unnecessary ASTContext parameter from
CXXRecordDecl::getDestructor(); no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107394 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-01 14:13:13 +00:00
Chris Lattner 77b89b87c3 finally get around to doing a significant cleanup to irgen:
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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106977 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-27 07:15:29 +00:00
Anders Carlsson 32f36baa6c Change EmitReferenceBindingToExpr to take a decl instead of a boolean.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106949 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-26 16:35:32 +00:00
Anders Carlsson 9a20d55807 Switch over to the new caching version of getMangledName.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106549 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22 16:16:50 +00:00
Chandler Carruth 06057cef0b Move CodeGenOptions.h *back* into Frontend. This should have been done when the
dependency edge was reversed such that CodeGen depends on Frontend.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106065 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-15 23:19:56 +00:00
Abramo Bagnara 6206d53f67 Added AccessSpecDecl node.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105525 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-05 05:09:32 +00:00
Sean Hunt 9a55591af3 Convert DeclNodes to use TableGen.
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105165 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-30 07:21:58 +00:00
Dan Gohman 707bef3207 This cast is no longer required.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104916 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-28 01:39:35 +00:00
Fariborz Jahanian 4c464b9702 Patch to fix a irgen crash accessing an initialized local static
variable in a local function. Fixes pr7101.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104743 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-26 21:45:50 +00:00
John McCall 8b24233616 If a function definition has any sort of weak linkage, its static local
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104581 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-25 04:30:21 +00:00
Douglas Gregor 3d91bbcdab Ensure that destructors are called for NRVO'd objects when the
function does not return. Thanks to Eli for pointing out this corner
case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103941 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-17 15:52:46 +00:00
Douglas Gregor b5b30b96e0 When applying the named return value optimization, we still need to
destroy the variable along the exceptional edge; it's only during
normal execution that we avoid destroying this variable.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103872 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-15 16:39:56 +00:00
Douglas Gregor d86c477fb5 Implement a simple form of the C++ named return value optimization for
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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103867 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-15 06:46:45 +00:00
John McCall fe67f3bfc0 Emit the globals, metadata, etc. associated with static variables even when
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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103052 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-04 20:45:42 +00:00
Fariborz Jahanian 3c347f25b5 Fixes a Code Gen. Crash when calling destructor on a __block
variabe. Blocks and their construction/destruction is
wip though. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102985 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-04 00:26:07 +00:00
John McCall e65ce966b6 Just bail out immediately when emitting an unreachable function-local static
variable.  Surprisingly, this does seem to be the right way to solve this.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102961 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-03 21:39:56 +00:00
Anders Carlsson 8e6404ca28 Add the same 'ForVirtualBase' parameter to EmitCXXDestructorCall.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102882 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-02 23:29:11 +00:00
Douglas Gregor 08688ac8aa I hate default statements. Fixes PR6874.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102160 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-23 02:02:43 +00:00
Fariborz Jahanian 63326a5341 Some renaming of methods, fixes typo
(related to PR6769).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101794 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19 18:15:02 +00:00
Fariborz Jahanian 65ad5a42cc Local static variables must be available module-wise
as they are accessible in static methods in a class
local to the same function. Fixes PR6769.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101756 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-18 21:01:23 +00:00
Mon P Wang 3ecd785aff Reapply patch for adding support for address spaces and added a isVolatile field to memcpy, memmove, and memset.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100305 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-04 03:10:52 +00:00
Mon P Wang c90f56d9f1 Revert r100193 since it causes failures in objc in clang
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100200 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-02 18:43:42 +00:00
Mon P Wang 8facca6caf Reapply patch for adding support for address spaces and added a isVolatile field to memcpy, memmove, and memset.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100193 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-02 18:04:30 +00:00