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

174 Коммитов

Автор SHA1 Сообщение Дата
Sebastian Redl 8026f6d82f Instead of storing an ASTContext* in FunctionProtoTypes with computed noexcept specifiers, unique FunctionProtoTypes with a ContextualFoldingSet, as suggested by John McCall.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127568 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-13 17:09:40 +00:00
Sebastian Redl 60618fa7f8 Propagate the new exception information to FunctionProtoType.
Change the interface to expose the new information and deal with the enormous fallout.
Introduce the new ExceptionSpecificationType value EST_DynamicNone to more easily deal with empty throw specifications.
Update the tests for noexcept and fix the various bugs uncovered, such as lack of tentative parsing support.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127537 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-12 11:50:43 +00:00
John McCall 413ebdb1af Use a slightly more semantic interface for emitting call arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127494 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-11 20:59:21 +00:00
John McCall c2f3e7f42c The conditional needs to be pushed before the branch. Make the test less
trivial to check this.  Adjust for style.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127151 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-07 03:12:35 +00:00
John McCall a7f633f522 An operator new with an empty exception specifier returns null on a bad
allocation and therefore requires a null-check.  We were doing that, but
we weren't treating the new-initializer as being conditionally executed,
which means it was possible to get ill-formed IR as in PR9298.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127147 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-07 01:52:56 +00:00
Tilmann Scheller 9c6082fe89 Revert "Add CC_Win64ThisCall and set it in the necessary places."
This reverts commit 126863.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126886 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-02 21:36:49 +00:00
Tilmann Scheller 88d117c2ee Add CC_Win64ThisCall and set it in the necessary places.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126863 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-02 19:36:23 +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
Fariborz Jahanian 771c678c04 Clean up of -fapple-kext abi code. No change otherwise.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124807 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-03 19:27:17 +00:00
Fariborz Jahanian ccd5259d33 -fapple-kext support for indirect call to virtuals dtors - wip.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124701 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-01 23:22:34 +00:00
Anders Carlsson 268ab8c6b9 When trying to get the most derived class, don't assume that we can ignore all casts. We can only ignore derived-to-base and no-op casts. Fixes selfhost.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124528 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-29 05:04:11 +00:00
Anders Carlsson 1679f5a84a When calling a virtual member function on a base class and the most derived class is marked 'final', we can devirtualize the call.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124524 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-29 03:52:01 +00:00
Fariborz Jahanian a50e33eb0f More work to support -fapple-kext regarding
indirect vf calls and addition of extra entry
at bottom of vtbls.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124507 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-28 23:42:29 +00:00
John McCall 36f893c1ef Move all the cleanups framework code into a single file.
Pure motion.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124484 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-28 11:13:47 +00:00
John McCall 804b807ea9 Reorganize the value-dominance metaprogram and introduce a specialization
for CodeGen's RValue type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124483 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-28 10:53:53 +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
John McCall 6ec278d1a3 Do a proper recursive lookup when deciding whether a class's usual
deallocation function has a two-argument form.  Store the result of this
check in new[] and delete[] nodes.

Fixes rdar://problem/8913519



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124373 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-27 09:37:56 +00:00
Anders Carlsson cb88a1f968 Use attributes for all the override control specifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124122 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-24 16:26:15 +00:00
Anders Carlsson f89e0424b8 Get rid of the [[final]] C++0x attribute.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124083 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-23 21:07:30 +00:00
Fariborz Jahanian 7ac0ff2a87 Move cheking of kext into canDevirtualizeMemberFunctionCalls().
Improve on test case. Per Doug's comment. wip.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123954 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-21 01:04:41 +00:00
Fariborz Jahanian 2726267f09 apple kext abi requires all vf calls, including qualified
vf calls, be made indirect. This patch is towards that goal.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123922 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 17:19:02 +00:00
Ken Dyck fe71008c27 Replace calls to getTypeSize() and getTypeAlign() with their 'InChars'
counterparts where char units are needed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123805 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-19 01:58:38 +00:00
Francois Pichet dbee3411a2 Add support for explicit constructor calls in Microsoft mode.
For example: 

class A{ 
public:
  A& operator=(const A& that) {
      if (this != &that) {
          this->A::~A();
          this->A::A(that);  // <=== explicit constructor call.
      }
      return *this;
  }
};

