summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/const-init-cxx11.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [opaque pointer types] Cleanup CGBuilder's Create*GEP.James Y Knight2019-02-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Some of these functions take some extraneous arguments, e.g. EltSize, Offset, which are computable from the Type and DataLayout. Add some asserts to ensure that the computed values are consistent with the passed-in values, in preparation for eliminating the extraneous arguments. This also asserts that the Type is an Array for the calls named "Array" and a Struct for the calls named "Struct". Then, correct a couple of errors: 1. Using CreateStructGEP on an array type. (this causes the majority of the test differences, as struct GEPs are created with i32 indices, while array GEPs are created with i64 indices) 2. Passing the wrong Offset to CreateStructGEP in TargetInfo.cpp on x86-64 NACL (which uses 32-bit pointers). Differential Revision: https://reviews.llvm.org/D57766 llvm-svn: 353529
* CGDecl::emitStoresForConstant fix synthesized constant's nameJF Bastien2018-11-151-2/+2
| | | | | | | | | | | | Summary: The name of the synthesized constants for constant initialization was using mangling for statics, which isn't generally correct and (in a yet-uncommitted patch) causes the mangler to assert out because the static ends up trying to mangle function parameters and this makes no sense. Instead, mangle to `"__const." + FunctionName + "." + DeclName`. Reviewers: rjmccall Subscribers: dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D54055 llvm-svn: 346915
* 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 llvm-svn: 329300
* 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 llvm-svn: 289585
* 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 llvm-svn: 289584
* 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 llvm-svn: 263469
* 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.) llvm-svn: 245497
* Test case updates for explicit type parameter to the gep operatorDavid Blaikie2015-03-131-5/+5
| | | | llvm-svn: 232187
* Update Clang tests to handle explicitly typed load changes in LLVM.David Blaikie2015-02-271-1/+1
| | | | llvm-svn: 230795
* CodeGen: Weak reference temporaries belong in a COMDATDavid Majnemer2015-02-191-4/+4
| | | | llvm-svn: 229902
* 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. llvm-svn: 229900
* 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.) llvm-svn: 227072
* 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. llvm-svn: 227071
* 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. llvm-svn: 213386
* 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. llvm-svn: 209723
* 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 llvm-svn: 208140
* 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. llvm-svn: 207496
* 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 llvm-svn: 207451
* 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. llvm-svn: 185652
* 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. llvm-svn: 183594
* 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. llvm-svn: 183283
* 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). llvm-svn: 183082
* 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. llvm-svn: 166361
* 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. llvm-svn: 161388
* 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). llvm-svn: 159904
* 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. llvm-svn: 159733
* 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. llvm-svn: 156274
* 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). llvm-svn: 154756
* 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. llvm-svn: 154278
* ConstStructBuilder: fix offset math for base classes so it works correctly ↵Eli Friedman2012-03-301-0/+5
| | | | | | in general. Found by inspection. llvm-svn: 153720
* 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. llvm-svn: 152193
* 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. llvm-svn: 151955
* 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. llvm-svn: 151922
* Fix buildbot: make this test less dependent on the value names in the ↵Richard Smith2012-03-021-2/+2
| | | | | | produced IR. llvm-svn: 151880
* 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. llvm-svn: 151879
* PR12067: When emitting an evaluated constant structure in C++11 mode, don'tRichard Smith2012-02-231-0/+36
| | | | | | forget the vptrs. llvm-svn: 151245
* 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'. llvm-svn: 150792
* 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. llvm-svn: 150789
* 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. llvm-svn: 150770
* 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. llvm-svn: 150419
* 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. llvm-svn: 149108
* 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. llvm-svn: 149025
* 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. llvm-svn: 148178
* Address Richard's review comments on r147561 (Evaluate support for ↵Eli Friedman2012-01-051-0/+9
address-of-label differences). llvm-svn: 147631
OpenPOWER on IntegriCloud