summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/global-init.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibilityReid Kleckner2017-02-131-1/+1
| | | | | | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=31932 Based on a patch by Roland McGrath Reviewed By: phosek Differential Revision: https://reviews.llvm.org/D29843 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294978 91177308-0d34-0410-b5e6-96231b3b80d8
* Cleanup the handling of noinline function attributes, -fno-inline,Chandler Carruth2016-12-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -fno-inline-functions, -O0, and optnone. These were really, really tangled together: - We used the noinline LLVM attribute for -fno-inline - But not for -fno-inline-functions (breaking LTO) - But we did use it for -finline-hint-functions (yay, LTO is happy!) - But we didn't for -O0 (LTO is sad yet again...) - We had weird structuring of CodeGenOpts with both an inlining enumeration and a boolean. They interacted in weird ways and needlessly. - A *lot* of set smashing went on with setting these, and then got worse when we considered optnone and other inlining-effecting attributes. - A bunch of inline affecting attributes were managed in a completely different place from -fno-inline. - Even with -fno-inline we failed to put the LLVM noinline attribute onto many generated function definitions because they didn't show up as AST-level functions. - If you passed -O0 but -finline-functions we would run the normal inliner pass in LLVM despite it being in the O0 pipeline, which really doesn't make much sense. - Lastly, we used things like '-fno-inline' to manipulate the pass pipeline which forced the pass pipeline to be much more parameterizable than it really needs to be. Instead we can *just* use the optimization level to select a pipeline and control the rest via attributes. Sadly, this causes a bunch of churn in tests because we don't run the optimizer in the tests and check the contents of attribute sets. It would be awesome if attribute sets were a bit more FileCheck friendly, but oh well. I think this is a significant improvement and should remove the semantic need to change what inliner pass we run in order to comply with the requested inlining semantics by relying completely on attributes. It also cleans up tho optnone and related handling a bit. One unfortunate aspect of this is that for generating alwaysinline routines like those in OpenMP we end up removing noinline and then adding alwaysinline. I tried a bunch of other approaches, but because we recompute function attributes from scratch and don't have a declaration here I couldn't find anything substantially cleaner than this. Differential Revision: https://reviews.llvm.org/D28053 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290398 91177308-0d34-0410-b5e6-96231b3b80d8
* Add the alloc_size attribute to clang, attempt 2.George Burgess IV2016-12-221-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a recommit of r290149, which was reverted in r290169 due to msan failures. msan was failing because we were calling `isMostDerivedAnUnsizedArray` on an invalid designator, which caused us to read uninitialized memory. To fix this, the logic of the caller of said function was simplified, and we now have a `!Invalid` assert in `isMostDerivedAnUnsizedArray`, so we can catch this particular bug more easily in the future. Fingers crossed that this patch sticks this time. :) Original commit message: This patch does three things: - Gives us the alloc_size attribute in clang, which lets us infer the number of bytes handed back to us by malloc/realloc/calloc/any user functions that act in a similar manner. - Teaches our constexpr evaluator that evaluating some `const` variables is OK sometimes. This is why we have a change in test/SemaCXX/constant-expression-cxx11.cpp and other seemingly unrelated tests. Richard Smith okay'ed this idea some time ago in person. - Uniques some Blocks in CodeGen, which was reviewed separately at D26410. Lack of uniquing only really shows up as a problem when combined with our new eagerness in the face of const. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290297 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix defaulted-functions-in-C++98 extension to give the functions the sameRichard Smith2016-12-211-0/+2
| | | | | | | | | effect they would have in C++11. In particular, they do not prevent value-initialization from performing zero-initialization, nor do they prevent a struct from being an aggregate. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290229 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r290149: Add the alloc_size attribute to clang.Chandler Carruth2016-12-201-0/+3
| | | | | | | | | | | | | | | This commit fails MSan when running test/CodeGen/object-size.c in a confusing way. After some discussion with George, it isn't really clear what is going on here. We can make the MSan failure go away by testing for the invalid bit, but *why* things are invalid isn't clear. And yet, other code in the surrounding area is doing precisely this and testing for invalid. George is going to take a closer look at this to better understand the nature of the failure and recommit it, for now backing it out to clean up MSan builds. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290169 91177308-0d34-0410-b5e6-96231b3b80d8
* Add the alloc_size attribute to clang.George Burgess IV2016-12-201-3/+0
| | | | | | | | | | | | | | | | | | | | | This patch does three things: - Gives us the alloc_size attribute in clang, which lets us infer the number of bytes handed back to us by malloc/realloc/calloc/any user functions that act in a similar manner. - Teaches our constexpr evaluator that evaluating some `const` variables is OK sometimes. This is why we have a change in test/SemaCXX/constant-expression-cxx11.cpp and other seemingly unrelated tests. Richard Smith okay'ed this idea some time ago in person. - Uniques some Blocks in CodeGen, which was reviewed separately at D26410. Lack of uniquing only really shows up as a problem when combined with our new eagerness in the face of const. Differential Revision: https://reviews.llvm.org/D14274 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290149 91177308-0d34-0410-b5e6-96231b3b80d8
* Undo accidental comitPaul Robinson2016-12-191-10/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290121 91177308-0d34-0410-b5e6-96231b3b80d8
* Make a few OpenMP tests "C++11 clean."Paul Robinson2016-12-191-4/+10
| | | | | | | | Reviewed by abataev (in D27794) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290120 91177308-0d34-0410-b5e6-96231b3b80d8
* Set normal LLVM function attributes on global initializer functionsReid Kleckner2015-04-221-2/+9
| | | | | | | | | | | Otherwise -fno-omit-frame-pointer and other flags like it aren't applied. Basic idea taken from Gao's patch, thanks! Differential Revision: http://reviews.llvm.org/D9203 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235537 91177308-0d34-0410-b5e6-96231b3b80d8
* Test case updates for explicit type parameter to the gep operatorDavid Blaikie2015-03-131-6/+6
| | | | 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-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230795 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't set unnamed_addr in CreateRuntimeVariable.Rafael Espindola2014-05-221-1/+1
| | | | | | | | | | | | | This was fairly broken. For example, @__dso_handle would or would not get an unnamed_addr depending on how many global destructors were used in a translation unit. The consensus was that not every runtime variable is unnamed_addr and that __dso_handle handle should not be, so just don't add unnamed_addr in CreateRuntimeVariable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209484 91177308-0d34-0410-b5e6-96231b3b80d8
* Include translation unit filename in global ctor symbol names.Nico Weber2014-05-061-2/+2
| | | | | | | | | | | | | | | | | | | This makes it easier to see where a global ctor comes from, and it also makes ASan's init order analyzer output easier to understand. gcc does this too, but only in -fPIC mode for some reason. Don't do this for constructors with explicit init priority. Also prepend "sub_" before the 'I', that way regular constructors stay lexicographically after symbols with init priority (because ord('s') > ord('I')). gold seems to ignore the name of constructor symbols, and ld only looks at the symbol if it includes an init priority, which this patch doesn't change. Before: __GLOBAL_I_a Now: __GLOBAL_sub_I_myfile.cc git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208128 91177308-0d34-0410-b5e6-96231b3b80d8
* CHECK-LABEL-ify some code gen tests to improve diagnostic experience when ↵Stephen Lin2013-08-151-1/+1
| | | | | | tests fail. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188447 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix FileCheck --check-prefix lines.Tim Northover2013-08-121-1/+1
| | | | | | | | | | Various tests had sprung up over the years which had --check-prefix=ABC on the RUN line, but "CHECK-ABC:" later on. This happened to work before, but was strictly incorrect. FileCheck is getting stricter soon though. Patch by Ron Ofir. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188174 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r176133 with testcase fixes.Bill Wendling2013-02-271-12/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176145 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Add more attributes from the command line to functions."Anna Zaks2013-02-251-3/+12
| | | | | | | | This reverts commit 176009. The commit is a likely cause of several buildbot failures. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176044 91177308-0d34-0410-b5e6-96231b3b80d8
* Add more attributes from the command line to functions.Bill Wendling2013-02-251-12/+3
| | | | | | | | This is an ongoing process. Any command line option which a back-end cares about should be added here. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176009 91177308-0d34-0410-b5e6-96231b3b80d8
* Modify the tests to use attribute group references instead of listing theBill Wendling2013-02-201-1/+12
| | | | | | | function attributes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175606 91177308-0d34-0410-b5e6-96231b3b80d8
* Update documentation of HasSideEffects to match its callers' expectations, andRichard Smith2012-08-071-3/+15
| | | | | | | | | | | | | update implementation to match. An elidable, non-trivial constructor call is a side-effect under this definition, but wasn't under the old one, because we are not required to evaluate it even though it may have an effect. Also rationalize checking for volatile reads: just look for lvalue-to-rvalue conversions on volatile glvalues, and ignore whether a DeclRefExpr etc is for a volatile variable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161393 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach Expr::HasSideEffects about all the Expr types, and fix a bug where itRichard Smith2012-08-071-13/+82
| | | | | | | | | | | | | | | | | | | | 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
* Use atexit when __cxa_atexit isn't available instead of adding aJohn McCall2012-04-061-4/+4
| | | | | | | | | global destructor entry. For some reason this isn't enabled for apple-kexts; it'd be good to have documentation for that. Based on a patch by Nakamura Takumi! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154191 91177308-0d34-0410-b5e6-96231b3b80d8
* clang side to match the LLVM IR type system rewrite patch.Chris Lattner2011-07-091-4/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134831 91177308-0d34-0410-b5e6-96231b3b80d8
* Emit guard variables for any weak global that has a run-timeDouglas Gregor2011-07-011-9/+14
| | | | | | | | initializer. Previously, we only used guard variables for weak static data members. Fixes <rdar://problem/9692249>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134266 91177308-0d34-0410-b5e6-96231b3b80d8
* When laying out bases in, always try the "base subobject" LLVM type. If itAnders Carlsson2011-04-171-2/+2
| | | | | | | | | | | | | | | turns out that a field or base needs to be laid out in the tail padding of the base, CGRecordLayoutBuilder::ResizeLastBaseFieldIfNecessary will convert it to an array of i8. I've audited the new test results to make sure that they are still valid. I've also verified that we pass a self-host with this change. This (finally) fixes PR5589! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129673 91177308-0d34-0410-b5e6-96231b3b80d8
* Template static data members can have weak_odr linkage, not justJohn McCall2011-04-121-0/+10
| | | | | | | | | | weak linkage. Also, fix a problem where global weak variables with non-trivial initializers were getting guard variables, or at least were checking for them and then crashing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129342 91177308-0d34-0410-b5e6-96231b3b80d8
* Whoops.John McCall2011-04-121-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129341 91177308-0d34-0410-b5e6-96231b3b80d8
* Ignore indirect field declarations. Fixes PR9570.John McCall2011-04-121-0/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129337 91177308-0d34-0410-b5e6-96231b3b80d8
* Add unnamed_addr in CreateRuntimeVariable.Rafael Espindola2011-01-181-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123773 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach the constant expr evaluator about derived-to-base casts when no ↵Anders Carlsson2010-10-311-0/+16
| | | | | | virtual bases are involved. Fixes PR5974. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117868 91177308-0d34-0410-b5e6-96231b3b80d8
* Test for rdar://problem/8073696.John McCall2010-08-121-0/+11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110907 91177308-0d34-0410-b5e6-96231b3b80d8
* Do a very simple pass over every function we emit to infer whether we canJohn McCall2010-08-031-1/+1
| | | | | | | | | mark it nounwind based on whether it contains any non-nounwind calls. <rdar://problem/8087431> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110163 91177308-0d34-0410-b5e6-96231b3b80d8
* Emit global destructors even if the destroyed object has no initializers or hasJohn McCall2010-07-301-2/+17
| | | | | | | | | | an initializer requiring temporary object disposal. Fixes rdar:://problem/8246444. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109849 91177308-0d34-0410-b5e6-96231b3b80d8
* When deferring the emission of declarations with initializers in C++, rememberJohn McCall2010-07-151-0/+22
| | | | | | | | | 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
* When creating functions to run global initializers and destructors, mark themJohn McCall2010-07-061-1/+4
| | | | | | | | as nounwind in -fno-exceptions. Fixes rdar://problem/8090834. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107639 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix test.Anders Carlsson2010-06-091-1/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105668 91177308-0d34-0410-b5e6-96231b3b80d8
* C++: Add support for -fno-use-cxa-atexit.Daniel Dunbar2010-03-201-1/+1
| | | | | | | | - So much typing, so little gain... Also, rename the __cxx_global_initialization function just to match llvm-gcc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99039 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the bug that was breaking self-host, and re-land the static ctor fixes.Anders Carlsson2010-02-051-0/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95400 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r95363 and r95375, which broke self-host.Douglas Gregor2010-02-051-5/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95389 91177308-0d34-0410-b5e6-96231b3b80d8
* If a global initializer has a non-trivial destructor it can't be emitted as ↵Anders Carlsson2010-02-051-0/+5
| | | | | | a constant (even if it has a trivial constructor). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95363 91177308-0d34-0410-b5e6-96231b3b80d8
* Codegen CXXConstructExprs with trivial constructors as constants.John McCall2010-02-021-0/+10
| | | | | | | | Eliminates a lot of spurious global initializers, fixing PR6205. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95077 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
* If a global initializer has a non-trivial constructor or destructor, we ↵Anders Carlsson2009-10-081-2/+8
| | | | | | | | | | | | | | | | | | | | | never want to defer generation of it, even if it is declared static. With this change we're finally able to compile and run the (infamous) #include <string> #include <iostream> int main(int argc, char **argv) { std::cout << "Hello, World" << std::endl; } $ clang hello.cpp -lstdc++ -o hello $ ./hello Hello, World git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83559 91177308-0d34-0410-b5e6-96231b3b80d8
* Port test over to FileCheck.Anders Carlsson2009-10-081-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83558 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the inbounds variant of getelementptr for common pointer arithmetic.Dan Gohman2009-08-121-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78756 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for global initializers.Anders Carlsson2009-08-081-0/+10
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78515 91177308-0d34-0410-b5e6-96231b3b80d8