More work will be needed to support an explicit call to a template constructor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123735 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-18 05:04:39 +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
Jay Foad 9f71a8f4c7 PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method
trunc(), to be const and to return a new value instead of modifying the
object in place.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121121 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 08:25:34 +00:00
John McCall 4765fa05b5 Rename CXXExprWithTemporaries -> ExprWithCleanups; there's no theoretical
reason this is limited to C++, and it's certainly not limited to temporaries.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120996 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-06 08:20:24 +00:00
John McCall 0e800c9c20 Remove some defensive calls to EmitLoadOfPropertyRefLValue that shouldn't
be required, and then fix up some missing loads on overloaded-operator
paths which that exposed.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120896 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 08:14:53 +00:00
John McCall 119a1c6c40 Kill the KVC l-value kind and calculate the base expression when emitting
the l-value.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120884 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 02:32:38 +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
Chandler Carruth 858a546d8f Silence an unused variable warning during release builds by folding the
expression into the assert.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119143 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-15 13:54:43 +00:00
Fariborz Jahanian 34999876e2 Block API patch to do copy ctor of copied-in cxx objects in
copy helper function and dtor of copied cxx objects
in dispose helper functions. __block variables
TBD next.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119011 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-13 21:53:34 +00:00
Anders Carlsson d66f428565 Also devirtualize calls to a member functions where the containing class has been marked final.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117445 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-27 13:34:43 +00:00
Anders Carlsson bd2bfae2a6 If a virtual member function has the 'final' attribute, we can devirtualize calls to it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117444 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-27 13:28:46 +00:00
Dan Gohman 043fb9a1fc Factor out the code for emitting code to load vtable pointer members
so that it's done in one place.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117386 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-26 18:44:08 +00:00
Fariborz Jahanian 8a97005f97 After discussion with Doug and John, I am reverting
the patch. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117159 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-22 22:05:03 +00:00
Fariborz Jahanian 07ed93f378 Patch fixes miscompile with non-trivial copy constructors and
statement expressions, //rdar: //8540501


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117146 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-22 21:01:02 +00:00
Devang Patel 6802027338 Delay record type's debug info emission, in -flimit-debug-info mode, if member expression's base is call expr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117127 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-22 18:56:27 +00:00
Benjamin Kramer 79ba2a6379 More class anonymization.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117106 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-22 16:48:22 +00:00
Devang Patel c69e1cf043 Introduce -flimit-debug-info.
In this experimental mode try avoiding debug info emission for classes as much as possible. The goal is to reduce size of produced debuginfo without reducing quality of debug info in general. This is a work in progress.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115188 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-30 19:05:55 +00:00
Douglas Gregor 3e9438b525 Kill FunctionDecl's IsCopyAssignment bit; it duplicated what could
already be determined by isCopyAssignmentOperator(), and was set too
late in the process for all clients to see the appropriate
value. Cleanup only; no functionality change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114916 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-27 22:37:28 +00:00
John McCall fc1e6c79bb Fix a bug with binding l-values to elided temporaries, and leave a couple
helpful asserts behind.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114250 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-18 00:58:34 +00:00
John McCall 3019c444c6 When emitting a new-expression inside a conditional expression,
the cleanup might not be dominated by the allocation code.
In this case, we have to store aside all the delete arguments
in case we need them later.  There's room for optimization here
in cases where we end up not actually needing the cleanup in
different branches (or being able to pop it after the
initialization code).

Also make sure we only call this operator delete along the path
where we actually allocated something.

