summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* -fms-extensions: Implement half of #pragma init_segReid Kleckner2014-07-221-2/+31
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This pragma is very rare. We could *hypothetically* lower some uses of it down to @llvm.global_ctors, but given that GlobalOpt isn't able to optimize prioritized global ctors today, there's really no point. If we wanted to do this in the future, I would check if the section used in the pragma started with ".CRT$XC" and had up to two characters after it. Those two characters could form the 16-bit initialization priority that we support in @llvm.global_ctors. We would have to teach LLVM to lower prioritized global ctors on COFF as well. This should let us compile some silly uses of this pragma in WebKit / Blink. Reviewers: rsmith, majnemer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4549 llvm-svn: 213593
* [Sanitizer] Reduce the usage of sanitizer blacklist in CodeGenModuleAlexey Samsonov2014-07-071-6/+8
| | | | | | | | | | | | | | | | Get rid of cached CodeGenModule::SanOpts, which was used to turn off sanitizer codegen options if current LLVM Module is blacklisted, and use plain LangOpts.Sanitize instead. 1) Some codegen decisions (turning TBAA or writable strings on/off) shouldn't depend on the contents of blacklist. 2) llvm.asan.globals should *always* be created, even if the module is blacklisted - soon Clang's CodeGen where we read sanitizer blacklist files, so we should properly report which globals are blacklisted to the backend. llvm-svn: 212499
* Use comdats to avoid double initialization of weak dataReid Kleckner2014-05-231-6/+7
| | | | | | | | | | | | | | | | | 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
* [C++11] Use 'nullptr'. CodeGen edition.Craig Topper2014-05-211-6/+6
| | | | llvm-svn: 209272
* If a declaration is loaded, and then a module import adds a redeclaration, thenRichard Smith2014-05-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ensure that querying the first declaration for its most recent declaration checks for redeclarations from the imported module. This works as follows: * The 'most recent' pointer on a canonical declaration grows a pointer to the external AST source and a generation number (space- and time-optimized for the case where there is no external source). * Each time the 'most recent' pointer is queried, if it has an external source, we check whether it's up to date, and update it if not. * The ancillary data stored on the canonical declaration is allocated lazily to avoid filling it in for declarations that end up being non-canonical. We'll still perform a redundant (ASTContext) allocation if someone asks for the most recent declaration from a decl before setPreviousDecl is called, but such cases are probably all bugs, and are now easy to find. Some finessing is still in order here -- in particular, we use a very general mechanism for handling the DefinitionData pointer on CXXRecordData, and a more targeted approach would be more compact. Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was addressing only a corner of the full problem space here. That's not covered by this patch. Early performance benchmarks show that this makes no measurable difference to Clang performance without modules enabled (and fixes a major correctness issue with modules enabled). I'll revert if a full performance comparison shows any problems. llvm-svn: 209046
* Include translation unit filename in global ctor symbol names.Nico Weber2014-05-061-3/+16
| | | | | | | | | | | | | | | | | 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
* CodeGen: Fix linkage of reference temporariesDavid Majnemer2014-04-281-2/+2
| | | | | | | | | | | | | | | 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
* Follow-up to r205999: Emit an artificial location (valid scope, line 0)Adrian Prantl2014-04-111-43/+54
| | | | | | | | | for CXXGlobalInit/Dtor helper functions. This makes _GLOBAL__I_a regain its DW_AT_high/low_pc in the debug info. Thanks to echristo for catching this! llvm-svn: 206088
* Cleanup: Add default arguments to CodeGenFunction::StartFunction.Adrian Prantl2014-04-111-8/+4
| | | | | | Thanks dblaikie for the suggestion! llvm-svn: 206012
* Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_aAdrian Prantl2014-04-101-5/+7
| | | | | | | | | | | | | | | | are not associated with any source lines. Previously, if the Location of a Decl was empty, EmitFunctionStart would just keep using CurLoc, which would sometimes be correct (e.g., thunks) but in other cases would just point to a hilariously random location. This patch fixes this by completely eliminating all uses of CurLoc from EmitFunctionStart and rather have clients explicitly pass in a SourceLocation for the function header and the function body. rdar://problem/14985269 llvm-svn: 205999
* [ms-cxxabi] Use x86_cdeclmethodcc for __cdecl methods on win32Reid Kleckner2014-01-311-5/+3
| | | | | | | | | | | | | | | | | | | This fixes PR15768, where the sret parameter and the 'this' parameter are in the wrong order. Instance methods compiled by MSVC never return records in registers, they always return indirectly through an sret pointer. That sret pointer always comes after the 'this' parameter, for both __cdecl and __thiscall methods. Unfortunately, the same is true for other calling conventions, so we'll have to change the overall approach here relatively soon. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D2664 llvm-svn: 200587
* Switched code from using hasAttr followed by getAttr to simply call getAttr ↵Aaron Ballman2013-12-191-3/+2
| | | | | | | | directly and check the resulting value. No functional changes intended. llvm-svn: 197650
* Fix crashes when creating global instances of polymorphic classes without fieldsTimur Iskhodzhanov2013-10-021-1/+2
| | | | | | Reviewed at http://llvm-reviews.chandlerc.com/D1795 llvm-svn: 191839
* [ms-cxxabi] Mangle dynamic initializer stubs the same way MSVC doesReid Kleckner2013-09-101-1/+6
| | | | | | | | | | | | 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-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Order initializers of static data members of explicit specializationsReid Kleckner2013-09-041-5/+6
| | | | | | | | I tried to implement this properly in r189051, but I didn't have enough test coverage. Richard kindly provided more test cases than I could possibly imagine and now we should have the correct condition. llvm-svn: 189898
* Revert "PR14569: Omit debug info for thunks"David Blaikie2013-08-271-16/+14
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit r189320. Alexey Samsonov and Dmitry Vyukov presented some arguments for keeping these around - though it still seems like those tasks could be solved by a tool just using the symbol table. In a very small number of cases, thunks may be inlined & debug info might be able to save profilers & similar tools from misclassifying those cases as part of the caller. The extra changes here plumb through the VarDecl for various cases to CodeGenFunction - this provides better fidelity through a few APIs but generally just causes the CGF::StartFunction to fallback to using the name of the IR function as the name in the debug info. The changes to debug-info-global-ctor-dtor.cpp seem like goodness. The two names that go missing (in favor of only emitting those names as linkage names) are names that can be demangled - emitting them only as the linkage name should encourage tools to do just that. Again, thanks to Dinesh Dwivedi for investigation/work on this issue. llvm-svn: 189421
* Simplify/clean up debug info suppression in CodeGenFunctionDavid Blaikie2013-08-261-14/+2
| | | | | | | | | | CodeGenFunction is run on only one function - a new object is made for each new function. I would add an assertion/flag to this effect, but there's an exception: ObjC properties involve emitting helper functions that are all emitted by the same CodeGenFunction object, so such a check is not possible/correct. llvm-svn: 189277
* Add a separate llvm.global_ctors entry for linkonce_odr data initializersReid Kleckner2013-08-221-0/+13
| | | | | | | | | | | | | | | 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
* Simplify: we don't need any special-case lifetime extension when initializingRichard Smith2013-06-121-1/+1
| | | | | | | declarations of reference type; they're handled by the general case handling of MaterializeTemporaryExpr. llvm-svn: 183875
* Revert r180739 and r180748: they broke C++11 thread_local on non-Darwin ↵Richard Smith2013-04-301-1/+0
| | | | | | | | | | | | | | | | systems and did not do the right thing on Darwin. Original commit message: Emit the TLS intialization functions into a list. Add the TLS initialization functions to a list of initialization functions. The back-end takes this list and places the function pointers into the correct section. This way they're called before `main().' <rdar://problem/13733006> llvm-svn: 180809
* Emit the TLS intialization functions into a list.Bill Wendling2013-04-291-0/+1
| | | | | | | | | | Add the TLS initialization functions to a list of initialization functions. The back-end takes this list and places the function pointers into the correct section. This way they're called before `main().' <rdar://problem/13733006> llvm-svn: 180739
* ArrayRefize code. No functionality change.Benjamin Kramer2013-04-261-16/+12
| | | | llvm-svn: 180632
* Implement CodeGen for C++11 thread_local, following the Itanium ABI ↵Richard Smith2013-04-191-10/+59
| | | | | | specification as discussed on cxx-abi-dev. llvm-svn: 179858
* Standardize accesses to the TargetInfo in IR-gen.John McCall2013-04-161-1/+1
| | | | | | Patch by Stephen Lin! llvm-svn: 179638
* CodeGen support for function-local static thread_local variables withRichard Smith2013-04-141-4/+2
| | | | | | | | | non-constant constructors or non-trivial destructors. Plus bugfixes for thread_local references bound to temporaries (the temporaries themselves are lifetime-extended to become thread_local), and the corresponding case for std::initializer_list. llvm-svn: 179496
* Annotate flavor of TLS variable (statically or dynamically initialized) onto ↵Richard Smith2013-04-131-1/+7
| | | | | | the AST. llvm-svn: 179447
* Change hasAggregateLLVMType, which conflates complex andJohn McCall2013-03-071-4/+10
| | | | | | | | | | | | | | | aggregate types in a profoundly wrong way that has to be worked around in every call site, to getEvaluationKind, which classifies and distinguishes between all of these cases. Also, normalize the API for loading and storing complexes. I'm working on a larger patch and wanted to pull these changes out, but it would have be annoying to detangle them from each other. llvm-svn: 176656
* Use the actual ABI-determined C calling convention for runtimeJohn McCall2013-02-281-2/+4
| | | | | | | | | | | | | | | | | | | | | | calls and declarations. LLVM has a default CC determined by the target triple. This is not always the actual default CC for the ABI we've been asked to target, and so we sometimes find ourselves annotating all user functions with an explicit calling convention. Since these calling conventions usually agree for the simple set of argument types passed to most runtime functions, using the LLVM-default CC in principle has no effect. However, the LLVM optimizer goes into histrionics if it sees this kind of formal CC mismatch, since it has no concept of CC compatibility. Therefore, if this module happens to define the "runtime" function, or got LTO'ed with such a definition, we can miscompile; so it's quite important to get this right. Defining runtime functions locally is quite common in embedded applications. llvm-svn: 176286
* Unify clang/llvm attributes for asan/tsan/msan (Clang part)Kostya Serebryany2013-02-261-1/+5
| | | | | | | | | | | | | | | | | | | These are two related changes (one in llvm, one in clang). LLVM: - rename address_safety => sanitize_address (the enum value is the same, so we preserve binary compatibility with old bitcode) - rename thread_safety => sanitize_thread - rename no_uninitialized_checks -> sanitize_memory CLANG: - add __attribute__((no_sanitize_address)) as a synonym for __attribute__((no_address_safety_analysis)) - add __attribute__((no_sanitize_thread)) - add __attribute__((no_sanitize_memory)) for S in address thread memory If -fsanitize=S is present and __attribute__((no_sanitize_S)) is not set llvm attribute sanitize_S llvm-svn: 176076
* [ubsan] Add support for -fsanitize-blacklistWill Dietz2013-01-181-1/+1
| | | | llvm-svn: 172808
* Rewrite #includes for llvm/Foo.h to llvm/IR/Foo.h as appropriate toChandler Carruth2013-01-021-1/+1
| | | | | | | | reflect the migration in r171366. Re-sort the #include lines to reflect the new paths. llvm-svn: 171369
* Rename llvm::Attributes to llvm::Attribute.Bill Wendling2012-12-201-1/+1
| | | | llvm-svn: 170722
* Revert r170500. It over-zealously converted *ALL* things named Attributes, ↵Bill Wendling2012-12-201-1/+1
| | | | | | which is wrong here. llvm-svn: 170721
* Rename the 'Attributes' class to 'Attribute'. It's going to represent a ↵Bill Wendling2012-12-191-1/+1
| | | | | | single attribute in the future. llvm-svn: 170500
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-2/+2
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Implement codegen for init_priority attribute properly - make sure itAnton Korobeynikov2012-11-061-16/+38
| | | | | | | | works between the modules. No functionality change on Darwin/Windows. This fixes PR11480. llvm-svn: 167496
* Rename LangOptions members for address sanitizer and thread sanitizer fromRichard Smith2012-11-051-1/+1
| | | | | | *Sanitizer to Sanitize* in preparation for later patches. llvm-svn: 167405
* Simplify: replace getContext().getLangOpts() with just getLangOpts().Richard Smith2012-11-011-1/+1
| | | | llvm-svn: 167261
* Initialize debug info for special cases of functions that lack declarations ↵Alexey Samsonov2012-10-251-0/+12
| | | | | | and are generated by Clang (global initializers/destructors, thunks) . Fixes PR13942. llvm-svn: 166676
* Transform pattern:Alexey Samsonov2012-10-161-2/+3
| | | | | | | | | | | if (CGM.getModuleDebugInfo()) DebugInfo = CGM.getModuleDebugInfo() into a call: maybeInitializeDebugInfo(); This is a simplification for a possible future fix of PR13942. llvm-svn: 166019
* Have 'addFnAttr' take the attribute enum value. Then have it build the ↵Bill Wendling2012-10-101-1/+1
| | | | | | attribute object and add it appropriately. No functionality change. llvm-svn: 165596
* Emit debug info for dynamic initializers. Permit __attribute__((nodebug)) onNick Lewycky2012-07-241-2/+5
| | | | | | | variables that have static storage duration, it removes debug info on the emitted initializer function but not all debug info about this variable. llvm-svn: 160659
* [asan] add missing asan instrumentation in generated global init functionsKostya Serebryany2012-06-261-0/+3
| | | | llvm-svn: 159191
* Abstract the emission of global destructors into ABI-specific codeJohn McCall2012-05-011-62/+8
| | | | | | | | | | | | | 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
* Fix a trivial oversight with apple-kext static local destructorsJohn McCall2012-04-131-0/+1
| | | | | | and add a test case. llvm-svn: 154653
* Use atexit when __cxa_atexit isn't available instead of adding aJohn McCall2012-04-061-26/+98
| | | | | | | | | 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! llvm-svn: 154191
* Rename GenerateCXXGlobalDtorFunc to GenerateCXXGlobalDtorsFunc.John McCall2012-04-061-2/+2
| | | | llvm-svn: 154190
* Revert r153723, and its follow-ups r153728 and r153733.Chandler Carruth2012-03-301-2/+2
| | | | | | | | | | | | | | | | These patches cause us to miscompile and/or reject code with static function-local variables in an extern-C context. Previously, we were papering over this as long as the variables are within the same translation unit, and had not seen any failures in the wild. We still need a proper fix, which involves mangling static locals inside of an extern-C block (as GCC already does), but this patch causes pretty widespread regressions. Firefox, and many other applications no longer build. Lots of test cases have been posted to the list in response to this commit, so there should be no problem reproducing the issues. llvm-svn: 153768
* Do the static-locals thing properly in the face of unions andJohn McCall2012-03-301-2/+2
| | | | | | other things which might mess with the variable's type. llvm-svn: 153733
OpenPOWER on IntegriCloud