summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/microsoft-abi-static-initializers.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert "[CodeGenCXX] Treat 'this' as noalias in constructors"Sean Fertile2018-10-151-1/+1
| | | | | | | This reverts commit https://reviews.llvm.org/rL344150 which causes MachineOutliner related failures on the ppc64le multistage buildbot. llvm-svn: 344526
* [CodeGenCXX] Treat 'this' as noalias in constructorsAnton Bikineev2018-10-101-1/+1
| | | | | | | | | This is currently a clang extension and a resolution of the defect report in the C++ Standard. Differential Revision: https://reviews.llvm.org/D46441 llvm-svn: 344150
* [MS ABI] Fix mangling issue with dynamic initializer stubs.Zachary Turner2018-08-301-5/+5
| | | | | | | | | | | | | | | | | | | | There are two types of dynamic initializer stubs. There's `dynamic initializer for 'x''(void) and `dynamic initializer for `static Foo::Bar StaticDataMember''(void) The second case is disambiguated from the first by the presence of a ? after the operator code. So the first will appear something like ?__E<name> while the second will appear something like ?__E?<name>. clang-cl was mangling these both the same though. This patch matches behavior with cl. Differential Revision: https://reviews.llvm.org/D51500 llvm-svn: 341117
* [MS] Don't escape MS C++ names with \01Reid Kleckner2018-03-161-49/+49
| | | | | | | It is not needed after LLVM r327734. Now it will be easier to copy-paste IR symbol names from Clang. llvm-svn: 327738
* Bring r325915 back.Rafael Espindola2018-02-231-11/+11
| | | | | | | | | | | | | | | The tests that failed on a windows host have been fixed. Original message: Start setting dso_local for COFF. With this there are still some GVs where we don't set dso_local because setGVProperties is never called. I intend to fix that in followup commits. This is just the bare minimum to teach shouldAssumeDSOLocal what it should do for COFF. llvm-svn: 325940
* Revert "Start setting dso_local for COFF."Rafael Espindola2018-02-231-11/+11
| | | | | | | | This reverts commit r325915. It will take some time to fix the failures on a windows host. llvm-svn: 325929
* Start setting dso_local for COFF.Rafael Espindola2018-02-231-11/+11
| | | | | | | | | With this there are still some GVs where we don't set dso_local because setGVProperties is never called. I intend to fix that in followup commits. This is just the bare minimum to teach shouldAssumeDSOLocal what it should do for COFF. llvm-svn: 325915
* Make internal/private GVs implicitly dso_local.Rafael Espindola2018-01-111-3/+3
| | | | | | | | | | | | | | | | While updating clang tests for having clang set dso_local I noticed that: - There are *a lot* of tests to update. - Many of the updates are redundant. They are redundant because a GV is "obviously dso_local". This patch starts formalizing that a bit by requiring that internal and private GVs be dso_local too. Since they all are, we don't have to print dso_local to the textual representation, making it a bit more compact and easier to read. llvm-svn: 322318
* Add branch weights to branches for static initializers.Richard Smith2017-07-261-1/+1
| | | | | | | | | | | | | | | | | | | The initializer for a static local variable cannot be hot, because it runs at most once per program. That's not quite the same thing as having a low branch probability, but under the assumption that the function is invoked many times, modeling this as a branch probability seems reasonable. For TLS variables, the situation is less clear, since the initialization side of the branch can run multiple times in a program execution, but we still expect initialization to be rare relative to non-initialization uses. It would seem worthwhile to add a PGO counter along this path to make this estimation more accurate in future. For globals with guarded initialization, we don't yet apply any branch weights. Due to our use of COMDATs, the guard will be reached exactly once per DSO, but we have no idea how many DSOs will define the variable. llvm-svn: 309195
* Changed renaming of local symbols by inserting a dot vefore the numeric suffixSunil Srivastava2015-05-121-1/+1
| | | | | | | details in http://reviews.llvm.org/D9483 goes with llvm checkin r237150 llvm-svn: 237151
* [MS ABI] Implement thread-safe initialization using the MSVC 2015 ABIDavid Majnemer2015-05-071-1/+1
| | | | | | | | | The MSVC 2015 ABI utilizes a rather straightforward adaptation of the algorithm found in the appendix of N2382. While we are here, implement support for emitting cleanups if an exception is thrown while we are intitializing a static local variable. llvm-svn: 236697
* Test case updates for explicit type parameter to the gep operatorDavid Blaikie2015-03-131-3/+3
| | | | llvm-svn: 232187
* Update Clang tests to handle explicitly typed load changes in LLVM.David Blaikie2015-02-271-4/+4
| | | | llvm-svn: 230795
* Add comdats to dynamic init functions in the microsoft abi.Rafael Espindola2015-01-161-3/+3
| | | | llvm-svn: 226286
* Make this test a bit stricter. NFC.Rafael Espindola2015-01-161-9/+9
| | | | llvm-svn: 226285
* MS ABI: Use '1' (instead of '0') relative scope discriminatorsDavid Majnemer2014-10-051-4/+4
| | | | | | | | This changes the scope discriminator's behavior to start at '1' instead of '0'. Symbol table diffing, for ABI compatibility testing, kept finding these as false positives. llvm-svn: 219075
* MS ABI: Emit dynamic initializers for selectany globals in ↵Hans Wennborg2014-09-101-6/+20
| | | | | | | | | | comdat-associative sections (PR20889) This prevents initializers for comdat-folded globals from running multiple times. Differential Revision: http://reviews.llvm.org/D5281 llvm-svn: 217534
* 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
* Fix bug in code for avoiding dynamic initialization of dllimport globalsHans Wennborg2014-06-181-0/+18
| | | | | | | | | | | | | When instantiating dllimport variables with dynamic initializers, don't bail out of Sema::InstantiateVariableInitializer without calling PopExpressionEvaluationContext(). This was causing a stale object to stay on the ExprEvalContexts stack, causing subsequent calls to getCurrentMangleNumberContext() to fail, resulting in incorrect numbering of static locals (and probably other broken things). llvm-svn: 211137
* MS static locals mangling: don't double-increment mangling number for switchesHans Wennborg2014-06-171-0/+29
| | | | | | Differential Revision: http://reviews.llvm.org/D4165 llvm-svn: 211079
* MS static locals mangling: don't count enum scopesHans Wennborg2014-06-171-0/+21
| | | | | | | | | | We may not have the mangling for static locals vs. enums completely figured out, but at least for my simple test cases, enums should not increment the mangling number. Differential Revision: http://reviews.llvm.org/D4164 llvm-svn: 211078
* 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
* Use comdats to avoid double initialization of weak dataReid Kleckner2014-05-231-17/+19
| | | | | | | | | | | | | | | | | Initializers of global data that can appear multiple TUs (static data members of class templates or __declspec(selectany) data) are now in a comdat group keyed on the global variable being initialized. On non-Windows platforms, this is a code size and startup time optimization. On Windows, this is necessary for ABI compatibility with MSVC. Fixes PR16959. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D3811 llvm-svn: 209555
* 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 llvm-svn: 208128
* MS ABI: Use a different guard variable for each weak globalReid Kleckner2014-04-231-1/+12
| | | | | | | | | | We were using the same guard variable and failing to initialize the second global. Clang is still not MS ABI compatible in this area. Fixing that is PR16959, which will require LLVM changes to @llvm.global_ctors. llvm-svn: 207008
* MS ABI: Disambiguate the manglings for global guard variablesDavid Majnemer2014-03-061-0/+2
| | | | | | | | | If a guard variable will be created for an entity at global scope, then we cannot rely on the scope depth to disambiguate names for us. Instead, mangle the entire variable into the guard to ensure it's uniqueness. llvm-svn: 203151
* MS ABI: Fix the initializer/finalizer mangling for static data membersDavid Majnemer2014-03-061-4/+4
| | | | | | | Initializers and finalizers for static data members have the variable's access-specifier, storage-class, type and CV-qualifiers mangled in. llvm-svn: 203145
* [-cxx-abi microsoft] Implement local manglings accuratelyDavid Majnemer2014-03-051-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The MSVC ABI appears to mangle the lexical scope into the names of statics. Specifically, a counter is incremented whenever a scope is entered where things can be declared in such a way that an ambiguity can arise. For example, a class scope inside of a class scope doesn't do anything interesting because the nested class cannot collide with another nested class. There are problems with this scheme: - It is unreliable. The counter is only incremented when a previously never encountered scope is entered. There are cases where this will cause ambiguity amongst declarations that have the same name where one was introduced in a deep scope while the other was introduced right after in the previous lexical scope. - It is wasteful. Statements like: {{{{{{{ static int foo = a; }}}}}}} will make the mangling of "foo" larger than it need be because the scope counter has been incremented many times. Because of these problems, and practical implementation concerns. We choose not to implement this scheme if the local static or local type isn't visible. The mangling of these declarations will look very similar but the numbering will make far more sense, this scheme is lifted from the Itanium ABI implementation. Reviewers: rsmith, doug.gregor, rnk, eli.friedman, cdavis5x Reviewed By: rnk CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2953 llvm-svn: 202951
* Remove the -cxx-abi command-line flag.Hans Wennborg2014-01-141-1/+1
| | | | | | | | | | | | | | | This makes the C++ ABI depend entirely on the target: MS ABI for -win32 triples, Itanium otherwise. It's no longer possible to do weird combinations. To be able to run a test with a specific ABI without constraining it to a specific triple, new substitutions are added to lit: %itanium_abi_triple and %ms_abi_triple can be used to get the current target triple adjusted to the desired ABI. For example, if the test suite is running with the i686-pc-win32 target, %itanium_abi_triple will expand to i686-pc-mingw32. Differential Revision: http://llvm-reviews.chandlerc.com/D2545 llvm-svn: 199250
* Add -mconstructor aliases to some tests.Rafael Espindola2013-11-091-1/+1
| | | | | | | | clang-cl adds these, so this makes the tests a bit more realistic. These are the tests where it would make a difference if the windows specific handling were removed. llvm-svn: 194336
* [ms-cxxabi] Mangle dynamic initializer stubs the same way MSVC doesReid Kleckner2013-09-101-4/+4
| | | | | | | | | | | | Summary: Dynamic initializers are mangled as ??__E <name> YAXXZ. Reviewers: timurrrr CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1477 llvm-svn: 190434
* [ms-cxxabi] Implement guard variables for static initializationReid Kleckner2013-09-101-7/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | Static locals requiring initialization are not thread safe on Windows. Unfortunately, it's possible to create static locals that are actually externally visible with inline functions and templates. As a result, we have to implement an initialization guard scheme that is compatible with TUs built by MSVC, which makes thread safety prohibitively difficult. MSVC's scheme is that every function that requires a guard gets an i32 bitfield. Each static local is assigned a bit that indicates if it has been initialized, up to 32 bits, at which point a new bitfield is created. MSVC rejects inline functions with more than 32 static locals, and the externally visible mangling (?_B) only allows for one guard variable per function. On Eli's recommendation, I used MangleNumberingContext to track which bit each static corresponds to. Implements PR16888. Reviewers: rjmccall, eli.friedman Differential Revision: http://llvm-reviews.chandlerc.com/D1416 llvm-svn: 190427
* Add a separate llvm.global_ctors entry for linkonce_odr data initializersReid Kleckner2013-08-221-2/+5
| | | | | | | | | | | | | | | Summary: These typically come from static data members of class template specializations. This accomplishes two things: 1. May expose GlobalOpt optimizations for Itanium C++ ABI code. 2. Works toward fixing double initialization in the Microsoft C++ ABI. CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1475 llvm-svn: 189051
* Reapply r176133 with testcase fixes.Bill Wendling2013-02-271-6/+5
| | | | llvm-svn: 176145
* Revert "Add more attributes from the command line to functions."Anna Zaks2013-02-251-5/+6
| | | | | | | | This reverts commit 176009. The commit is a likely cause of several buildbot failures. llvm-svn: 176044
* Add more attributes from the command line to functions.Bill Wendling2013-02-251-6/+5
| | | | | | | This is an ongoing process. Any command line option which a back-end cares about should be added here. llvm-svn: 176009
* Modify the tests to use attribute group references instead of listing theBill Wendling2013-02-201-4/+7
| | | | | | function attributes. llvm-svn: 175606
* clang/test/CodeGenCXX/microsoft-*: Fix for -Asserts.NAKAMURA Takumi2012-09-251-2/+2
| | | | llvm-svn: 164594
* In the MS ABI, ctors return 'this'. Patch by Dmitry Sokolov.John McCall2012-09-251-3/+3
| | | | llvm-svn: 164592
* [Windows] Use thiscall as the default calling convention for class methods. ↵Timur Iskhodzhanov2012-07-121-6/+6
| | | | | | PR12785 llvm-svn: 160121
* Abstract the emission of global destructors into ABI-specific codeJohn McCall2012-05-011-0/+52
and only consider using __cxa_atexit in the Itanium logic. The default logic is to use atexit(). Emit "guarded" initializers in Microsoft mode unconditionally. This is definitely not correct, but it's closer to correct than just not emitting the initializer. Based on a patch by Timur Iskhodzhanov! llvm-svn: 155894
OpenPOWER on IntegriCloud