Fixes rdar://problem/8439196.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114145 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-17 00:50:28 +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 c384636f9a Tweak this assert.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113863 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-14 21:45:42 +00:00
John McCall 7d8647f194 Implement the EH cleanup to call 'operator delete' if a new-expression throws
(but not if destructors associated with the full-expression throw).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113836 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-14 07:57:04 +00:00
Fariborz Jahanian 0339d72d7f IRGen fix for using property-dot syntax to pass
reference object to a c++ member function.
fixes radar 8409336.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113602 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-10 18:56:35 +00:00
John McCall fc40028728 Re-commit r112916 with an additional fix for the self-host failures.
I've audited the remaining getFunctionInfo call sites.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112936 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-03 01:26:39 +00:00
John McCall 2b8d60dfdf Revert r112916, it's breaking selfhost pretty badly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112925 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-03 00:40:45 +00:00
John McCall 52968abd2a It's not safe to use the generic CXXMethodDecl overload of CGT::getFunctionInfo
to set up a destructor call, because ABIs can tweak these conventions.
Fixes rdar://problem/8386802.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112916 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-03 00:01:57 +00:00
Douglas Gregor cc09c022be Fix a few more ConvertTypes that should be ConvertTypeForMems, fixing
two regressions in Boost.Config.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112908 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-02 23:24:14 +00:00
Douglas Gregor eede61a83e Revert my two IRgen fixes for "bool", then use a far simpler approach
based on ConvertTypeForMem. Thanks to John for pointing out the right
solution.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112838 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-02 17:38:50 +00:00
Douglas Gregor f9cce31a1c Fix more i1/i8 pointer madness. Here, an overactive assertion
complains when the element type of a C++ "delete" expression is
different from what we would expect from the pointer type. When
deleting a bool*, we end up with an i1 on one side (where we compute
the LLVM type from the Clang bool type) and i8 on the other (where we
grab the LLVM type from the LLVM pointer type). I've weakened the
assertion appropriately, and the Boost Parallel Graph Library now
passes its regression tests.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112821 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-02 15:34:35 +00:00
John McCall 1e7fe75146 Abstract IR generation of array cookies into the C++ ABI class and
implement ARM array cookies.  Also fix a few unfortunate bugs:
  - throwing dtors in deletes prevented the allocation from being deleted
  - adding the cookie to the new[] size was not being considered for
    overflow (and, more seriously, was screwing up the earlier checks)
  - deleting an array via a pointer to array of class type was not
    causing any destructors to be run and was passing the unadjusted
    pointer to the deallocator
  - lots of address-space problems, in case anyone wants to support
    free store in a variant address space :)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112814 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-02 09:58:18 +00:00
Fariborz Jahanian 98c9d1fa37 Fix IRGen when property-dot syntax used to access
a c++ class object 'ivar'. Fixes radar 8366604.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112729 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-01 19:36:41 +00:00
John McCall 4c40d98ab7 Teach IR generation to return 'this' from constructors and destructors
under the ARM ABI.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112588 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-31 07:33:07 +00:00
Sebastian Redl 7a126a474f Rename DeclContext::getLookupContext to getRedeclContext and change its semantics slightly. No functionality change in the absence of inline namespaces. Also, change a few places where inline namespaces actually make a difference to be prepared for them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112563 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-31 00:36:30 +00:00
Argyrios Kyrtzidis e7ab92e1d6 Fix miscompilation. The cookie was not used when new'ing arrays with multiple dimensions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112188 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-26 15:23:38 +00:00
John McCall 2de56d1d0c GCC didn't care for my attempt at API compatibility, so brute-force everything
to the new constants.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112047 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25 11:45:40 +00:00
John McCall 5172ed92b4 Extract a method to check whether a function is the global placement
operator new[].



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111788 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-23 01:17:59 +00:00
John McCall f16aa103d3 Go back to asking CodeGenTypes whether a type is zero-initializable.
Make CGT defer to the ABI on all member pointer types.
This requires giving CGT a handle to the ABI.
It's way easier to make that work if we avoid lazily creating the ABI.
Make it so.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111786 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-22 21:01:12 +00:00
Douglas Gregor 759e41baf6 When performing value-initialization for a class with a non-trivial,
implicitly-defined default constructor, zero-initialize the memory
before calling the default constructor. Previously, we would only
zero-initialize in the case of a trivial default constructor.

Also, simplify the hideous logic that determines when we have a
trivial default constructor and, therefore, don't need to emit any
call at all.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111779 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-22 16:15:35 +00:00
John McCall d608cdb7c0 Experiment with using first-class aggregates to represent member function
pointers.  I find the resulting code to be substantially cleaner, and it
makes it very easy to use the same APIs for data member pointers (which I have
conscientiously avoided here), and it avoids a plethora of potential
inefficiencies due to excessive memory copying, but we'll have to see if it
actually works.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111776 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-22 10:59:02 +00:00
John McCall cf2c85e76f Abstract more member-pointerness out.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111771 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-22 04:16:24 +00:00
John McCall 93d557bc18 Extract calls to method pointers out as an ABI routine.
No functionality change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111752 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-22 00:05:51 +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
Douglas Gregor 452b7f22d7 Fix a major regression with value-initialization of class types with
trivial default constructors. We're weren't zero-initializing them,
which manifested as <rdar://problem/8320532> (a regression in the GCC
test suite) and is likely to have caused significant other breakage.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111650 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-20 16:57:37 +00:00
Douglas Gregor 59174c0633 Implement zero-initialization for array new when there is an
initializer of (). Make sure to use a simple memset() when we can, or
fall back to generating a loop when a simple memset will not
suffice. Fixes <rdar://problem/8212208>, a regression due to my work
in r107857.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108977 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-21 01:10:17 +00:00
Chris Lattner 806941eab5 in 'new int[4]', constant fold the 4*4=16 instead of
doing an overflow check.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108943 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-20 21:55:52 +00:00
Chris Lattner 83252dcfe6 Follow the implementation approach suggested by PR6687,
which generates more efficient and more obviously conformant
code.  We now test for overflow of the multiply then force
the result to -1 if so.  On X86, this generates nice code
like this:

