summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Avoid Attr.h includes, CodeGen editionReid Kleckner2019-12-091-1/+2
| | | | This saves around 20 includes of Attr.h. Not much.
* [NFC] Pass a reference to CodeGenFunction to methods of LValue andAkira Hatanaka2019-12-031-4/+5
| | | | | | | | | | | | | | AggValueSlot This reapplies 8a5b7c35709d9ce1f44a99f0c5b084bf2696ea17 after a null dereference bug in CGOpenMPRuntime::emitUserDefinedMapper. Original commit message: This is needed for the pointer authentication work we plan to do in the near future. https://github.com/apple/llvm-project/blob/a63a81bd9911f87a0b5dcd5bdd7ccdda7124af87/clang/docs/PointerAuthentication.rst
* Revert "[NFC] Pass a reference to CodeGenFunction to methods of LValue and"Akira Hatanaka2019-12-031-5/+4
| | | | | This reverts commit 8a5b7c35709d9ce1f44a99f0c5b084bf2696ea17. This seems to have broken UBSan because of a null dereference.
* [NFC] Pass a reference to CodeGenFunction to methods of LValue andAkira Hatanaka2019-12-031-4/+5
| | | | | | | | | AggValueSlot This is needed for the pointer authentication work we plan to do in the near future. https://github.com/apple/llvm-project/blob/a63a81bd9911f87a0b5dcd5bdd7ccdda7124af87/clang/docs/PointerAuthentication.rst
* Revert "re-land [DebugInfo] Add debug location to stubs generated by ↵Alexandre Ganea2019-11-151-9/+3
| | | | | | CGDeclCXX and mark them as artificial" This reverts commit 9c1baa23526c6d7d06eafefbf82d73bfe9bb3aaf.
* re-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX and ↵Alexandre Ganea2019-11-151-3/+9
| | | | | | mark them as artificial Differential Revision: https://reviews.llvm.org/D66328
* [HIP] Add option -fgpu-allow-device-initYaxun (Sam) Liu2019-10-221-1/+6
| | | | | | | | | | | | | | Add this option to allow device side class type global variables with non-trivial ctor/dtor. device side init/fini functions will be emitted, which will be executed by HIP runtime when the fat binary is loaded/unloaded. This feature is to facilitate implementation of device side sanitizer which requires global vars with non-trival ctors. By default this option is disabled. Differential Revision: https://reviews.llvm.org/D69268
* Fix Calling Convention through aliasesErich Keane2019-10-071-2/+2
| | | | | | | | | | | | | | r369697 changed the behavior of stripPointerCasts to no longer include aliases. However, the code in CGDeclCXX.cpp's createAtExitStub counted on the looking through aliases to properly set the calling convention of a call. The result of the change was that the calling convention mismatch of the call would be replaced with a llvm.trap, causing a runtime crash. Differential Revision: https://reviews.llvm.org/D68584 llvm-svn: 373929
* For P0784R7: compute whether a variable has constant destruction if itRichard Smith2019-09-291-7/+4
| | | | | | | | | | has a constexpr destructor. For constexpr variables, reject if the variable does not have constant destruction. In all cases, do not emit runtime calls to the destructor for variables with constant destruction. llvm-svn: 373159
* Revert: [DebugInfo] Add debug location to stubs generated by CGDeclCXX and ↵Alexandre Ganea2019-09-051-9/+3
| | | | | | mark them as artificial llvm-svn: 371113
* [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them ↵Alexandre Ganea2019-09-051-3/+9
| | | | | | | | as artificial Differential Revision: https://reviews.llvm.org/D66328 llvm-svn: 371080
* Revert r369458 "[DebugInfo] Add debug location to dynamic atexit destructor"Hans Wennborg2019-08-221-2/+0
| | | | | | | | | | | | | | | | It causes the build to fail with "inlinable function call in a function with debug info must have a !dbg location" in Chromium. See llvm-commits thread for more info. (This also reverts the follow-up in r369474.) > Fixes PR43012 > > Differential Revision: https://reviews.llvm.org/D66328 llvm-svn: 369633
* [DebugInfo] Add debug location to dynamic atexit destructorAlexandre Ganea2019-08-201-0/+2
| | | | | | | | Fixes PR43012 Differential Revision: https://reviews.llvm.org/D66328 llvm-svn: 369458
* ARM MTE stack sanitizer.Evgeniy Stepanov2019-07-151-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Add "memtag" sanitizer that detects and mitigates stack memory issues using armv8.5 Memory Tagging Extension. It is similar in principle to HWASan, which is a software implementation of the same idea, but there are enough differencies to warrant a new sanitizer type IMHO. It is also expected to have very different performance properties. The new sanitizer does not have a runtime library (it may grow one later, along with a "debugging" mode). Similar to SafeStack and StackProtector, the instrumentation pass (in a follow up change) will be inserted in all cases, but will only affect functions marked with the new sanitize_memtag attribute. Reviewers: pcc, hctim, vitalybuka, ostannard Subscribers: srhines, mehdi_amini, javed.absar, kristof.beyls, hiraditya, cryptoad, steven_wu, dexonsmith, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D64169 llvm-svn: 366123
* [OpenCL][PR41727] Prevent ICE on global dtorsAnastasia Stulova2019-07-151-3/+17
| | | | | | | | | | Pass NULL to pointer arg of __cxa_atexit if addr space is not matching with its param. This doesn't align yet with how dtors are generated that should be changed too. Differential Revision: https://reviews.llvm.org/D62413 llvm-svn: 366059
* [OpenMP] Add support for handling declare target to clause when unified ↵Gheorghe-Teodor Bercea2019-06-201-1/+1
| | | | | | | | | | | | | | | | | | | | | memory is required Summary: This patch adds support for the handling of the variables under the declare target to clause. The variables in this case are handled like link variables are. A pointer is created on the host and then mapped to the device. The runtime will then copy the address of the host variable in the device pointer. Reviewers: ABataev, AlexEichenberger, caomhin Reviewed By: ABataev Subscribers: guansong, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63108 llvm-svn: 363959
* PR42111: Use guarded initialization for thread-local variables withRichard Smith2019-06-051-1/+7
| | | | | | | | | unordered initialization and internal linkage. We'll run their initializers once on each reference, so we need a guard variable even though they only have a single definition. llvm-svn: 362562
* [OpenCL] Make global ctor init function a kernelAnastasia Stulova2019-05-091-0/+13
| | | | | | | | | | | | | | We need to be able to enqueue internal function that initializes global constructors on the host side. Therefore it has to be converted to a kernel. This change factors out common logic for adding kernel metadata and moves it from CodeGenFunction to CodeGenModule in order to make it accessible for the extra use case. Differential revision: https://reviews.llvm.org/D61488 llvm-svn: 360342
* Fix bug 37903:MS ABI: handle inline static data member and inline variable ↵Jennifer Yu2019-04-251-1/+7
| | | | | | as template static data member llvm-svn: 359212
* [codeview] Fix symbol names for dynamic initializers and atexit stubsReid Kleckner2019-04-241-6/+6
| | | | | | | | | | | | | | | | Summary: Add a new variant to GlobalDecl for these so that we can detect them more easily during debug info emission and handle them appropriately. Reviewers: rsmith, rjmccall, jyu2 Subscribers: aprantl, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60930 llvm-svn: 359148
* Revert r357610, it caused PR41471Nico Weber2019-04-111-6/+0
| | | | llvm-svn: 358232
* Bug-40323: MS ABI adding template static member in the linker directive ↵Jennifer Yu2019-04-031-0/+6
| | | | | | section to make sure init function can be called before main. llvm-svn: 357610
* IRGen: Remove StructorType; thread GlobalDecl through more code. NFCI.Peter Collingbourne2019-03-221-1/+1
| | | | | | | | This should make it easier to add more structor variants. Differential Revision: https://reviews.llvm.org/D59724 llvm-svn: 356822
* [opaque pointer types] Pass through function types for TLSJames Y Knight2019-02-071-11/+13
| | | | | | | | initialization and global destructor calls. Differential Revision: https://reviews.llvm.org/D57801 llvm-svn: 353355
* [opaque pointer types] Pass function types for runtime function calls.James Y Knight2019-02-051-2/+2
| | | | | | | | | | | | | Emit{Nounwind,}RuntimeCall{,OrInvoke} have been modified to take a FunctionCallee as an argument, and CreateRuntimeFunction has been modified to return a FunctionCallee. All callers have been updated. Additionally, CreateBuiltinFunction is removed, as it was redundant with CreateRuntimeFunction after some previous changes. Differential Revision: https://reviews.llvm.org/D57668 llvm-svn: 353184
* [opaque pointer types] Trivial changes towards CallInst requiringJames Y Knight2019-02-031-1/+1
| | | | | | explicit function types. llvm-svn: 353009
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [OpenCL] Add generic AS to 'this' pointerMikael Nilsson2018-12-131-1/+4
| | | | | | | | | | | | | Address spaces are cast into generic before invoking the constructor. Added support for a trailing Qualifiers object in FunctionProtoType. Note: This recommits the previously reverted patch, but now it is commited together with a fix for lldb. Differential Revision: https://reviews.llvm.org/D54862 llvm-svn: 349019
* Revert "[OpenCL] Add generic AS to 'this' pointer"Mikael Nilsson2018-12-121-4/+1
| | | | | | Reverting because the patch broke lldb. llvm-svn: 348931
* [OpenCL] Add generic AS to 'this' pointerMikael Nilsson2018-12-121-1/+4
| | | | | | | | | | Address spaces are cast into generic before invoking the constructor. Added support for a trailing Qualifiers object in FunctionProtoType. Differential Revision: https://reviews.llvm.org/D54862 llvm-svn: 348927
* Move CodeGenOptions from Frontend to BasicRichard Trieu2018-12-111-1/+1
| | | | | | Basic uses CodeGenOptions and should not depend on Frontend. llvm-svn: 348827
* [CodeGen][CXX]: Fix no_destroy CG bug under specific circumstancesKristina Brooks2018-11-121-0/+9
| | | | | | | | | | | | | | | | | | Summary: Class with no user-defined destructor that has an inherited member that has a non-trivial destructor and a non-default constructor will attempt to emit a destructor despite being marked as __attribute((no_destroy)) in which case it would trigger an assertion due to an incorrect assumption. In addition this adds missing test coverage for IR generation for no_destroy. (Note that here use of no_destroy is synonymous with its global flag counterpart `-fno-c++-static-destructors` being enabled) Differential Revision: https://reviews.llvm.org/D54344 llvm-svn: 346628
* [clang]: Fix misapplied patch in 346582.Kristina Brooks2018-11-101-1/+1
| | | | llvm-svn: 346583
* Correct naming conventions and 80 col rule violation in CGDeclCXX.cpp. NFC.Kristina Brooks2018-11-101-16/+17
| | | | | | Differential Revision: https://reviews.llvm.org/D54373 llvm-svn: 346582
* Part of PR39508: Emit an @llvm.invariant.start after storing toRichard Smith2018-10-311-9/+19
| | | | | | | | | | | | | | | | | __tls_guard. __tls_guard can only ever transition from 0 to 1, and only once. This permits LLVM to remove repeated checks for TLS initialization and repeated initialization code in cases like: int g(); thread_local int n = g(); int a = n + n; where we could not prove that __tls_guard was still 'true' when checking it for the second reference to 'n' in the initializer of 'a'. llvm-svn: 345774
* [AArch64] Branch Protection and Return Address Signing B Key SupportLuke Cheeseman2018-10-251-1/+11
| | | | | | | | | | | - Add support for -mbranch-protection=<type>[+<type>]* where - <type> ::= [standard, none, bti, pac-ret[+b-key,+leaf]*] - The protection emits relevant function attributes - sign-return-address=<scope> - sign-return-address-key=<key> - branch-protection llvm-svn: 345273
* [AArch64] Enable return address signing for static ctorsOliver Stannard2018-09-131-0/+6
| | | | | | | | | | | Functions generated by clang and included in the .init_array section (such as static constructors) do not follow the usual code path for adding target-specific function attributes, so we have to add the return address signing attribute here too, as is currently done for the sanitisers. Differential revision: https://reviews.llvm.org/D51418 llvm-svn: 342126
* [MSan] add KMSAN support to Clang driverAlexander Potapenko2018-09-071-0/+4
| | | | | | | | | | | | | | | Boilerplate code for using KMSAN instrumentation in Clang. We add a new command line flag, -fsanitize=kernel-memory, with a corresponding SanitizerKind::KernelMemory, which, along with SanitizerKind::Memory, maps to the memory_sanitizer feature. KMSAN is only supported on x86_64 Linux. It's incompatible with other sanitizers, but supports code coverage instrumentation. llvm-svn: 341641
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-2/+2
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
* Remove trailing spaceFangrui Song2018-07-301-7/+7
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* Add a command line option 'fregister_global_dtors_with_atexit' toAkira Hatanaka2018-04-171-0/+3
| | | | | | | | | | | | | | | | | | | | | register destructor functions annotated with __attribute__((destructor)) using __cxa_atexit or atexit. Register destructor functions annotated with __attribute__((destructor)) calling __cxa_atexit in a synthesized constructor function instead of emitting references to the functions in a special section. The primary reason for adding this option is that we are planning to deprecate the __mod_term_funcs section on Darwin in the future. This feature is enabled by default only on Darwin. Users who do not want this can use command line option 'fno_register_global_dtors_with_atexit' to disable it. rdar://problem/33887655 Differential Revision: https://reviews.llvm.org/D45578 llvm-svn: 330199
* hwasan: add -fsanitize=kernel-hwaddress flagAndrey Konovalov2018-04-131-0/+4
| | | | | | | | | This patch adds -fsanitize=kernel-hwaddress flag, that essentially enables -hwasan-kernel=1 -hwasan-recover=1 -hwasan-match-all-tag=0xff. Differential Revision: https://reviews.llvm.org/D45046 llvm-svn: 330044
* PR36992: do not store beyond the dsize of a class object unless we knowRichard Smith2018-04-051-1/+2
| | | | | | | | | | | | | | the tail padding is not reused. We track on the AggValueSlot (and through a couple of other initialization actions) whether we're dealing with an object that might share its tail padding with some other object, so that we can avoid emitting stores into the tail padding if that's the case. We still widen stores into tail padding when we can do so. Differential Revision: https://reviews.llvm.org/D45306 llvm-svn: 329342
* Add the -fsanitize=shadow-call-stack flagVlad Tsyrklevich2018-04-031-0/+4
| | | | | | | | | | | | | | | | | Summary: Add support for the -fsanitize=shadow-call-stack flag which causes clang to add ShadowCallStack attribute to functions compiled with that flag enabled. Reviewers: pcc, kcc Reviewed By: pcc, kcc Subscribers: cryptoad, cfe-commits, kcc Differential Revision: https://reviews.llvm.org/D44801 llvm-svn: 329122
* [OPENMP] Codegen for ctor|dtor of declare target variables.Alexey Bataev2018-03-281-0/+4
| | | | | | | | When the declare target variables are emitted for the device, constructors|destructors for these variables must emitted and registered by the runtime in the offloading sections. llvm-svn: 328705
* Pass a GlobalDecl to SetInternalFunctionAttributes. NFC.Rafael Espindola2018-02-281-1/+1
| | | | | | | | This just reduces the noise in a followup patch. Part of D43900. llvm-svn: 326385
* [ObjC] Allow declaring __strong pointer fields in structs in Objective-CAkira Hatanaka2018-02-281-0/+1
| | | | | | | | | | | | | | | | | | | | | ARC mode. Declaring __strong pointer fields in structs was not allowed in Objective-C ARC until now because that would make the struct non-trivial to default-initialize, copy/move, and destroy, which is not something C was designed to do. This patch lifts that restriction. Special functions for non-trivial C structs are synthesized that are needed to default-initialize, copy/move, and destroy the structs and manage the ownership of the objects the __strong pointer fields point to. Non-trivial structs passed to functions are destructed in the callee function. rdar://problem/33599681 Differential Revision: https://reviews.llvm.org/D41228 llvm-svn: 326307
* [OPENMP] Support for -fopenmp-simd option with compilation of simd loopsAlexey Bataev2017-12-291-1/+3
| | | | | | | | | only. Added support for -fopenmp-simd option that allows compilation of simd-based constructs without emission of OpenMP runtime calls. llvm-svn: 321560
* Hardware-assisted AddressSanitizer (clang part).Evgeniy Stepanov2017-12-091-0/+4
| | | | | | | | | | | | | | Summary: Driver, frontend and LLVM codegen for HWASan. A clone of ASan, basically. Reviewers: kcc, pcc, alekseyshl Subscribers: srhines, javed.absar, cfe-commits Differential Revision: https://reviews.llvm.org/D40936 llvm-svn: 320232
* Allow specifying sanitizers in blacklistsVlad Tsyrklevich2017-09-251-11/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is the follow-up patch to D37924. This change refactors clang to use the the newly added section headers in SpecialCaseList to specify which sanitizers blacklists entries should apply to, like so: [cfi-vcall] fun:*bad_vcall* [cfi-derived-cast|cfi-unrelated-cast] fun:*bad_cast* The SanitizerSpecialCaseList class has been added to allow querying by SanitizerMask, and SanitizerBlacklist and its downstream users have been updated to provide that information. Old blacklists not using sections will continue to function identically since the blacklist entries will be placed into a '[*]' section by default matching against all sanitizers. Reviewers: pcc, kcc, eugenis, vsk Reviewed By: eugenis Subscribers: dberris, cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D37925 llvm-svn: 314171
OpenPOWER on IntegriCloud