summaryrefslogtreecommitdiffstats
path: root/test/CodeGen/const-init.c
Commit message (Collapse)AuthorAgeFilesLines
* [CodeGen] Always use string computed in Sema for PredefinedExprEli Friedman2019-01-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | We can't use any other string, anyway, because its type wouldn't match the type of the PredefinedExpr. With this change, we don't compute a "nice" name for the __func__ global when it's used in the initializer for a constant. This doesn't seem like a great loss, and I'm not sure how to fix it without either storing more information in the AST, or somehow threading through the information from ExprConstant.cpp. This could break some situations involving BlockDecl; currently, CodeGenFunction::EmitPredefinedLValue has some logic to intentionally emit a string different from what Sema computed. This code skips that logic... but that logic can't work correctly in general anyway. (For example, sizeof(__func__) returns the wrong result.) Hopefully this doesn't affect practical code. Fixes https://bugs.llvm.org/show_bug.cgi?id=40313 . Differential Revision: https://reviews.llvm.org/D56821 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351766 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r332847; it caused us to miscompile certain forms of reference ↵Richard Smith2018-05-211-1/+1
| | | | | | initialization. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332886 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Recognize more cases of zero initializationSerge Pavlov2018-05-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | If a variable has an initializer, codegen tries to build its value. If the variable is large in size, building its value requires substantial resources. It causes strange behavior from user viewpoint: compilation of huge zero initialized arrays like: char data_1[2147483648u] = { 0 }; consumes enormous amount of time and memory. With this change codegen tries to determine if variable initializer is equivalent to zero initializer. In this case variable value is not constructed. This change fixes PR18978. Differential Revision: https://reviews.llvm.org/D46241 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332847 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Use pointer-sized integers for ptrtoint sourcesDavid Majnemer2016-06-171-1/+1
| | | | | | | | | | | | | | | | | Given something like: void *v = (void *)100; We need to synthesize a ptrtoint operation from 100. During constant emission, we choose i64 as the type for our constant because it guaranteed not to drop any bits from our CharUnits representation of the value. However, this is suboptimal for 32-bit targets: LLVM passes like GlobalOpt will get confused by these sorts of casts resulting in pessimization. Instead, make sure the ptrtoint operand has a pointer-sized integer type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273020 91177308-0d34-0410-b5e6-96231b3b80d8
* Test case updates for explicit type parameter to the gep operatorDavid Blaikie2015-03-131-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232187 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: ConstStructBuilder must verify packed constraints after paddingDavid Majnemer2014-10-191-0/+22
| | | | | | | | | | | | | | | | | | This reverts commit r220169 which reverted r220153. However, it also contains additional changes: - We may need to add padding *after* we've packed the struct. This occurs when the aligned next field offset is greater than the new field's offset. When this occurs, we make the struct packed. *However*, once packed the next field offset might be less than the new feild's offset. It is in this case that we might further pad the struct. - We would pad structs which were perfectly sized! This behavior is immensely old. This behavior came from blindly subtracting NextFieldOffsetInChars from RecordSize. This doesn't take into account the fact that the struct might have a greater overall alignment than the last field. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220175 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r220153: "CodeGen: ConstStructBuilder must verify packed constraints ↵Chandler Carruth2014-10-191-11/+0
| | | | | | | | | | after padding" This commit caused two tests in LNT to regress. I'm able to reproduce on any platform and will send reproduction steps to the original commit log. This should restore the LNT bots that have been failing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220169 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: ConstStructBuilder must verify packed constraints after paddingDavid Majnemer2014-10-191-0/+11
| | | | | | | | | | | | Before, ConstStructBuilder::AppendBytes would check packed constraints prior to padding being added before the field's offset. However, adding this padding might force our struct to be packed. Because we wouldn't check *after* adding padding, ConstStructBuilder would be in an inconsistent state leading to a crash. This fixes PR21300. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220153 91177308-0d34-0410-b5e6-96231b3b80d8
* Add missing expected-warning.Rafael Espindola2013-07-041-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185644 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix InitListExpr::isStringLiteralInit so it handles various edge cases ↵Eli Friedman2012-08-201-0/+15
| | | | | | correctly. PR13643. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162226 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for bitcasts to vector type in Evaluate.Eli Friedman2011-12-221-0/+12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147137 91177308-0d34-0410-b5e6-96231b3b80d8
* fix an unintended behavior change in the type system rewrite, which caused ↵Chris Lattner2011-07-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | us to compile stuff like this: typedef struct { int x, y, z; } foo_t; foo_t g; into: %"struct.<anonymous>" = type { i32, i32, i32 } we now get: %struct.foo_t = type { i32, i32, i32 } This doesn't change the behavior of the compiler, but makes the IR much easier to read. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134969 91177308-0d34-0410-b5e6-96231b3b80d8
* clang side to match the LLVM IR type system rewrite patch.Chris Lattner2011-07-091-10/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134831 91177308-0d34-0410-b5e6-96231b3b80d8
* Update to match mainline ConstantStruct::get API change. Also, use Chris Lattner2011-06-201-2/+2
| | | | | | | | | | | | | ConvertType on InitListExprs as they are being converted. This is needed for a forthcoming patch, and improves the IR generated anyway (see additional type names in testcases). This patch also converts a bunch of std::vector's in CGObjCMac to use C arrays. There are a ton more that should be converted as well. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133413 91177308-0d34-0410-b5e6-96231b3b80d8
* Only emit string initializers in-place if types match. Fixes PR9373.Benjamin Kramer2011-03-021-0/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126883 91177308-0d34-0410-b5e6-96231b3b80d8
* Add unnamed_addr when creating artificial string globals. For example, inRafael Espindola2011-01-101-1/+1
| | | | | | | | | static const char foo[] = "foo"; static const char *bar = "bar"; the global created to hold "bar" will have it, but foo will not. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123192 91177308-0d34-0410-b5e6-96231b3b80d8
* A constant initializer never matches the type of the variable it'sJohn McCall2010-09-031-1/+6
| | | | | | | | | 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
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-1/+1
| | | | | | | | | - This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91446 91177308-0d34-0410-b5e6-96231b3b80d8
* Use intptr_t from stdint.h (in freestanding mode) instead of redefining it hereKen Dyck2009-11-221-2/+2
| | | | | | | with __INTPTR_TYPE__. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89609 91177308-0d34-0410-b5e6-96231b3b80d8
* Make __func__ and friends work correctly within the initializer for a staticEli Friedman2009-11-141-0/+6
| | | | | | | | local variable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88766 91177308-0d34-0410-b5e6-96231b3b80d8
* Obvious fix for PR5474.Eli Friedman2009-11-131-0/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88696 91177308-0d34-0410-b5e6-96231b3b80d8
* Removed math.h include, as Windows math.h has a compile error.John Thompson2009-10-151-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84160 91177308-0d34-0410-b5e6-96231b3b80d8
* In VC++, the *printf functions put an extra "0" in the exponent partMike Stump2009-10-081-5/+5
| | | | | | | | of a floating point number. This add regular expressions to account for this. Patch by John Thompson. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83581 91177308-0d34-0410-b5e6-96231b3b80d8
* FileCheckize test case.Benjamin Kramer2009-10-021-26/+22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83244 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't update the struct alignment when adding fields to a packed struct. ↵Anders Carlsson2009-10-021-3/+10
| | | | | | Fixes PR5118. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83235 91177308-0d34-0410-b5e6-96231b3b80d8
* When building constant structs, check if the resulting LLVM struct will be ↵Anders Carlsson2009-10-021-1/+7
| | | | | | bigger than the record layout size and use a packed struct if that's the case. Fixes PR5108. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83230 91177308-0d34-0410-b5e6-96231b3b80d8
* Update this test to expect the "inbounds" keyword, which LLVM's constantDan Gohman2009-09-111-1/+1
| | | | | | | folder is now automatically adding. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81491 91177308-0d34-0410-b5e6-96231b3b80d8
* Enable the new struct type builder now that the constant struct builder ↵Anders Carlsson2009-07-271-2/+2
| | | | | | works. (The old code will still be there until we know that everything works well. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77190 91177308-0d34-0410-b5e6-96231b3b80d8
* Enable the new constant struct builder by default. The old code is still in ↵Anders Carlsson2009-07-271-2/+2
| | | | | | place but will be removed shortly. The new struct builder works on big endian systems. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77185 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the -arch option from clang-cc: for all practical purposes, it's Eli Friedman2009-05-191-1/+1
| | | | | | | | redundant with -triple. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72108 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix for PR4108: be a bit looser with the casts that we accept in Eli Friedman2009-04-301-0/+5
| | | | | | | | constant initializers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70483 91177308-0d34-0410-b5e6-96231b3b80d8
* Move where block-related variables are initialized so that block Eli Friedman2009-03-281-2/+2
| | | | | | | | types don't get generated when blocks aren't used. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67898 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | | Tests and drivers updated, still need to shuffle dirs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67602 91177308-0d34-0410-b5e6-96231b3b80d8
* adjust to changes in the mainline llvm .ll printer.Chris Lattner2009-03-011-6/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65745 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow constant initializers to reference their defining decl.Daniel Dunbar2009-02-251-0/+11
| | | | | | | - PR3662. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65472 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove a FIXME; I was mistaken in believing gcc rejected this.Daniel Dunbar2009-02-251-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65420 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix IRgen of constant expressions referring to external/staticDaniel Dunbar2009-02-241-0/+7
| | | | | | | | variables. - PR3657. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65381 91177308-0d34-0410-b5e6-96231b3b80d8
* Cleanp code with some recent suggestions.Mike Stump2009-02-221-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65285 91177308-0d34-0410-b5e6-96231b3b80d8
* Force arch for these test cases.Daniel Dunbar2009-02-211-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65252 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle constant int -> ptr casts of lvalue results.Daniel Dunbar2009-02-201-0/+3
| | | | | | | - PR3463 (again). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65133 91177308-0d34-0410-b5e6-96231b3b80d8
* Extend Evaluate() to fold (int) <pointer type>.Daniel Dunbar2009-02-191-0/+28
| | | | | | | | | | | - PR3463, PR3398, <rdar://problem/6553401> crash on relocatable symbol addresses as constants in static locals. - There are many more scenarious we could handle (like arithmetic on such an int) but this is the main use case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65074 91177308-0d34-0410-b5e6-96231b3b80d8
* Evaluate ==,!= for complex types.Daniel Dunbar2009-01-291-3/+28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63280 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement basic _Complex integer constant folding.Daniel Dunbar2009-01-281-0/+3
| | | | | | | | - Merged into single ComplexEvaluator, these share too much logic to be worth splitting for float/int (IMHO). Will split on request. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63248 91177308-0d34-0410-b5e6-96231b3b80d8
* Add test for PR2992.Anders Carlsson2008-11-221-0/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59861 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix const-init test caseDaniel Dunbar2008-08-051-3/+3
| | | | | | | | - Use -verify and added expected warnings for EXTWARN change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54342 91177308-0d34-0410-b5e6-96231b3b80d8
* Add codegen support for a few more kinds of initializer constant Eli Friedman2008-05-291-1/+3
| | | | | | | | expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51677 91177308-0d34-0410-b5e6-96231b3b80d8
* Some const initializer tests for stuff I just committed.Eli Friedman2008-02-211-0/+13
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47442 91177308-0d34-0410-b5e6-96231b3b80d8