__Z4testl:                              ## @_Z4testl
## BB#0:                                ## %entry
	subl	$12, %esp
	movl	$4, %eax
	mull	16(%esp)
	testl	%edx, %edx
	movl	$-1, %ecx
	cmovel	%eax, %ecx
	movl	%ecx, (%esp)
	call	__Znam
	addl	$12, %esp
	ret



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108927 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-20 21:07:09 +00:00
Chris Lattner 6c552c1d5f implement rdar://5739832 - operator new should check for overflow in multiply,
causing clang to compile this code into something that correctly throws a
length error, fixing a potential integer overflow security attack:

void *test(long N) {
  return new int[N];
}

int main() {
  test(1L << 62);
}

We do this even when exceptions are disabled, because it is better for the
code to abort than for the attack to succeed.

This is heavily based on a patch that Fariborz wrote.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108915 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-20 20:19:24 +00:00
Chris Lattner 6ba9aaed5e delete a loop that just generates dead code. In an example
like this:

void *test(long N) {
  return new int[N][42][42];
}

the loop generates two dead mul instructions:

  %tmp = load i64* %N.addr                        ; <i64> [#uses=2]
  %0 = mul i64 %tmp, 7056                         ; <i64> [#uses=1]
  %1 = mul i64 %tmp, 42                           ; <i64> [#uses=1]
  %2 = mul i64 %1, 42                             ; <i64> [#uses=0]
  %call = call noalias i8* @_Znam(i64 %0)         ; <i8*> [#uses=1]

The scale of these multiplies is already handled by the typesize stuff.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108884 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-20 18:49:33 +00:00
Chris Lattner defe8b263a remove the special case for constant array sizes from
EmitCXXNewAllocSize.  This code uses IRBuilder, which does
constant folding already.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108882 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-20 18:45:57 +00:00
Douglas Gregor ed8abf1832 Reinstate the fix for PR7556. A silly use of isTrivial() was
suppressing copies of objects with trivial copy constructors.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107857 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-08 06:14:04 +00:00
Douglas Gregor 84745677f6 Revert r107828 and r107827, the fix for PR7556, which seems to be
breaking bootstrap on Linux.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107837 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-07 23:37:33 +00:00
Douglas Gregor 63ef464c3f Do not use CXXZeroValueInitExpr for class types. Instead, use
CXXConstructExpr/CXXTemporaryObjectExpr/CXXNewExpr as
appropriate. Fixes PR7556, and provides a slide codegen improvement
when copy-initializing a POD class type from a value-initialized
temporary. Previously, we weren't eliding the copy.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107827 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-07 22:35:13 +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
Fariborz Jahanian 5304c953c1 Minor change to my last patch to fix PR7490.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106875 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-25 20:01:13 +00:00
Fariborz Jahanian ef66872797 IRGen for trivial initialization of dynamiccaly allocated
array of other done c++ objects. Fixes PR7490.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106869 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-25 18:26:07 +00:00
Fariborz Jahanian 55bcace250 Patch adds support for copying of those
objective-c++ class objects which have GC'able objc object
pointers and need to use ObjC's objc_memmove_collectable
API (radar 8070772). 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106061 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-15 22:44:06 +00:00
Fariborz Jahanian 842ddd0391 Adds support for generation of objc_memmove_collectable API
in Objective-C++ mode.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104281 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-20 21:38:57 +00:00
Fariborz Jahanian 1d49f21125 Copy construction of non-trivial properties must not
be turned into a setter call (fixes radar 8008649).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104235 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-20 16:46:55 +00:00
Fariborz Jahanian c9a8fa4e4d Minor twik to my last patch. (for radar 7986354).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103889 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-16 00:10:46 +00:00
Fariborz Jahanian 0ca0b1f4b4 Fix API gen for objc_msgSend property of aggregate types
in Objective-c++ mode. Fixes radar 7986354.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103887 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-15 23:05:52 +00:00
Douglas Gregor 3c9034cb7f Recognize when the named return value optimization applies in a
"return" statement and mark the corresponding CXXConstructExpr as
elidable. Teach CodeGen that eliding a temporary is different from
eliding an object construction.

This is just a baby step toward NRVO.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103849 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-15 00:13:29 +00:00
Douglas Gregor 485ee32d93 When a failed dynamic_cast<T&> (which is an lvalue) results in a
throw, it should use invoke when needed. The fixes the
Boost.Statechrt failures that motivated PR7132, but there are a few
side issues to tackle as well.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103803 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-14 21:14:41 +00:00
Fariborz Jahanian b3ebe946d3 Objective-C++ Code gen. Handle code gen. for property
reference dot-syntax notation in a varierty of cases.
Fixes radar 7964490.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103440 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-10 22:57:35 +00:00
Fariborz Jahanian 100b3b9153 Minor mod. to my last patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103280 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-07 18:59:54 +00:00
Fariborz Jahanian bbb5224710 Fixes a Code gen crash trying to use a dot-syntax for
a property of a c++ class object (radar 7957369).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103279 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-07 18:56:13 +00:00
Anders Carlsson e99bdb6969 Don't build an aggregate constructor loop when the constructor is trivial.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102912 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-03 15:09:17 +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
Anders Carlsson 155ed4a233 Revert my last change and add a 'ForVirtualBase' parameter to EmitCXXConstructorCall instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102881 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-02 23:20:53 +00:00
Anders Carlsson 24eb78e38a Pass the construction kind down to EmitCXXConstructorCall.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102880 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-02 23:01:10 +00:00
Anders Carlsson 43db20e955 Simplify EmitClassAggrMemberwiseCopy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102848 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-01 17:02:18 +00:00
Anders Carlsson 046c294a43 Vtable -> VTable renames across the board.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101666 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-17 20:15:18 +00:00
Douglas Gregor 2f59979a7c Rework our handling of copy construction of temporaries, which was a
poor (and wrong) approximation of the actual rules governing when to
build a copy and when it can be elided.

The correct implementation is actually simpler than the
approximation. When we only enumerate constructors as part of
initialization (e.g., for direct initialization or when we're copying
from a class type or one of its derived classes), we don't create a
copy. When we enumerate all conversion functions, we do create a
copy. Before, we created some extra copies and missed some
others. The new test copy-initialization.cpp shows a case where we
missed creating a (required, non-elidable) copy as part of a
user-defined conversion, which resulted in a miscompile. This commit
also fixes PR6757, where the missing copy made us reject well-formed
code in the ternary operator.

This commit also cleans up our handling of copy elision in the case
where we create an extra copy of a temporary object, which became
necessary now that we produce the right copies. The code that seeks to
find the temporary object being copied has moved into
Expr::getTemporaryObject(); it used to have two different
not-quite-the-same implementations, one in Sema and one in CodeGen.

Note that we still do not attempt to perform the named return value
optimization, so we miss copy elisions for return values and throw
expressions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100196 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-02 18:24:57 +00:00
Rafael Espindola 264ba48dc9 the big refactoring bits of PR3782.
This introduces FunctionType::ExtInfo to hold the calling convention and the
noreturn attribute. The next patch will extend it to include the regparm
attribute and fix the bug.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99920 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30 20:24:48 +00:00
Fariborz Jahanian ceb43b662b Code gen for multi-dimensional dynamic allocations.
Fixes PR6641.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99404 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24 16:57:01 +00:00
Daniel Dunbar 195337d2e5 IRgen: Add CreateMemTemp, for creating an temporary memory object for a particular type, and flood fill. - CreateMemTemp sets the alignment on the alloca correctly, which fixes a great many places in IRgen where we were doing the wrong thing.
- This fixes many many more places than the test case, but my feeling is we need to audit alignment systematically so I'm not inclined to try hard to test the individual fixes in this patch. If this bothers you, patches welcome!

PR6240.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95648 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-09 02:48:28 +00:00
John McCall 04a67a6aa3 Standardize the parsing of function type attributes in a way that
follows (as conservatively as possible) gcc's current behavior:  attributes
written on return types that don't apply there are applied to the function
instead, etc.  Only parse CC attributes as type attributes, not as decl attributes;
don't accepet noreturn as a decl attribute on ValueDecls, either (it still
needs to apply to other decls, like blocks).  Consistently consume CC/noreturn
information throughout codegen;  enforce this by removing their default values
in CodeGenTypes::getFunctionInfo().



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95436 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 21:31:56 +00:00
Daniel Dunbar ea48522e97 IRgen: Fix some CreateTempAlloca calls to use ConvertTypeForMem when that is
conceptually correct. Review appreciated (Chris, Eli, Anders).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95401 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 18:56:49 +00:00