summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/const-init-cxx11.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Disable -fmerge-all-constants as default.Manoj Gupta2018-04-051-1/+1
| | | | | | | | | | | | | | | | | | | Summary: "-fmerge-all-constants" is a non-conforming optimization and should not be the default. It is also causing miscompiles when building Linux Kernel (https://lkml.org/lkml/2018/3/20/872). Fixes PR18538. Reviewers: rjmccall, rsmith, chandlerc Reviewed By: rsmith, chandlerc Subscribers: srhines, cfe-commits Differential Revision: https://reviews.llvm.org/D45289 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329300 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: Start using inrange annotations on vtable getelementptr.Peter Collingbourne2016-12-131-3/+3
| | | | | | | | | | | | This annotation allows the optimizer to split vtable groups, as permitted by a change to the Itanium ABI [1] that prevents compilers from adjusting virtual table pointers between virtual tables. [1] https://github.com/MentorEmbedded/cxx-abi/pull/7 Differential Revision: https://reviews.llvm.org/D24431 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289585 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: New vtable group representation: struct of vtable arrays.Peter Collingbourne2016-12-131-3/+3
| | | | | | | | | In a future change, this representation will allow us to use the new inrange annotation on getelementptr to allow the optimizer to split vtable groups. Differential Revision: https://reviews.llvm.org/D22296 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289584 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: Use 32-bit gep offsets to address vtable address points.Peter Collingbourne2016-03-141-3/+3
| | | | | | | | | | | | | | | | | The relative vtable ABI will use a struct rather than an array as the type of a vtable. LLVM only allows 32-bit integers as struct indices, so we need to use 32-bit integers to get addresses of address points. In order to keep the code simple, we might as well do that unconditionally. It's probably a reasonable implementation limit to support no more than 2 billion virtual functions per class. This change causes quite a bit of churn in the test suite, so I'm making it separately. Differential Revision: http://reviews.llvm.org/D18113 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263469 91177308-0d34-0410-b5e6-96231b3b80d8
* Internal-linkage variables with constant-evaluatable initializers do not ↵Richard Smith2015-08-191-0/+1
| | | | | | need to be emitted. (Also reduces the set of variables that need to be eagerly deserialized when using PCH / modules.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245497 91177308-0d34-0410-b5e6-96231b3b80d8
* Test case updates for explicit type parameter to the gep operatorDavid Blaikie2015-03-131-5/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232187 91177308-0d34-0410-b5e6-96231b3b80d8
* Update Clang tests to handle explicitly typed load changes in LLVM.David Blaikie2015-02-271-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230795 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: Weak reference temporaries belong in a COMDATDavid Majnemer2015-02-191-4/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229902 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: static constexpr data members should have a linkonce_odr initDavid Majnemer2015-02-191-16/+25
| | | | | | | | | Classes can be defined in multiple translation units. This means that the static constexpr data members should have identical initializers in all translation units. Implement this by giving the reference temporary linkonce_odr linkage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229900 91177308-0d34-0410-b5e6-96231b3b80d8
* Test that member functions of constexpr constructed templates are instantiated.Nico Weber2015-01-261-1/+14
| | | | | | | | They are referenced from the vtable. (This worked fine, but I couldn't find an existing test for this. Maybe I didn't look hard enough.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227072 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove -verify from a codegen test that didn't have any expected-foo lines.Nico Weber2015-01-261-1/+1
| | | | | | | | Makes the error output of the test more readable when it fails. Also allows removing a "not" from the run line. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227071 91177308-0d34-0410-b5e6-96231b3b80d8
* Mark C++ reference parameters as dereferenceableHal Finkel2014-07-181-2/+2
| | | | | | | | | | | | | | Because references must be initialized using some evaluated expression, they must point to something, and a callee can assume the reference parameter is dereferenceable. Taking advantage of a new attribute just added to LLVM, mark them as such. Because dereferenceability in addrspace(0) implies nonnull in the backend, we don't need both attributes. However, we need to know the size of the object to use the dereferenceable attribute, so for incomplete types we still emit only nonnull. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213386 91177308-0d34-0410-b5e6-96231b3b80d8
* Add 'nonnull' parameter or return attribute when producing an llvm pointer ↵Nick Lewycky2014-05-281-2/+2
| | | | | | type in a function type where the C++ type is a reference. Update the tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209723 91177308-0d34-0410-b5e6-96231b3b80d8
* AST: Update reference temporary manglingDavid Majnemer2014-05-061-8/+8
| | | | | | | | | | | | | | | Summary: Update our mangling to match the discussion on cxx-abi-dev. This involves using a seq-id instead of an optional number. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3631 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208140 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: Reference temporaries inherit visibilityDavid Majnemer2014-04-291-0/+12
| | | | | | | Reference temporaries inherited many properties from the variable that they correspond to but visibility wasn't one of them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207496 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: Fix linkage of reference temporariesDavid Majnemer2014-04-281-0/+22
| | | | | | | | | | | | | | | Summary: A reference temporary should inherit the linkage of the variable it initializes. Otherwise, we may hit cases where a reference temporary wouldn't have the same value in all translation units. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3515 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207451 91177308-0d34-0410-b5e6-96231b3b80d8
* Add 'not' to commands that are expected to fail.Rafael Espindola2013-07-041-1/+1
| | | | | | | This is at least good documentation, but also opens the possibility of using pipefail. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185652 91177308-0d34-0410-b5e6-96231b3b80d8
* Recursively lifetime-extend into array temporaries. These can get implicitlyRichard Smith2013-06-081-0/+11
| | | | | | | created through binding a reference-to-array to an initializer list. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183594 91177308-0d34-0410-b5e6-96231b3b80d8
* Model temporary lifetime-extension explicitly in the AST. Use this model toRichard Smith2013-06-051-5/+54
| | | | | | | | | | handle temporaries which have been lifetime-extended to static storage duration within constant expressions. This correctly handles nested lifetime extension (through reference members of aggregates in aggregate initializers) but non-constant-expression emission hasn't yet been updated to do the same. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183283 91177308-0d34-0410-b5e6-96231b3b80d8
* PR12848: When emitting a local variable declared 'constexpr', always ↵Richard Smith2013-06-021-0/+38
| | | | | | initialize it with a store or a memcpy, not by emitting the initializer expression. This is not required for correctness, but more closely aligns with people's expectations, and is cheap (since we've already evaluated the initializer). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183082 91177308-0d34-0410-b5e6-96231b3b80d8
* DR1472: A reference isn't odr-used if it has preceding initialization,Richard Smith2012-10-201-5/+1
| | | | | | | | | | initialized by a reference constant expression. Our odr-use modeling still needs work here: we don't yet implement the 'set of potential results of an expression' DR. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166361 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach Expr::HasSideEffects about all the Expr types, and fix a bug where itRichard Smith2012-08-071-2/+2
| | | | | | | | | | | | | | | | | | | | was mistakenly classifying dynamic_casts which might throw as having no side effects. Switch it from a visitor to a switch, so it is kept up-to-date as future Expr nodes are added. Move it from ExprConstant.cpp to Expr.cpp, since it's not really related to constant expression evaluation. Since we use HasSideEffect to determine whether to emit an unused global with internal linkage, this has the effect of suppressing emission of globals in some cases. I've left many of the Objective-C cases conservatively assuming that the expression has side-effects. I'll leave it to someone with better knowledge of Objective-C than mine to improve them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161388 91177308-0d34-0410-b5e6-96231b3b80d8
* PR13290: Constant-evaluation support for CXXConstructExprs which construct aRichard Smith2012-07-071-0/+7
| | | | | | | | | multidimensional array of class type. Also, preserve zero-initialization when evaluating an initializer list for an array, in case the initializers refer to later elements (which have preceding zero-initialization). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159904 91177308-0d34-0410-b5e6-96231b3b80d8
* PR13273: When performing list-initialization with an empty initializer list,Richard Smith2012-07-051-0/+14
| | | | | | | | | | | | actually perform value initialization rather than trying to fake it with a call to the default constructor. Fixes various bugs related to the previously-missing zero-initialization in this case. I've also moved this and the other list initialization 'special case' from TryConstructorInitialization into TryListInitialization where they belong. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159733 91177308-0d34-0410-b5e6-96231b3b80d8
* A union can have a constexpr defaulted default constructor, if it has anRichard Smith2012-05-071-0/+11
| | | | | | | | | | in-class initializer for one of its fields. Value-initialization of such a type should use the in-class initializer! The former was just a bug, the latter is a (reported) standard defect. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156274 91177308-0d34-0410-b5e6-96231b3b80d8
* PR12226: don't generate wrong code if a braced string literal is used toRichard Smith2012-04-151-0/+3
| | | | | | | | | | initialize an array of unsigned char. Outside C++11 mode, this bug was benign, and just resulted in us emitting a constant which was double the required length, padded with 0s. In C++11, it resulted in us generating an array whose first element was something like i8 ptrtoint ([n x i8]* @str to i8). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154756 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't forget to evaluate the subexpression in a null pointer cast. If we'reRichard Smith2012-04-081-0/+9
| | | | | | | converting from std::nullptr_t, the subexpression might have side-effects. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154278 91177308-0d34-0410-b5e6-96231b3b80d8
* ConstStructBuilder: fix offset math for base classes so it works correctly ↵Eli Friedman2012-03-301-0/+5
| | | | | | in general. Found by inspection. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153720 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't even try to directly emit the value of a DeclRefExpr if that declarationRichard Smith2012-03-071-1/+1
| | | | | | | is not usable in a constant expression. ~2.5% speedup on 403.gcc / combine.c. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152193 91177308-0d34-0410-b5e6-96231b3b80d8
* Reinstate r151879, r151880, reverted in r151922, along with a bugfix forRichard Smith2012-03-021-0/+72
| | | | | | | | | | scalar emission of DeclRefExprs to const bools: emit scalar bools as i1, not as i8. In addition to the extra unit testing, this has successfully bootstrapped. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151955 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r151879, r151880, "PR12145: Avoid emitting loads of constexpr ↵Daniel Dunbar2012-03-021-27/+0
| | | | | | | | variables in contexts where there" and "Fix buildbot: make this test less dependent on the value names in the produced IR." They broke bootstrap. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151922 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix buildbot: make this test less dependent on the value names in the ↵Richard Smith2012-03-021-2/+2
| | | | | | produced IR. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151880 91177308-0d34-0410-b5e6-96231b3b80d8
* PR12145: Avoid emitting loads of constexpr variables in contexts where thereRichard Smith2012-03-021-0/+27
| | | | | | | | is no odr-use of the variable. Go slightly beyond what the standard requires for variables of reference type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151879 91177308-0d34-0410-b5e6-96231b3b80d8
* PR12067: When emitting an evaluated constant structure in C++11 mode, don'tRichard Smith2012-02-231-0/+36
| | | | | | | forget the vptrs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151245 91177308-0d34-0410-b5e6-96231b3b80d8
* When performing IRGen on a global, emit it as a constant if:Richard Smith2012-02-171-8/+8
| | | | | | | | | | | | 1) It has a const-qualified type, and 2) It has no mutable members, and 3) It has no dynamic initialization, and 4) It has trivial destruction. Remove the unnecessary requirement that the type be POD. This allows us to mark all constexpr objects with no mutable members as 'constant'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150792 91177308-0d34-0410-b5e6-96231b3b80d8
* Make sure all remaining parts of the constant evaluator are aware that an arrayRichard Smith2012-02-171-0/+8
| | | | | | | can be represented by an LValue, and use that to simplify the code a little. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150789 91177308-0d34-0410-b5e6-96231b3b80d8
* PR12012: Fix a regression in r150419 where we would try (and fail) toRichard Smith2012-02-171-0/+14
| | | | | | | | zero-initialize class types with virtual bases when constant-evaluating an initializer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150770 91177308-0d34-0410-b5e6-96231b3b80d8
* Deal with a horrible C++11 special case. If a non-literal type has a constexprRichard Smith2012-02-131-0/+84
| | | | | | | | | | | | constructor, and that constructor is used to initialize an object of static storage duration such that all members and bases are initialized by constant expressions, constant initialization is performed. In this case, the object can still have a non-trivial destructor, and if it does, we must emit a dynamic initializer which performs no initialization and instead simply registers that destructor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150419 91177308-0d34-0410-b5e6-96231b3b80d8
* constexpr: Implement the [dcl.constexpr]p5 check for whether a constexprRichard Smith2012-01-271-2/+2
| | | | | | | | function definition can produce a constant expression. This also provides the last few checks for [dcl.constexpr]p3 and [dcl.constexpr]p4. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149108 91177308-0d34-0410-b5e6-96231b3b80d8
* fix to go along with an llvm change: VMCore now returns an UndefValueChris Lattner2012-01-261-1/+1
| | | | | | | when asking for a ConstantStruct with all undef elements. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149025 91177308-0d34-0410-b5e6-96231b3b80d8
* constexpr irgen: Add irgen support for APValue::Struct, APValue::Union,Richard Smith2012-01-141-0/+188
| | | | | | | | | | | | | | | | | | | | | APValue::Array and APValue::MemberPointer. All APValue values can now be emitted as constants. Add new CGCXXABI entry point for emitting an APValue MemberPointer. The other entrypoints dealing with constant member pointers are no longer necessary and will be removed in a later change. Switch codegen from using EvaluateAsRValue/EvaluateAsLValue to VarDecl::evaluateValue. This performs caching and deals with the nasty cases in C++11 where a non-const object's initializer can refer indirectly to previously-initialized fields within the same object. Building the intermediate APValue object incurs a measurable performance hit on pathological testcases with huge initializer lists, so we continue to build IR directly from the Expr nodes for array and record types outside of C++11. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148178 91177308-0d34-0410-b5e6-96231b3b80d8
* Address Richard's review comments on r147561 (Evaluate support for ↵Eli Friedman2012-01-051-0/+9
address-of-label differences). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147631 91177308-0d34-0410-b5e6-96231b3b80d8