summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [CUDA] Destroy deferred diagnostics before destroying the ASTContext's ↵Justin Lebar2016-10-041-0/+3
| | | | | | | | | | | | | | | | PartialDiagnostic allocator. Summary: This will let us (in a separate patch) allocate deferred diagnostics in the ASTContext's PartialDiagnostic arena. Reviewers: rnk Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25260 llvm-svn: 283271
* Move UTF functions into namespace llvm.Justin Lebar2016-09-301-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This lets people link against LLVM and their own version of the UTF library. I determined this only affects llvm, clang, lld, and lldb by running $ git grep -wl 'UTF[0-9]\+\|\bConvertUTF\bisLegalUTF\|getNumBytesFor' | cut -f 1 -d '/' | sort | uniq clang lld lldb llvm Tested with ninja lldb ninja check-clang check-llvm check-lld (ninja check-lldb doesn't complete for me with or without this patch.) Reviewers: rnk Subscribers: klimek, beanz, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D24996 llvm-svn: 282822
* CodeGen: simplify the logic a slight bitSaleem Abdulrasool2016-09-141-9/+7
| | | | | | | | | Move the definition of `getTriple()` into the header. It would just call `getTarget().getTriple()`. Inline the definition to allow the compiler to see the same amount of the layout as previously. Remove the more verbose `getTarget().getTriple()` in favour of `getTriple()`. llvm-svn: 281487
* Also don't inline dllimport functions referring to non-dllimport constructors.Hans Wennborg2016-09-131-0/+6
| | | | | | | | The AST walker wasn't visiting CXXConstructExprs before. This is a follow-up to r281395. llvm-svn: 281413
* Try harder to not inline dllimport functions referencing non-dllimport functionsHans Wennborg2016-09-131-2/+23
| | | | | | | | In r246338, code was added to check for this, but it failed to take into account implicit destructor invocations because those are not reflected in the AST. This adds a separate check for them. llvm-svn: 281395
* CodeGen: remove unnecessary else caseSaleem Abdulrasool2016-09-111-6/+3
| | | | | | | Refactor the assignment so that its much more clear that the if-clause contains the lookup, and once cached is directly used. NFC. llvm-svn: 281150
* C++ Modules TS: Add parsing and some semantic analysis support forRichard Smith2016-09-081-15/+16
| | | | | | | export-declarations. These don't yet have an effect on name visibility; we still export everything by default. llvm-svn: 280999
* Add -fprofile-dir= to clang.Nick Lewycky2016-08-311-12/+18
| | | | | | | | | | | | | | | | | | | | | -fprofile-dir=path allows the user to specify where .gcda files should be emitted when the program is run. In particular, this is the first flag that causes the .gcno and .o files to have different paths, LLVM is extended to support this. -fprofile-dir= does not change the file name in the .gcno (and thus where lcov looks for the source) but it does change the name in the .gcda (and thus where the runtime library writes the .gcda file). It's different from a GCOV_PREFIX because a user can observe that the GCOV_PREFIX_STRIP will strip paths off of -fprofile-dir= but not off of a supplied GCOV_PREFIX. To implement this we split -coverage-file into -coverage-data-file and -coverage-notes-file to specify the two different names. The !llvm.gcov metadata node grows from a 2-element form {string coverage-file, node dbg.cu} to 3-elements, {string coverage-notes-file, string coverage-data-file, node dbg.cu}. In the 3-element form, the file name is already "mangled" with .gcno/.gcda suffixes, while the 2-element form left that to the middle end pass. llvm-svn: 280306
* Re-commit [OpenCL] AMDGCN: Fix size_t typeYaxun Liu2016-08-191-1/+4
| | | | | | There was a premature cast to pointer type in emitPointerArithmetic which caused assertion in tests with assertion enabled. llvm-svn: 279206
* Revert [OpenCL] AMDGCN: Fix size_t typeYaxun Liu2016-08-181-4/+1
| | | | | | due to regressions in test/CodeGen/exprs.c on certain platforms. llvm-svn: 279127
* [OpenCL] AMDGCN: Fix size_t typeYaxun Liu2016-08-181-1/+4
| | | | | | | | Pointers of certain GPUs in AMDGCN target in private address space is 32 bit but pointers in other address spaces are 64 bit. size_t type should be defined as 64 bit for these GPUs so that it could hold pointers in all address spaces. Also fixed issues in pointer arithmetic codegen by using pointer specific intptr type. Differential Revision: https://reviews.llvm.org/D23361 llvm-svn: 279121
* Add the notion of deferred diagnostics.Justin Lebar2016-08-151-0/+37
| | | | | | | | | | | | | | | | | | | Summary: This patch lets you create diagnostics that are emitted if and only if a particular FunctionDecl is codegen'ed. This is necessary for CUDA, where some constructs -- e.g. calls from host+device functions to host functions when compiling for device -- are allowed to appear in semantically-correct programs, but only if they're never codegen'ed. Reviewers: rnk Subscribers: cfe-commits, tra Differential Revision: https://reviews.llvm.org/D23241 llvm-svn: 278735
* P0217R3: code generation support for decomposition declarations.Richard Smith2016-08-151-0/+4
| | | | llvm-svn: 278642
* CodeGen: try harder to make the CFString structure RWSaleem Abdulrasool2016-07-291-1/+1
| | | | | | | | The previous change was insufficient to mark the content as read-write as the structure itself was marked constant. Adjust this and add tests to ensure that the section is marked appropriately as being read-write. llvm-svn: 277200
* [OpenCL] Generate opaque type for sampler_t and function call for the ↵Yaxun Liu2016-07-281-1/+16
| | | | | | | | | | | | | | | | initializer Currently Clang use int32 to represent sampler_t, which have been a source of issue for some backends, because in some backends sampler_t cannot be represented by int32. They have to depend on kernel argument metadata and use IPA to find the sampler arguments and global variables and transform them to target specific sampler type. This patch uses opaque pointer type opencl.sampler_t* for sampler_t. For each use of file-scope sampler variable, it generates a function call of __translate_sampler_initializer. For each initialization of function-scope sampler variable, it generates a function call of __translate_sampler_initializer. Each builtin library can implement its own __translate_sampler_initializer(). Since the real sampler type tends to be architecture dependent, allowing it to be initialized by a library function simplifies backend design. A typical implementation of __translate_sampler_initializer could be a table lookup of real sampler literal values. Since its argument is always a literal, the returned pointer is known at compile time and easily optimized to finally become some literal values directly put into image read instructions. This patch is partially based on Alexey Sotkin's work in Khronos Clang (https://github.com/KhronosGroup/SPIR/commit/3d4eec61623502fc306e8c67c9868be2b136e42b). Differential Revision: https://reviews.llvm.org/D21567 llvm-svn: 277024
* P0217R3: Parsing support and framework for AST representation of C++1zRichard Smith2016-07-221-0/+1
| | | | | | | | | | | decomposition declarations. There are a couple of things in the wording that seem strange here: decomposition declarations are permitted at namespace scope (which we partially support here) and they are permitted as the declaration in a template (which we reject). llvm-svn: 276492
* [modules] Don't emit initializers for VarDecls within a module eagerly wheneverRichard Smith2016-07-201-5/+11
| | | | | | | | | | | | we first touch any part of that module. Instead, defer them until the first time that module is (transitively) imported. The initializer step for a module then recursively initializes modules that its own headers imported. For example, this avoids running the <iostream> global initializer in programs that don't actually use iostreams, but do use other parts of the standard library. llvm-svn: 276159
* [NFC] Header cleanupMehdi Amini2016-07-181-1/+0
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* [CodeGen] Treat imported static local variables as declarationsDavid Majnemer2016-07-111-0/+4
| | | | | | | Imported variables cannot really be definitions for the purposes of IR generation. llvm-svn: 275040
* CodeGen: tweak CFString section for COFF, ELFSaleem Abdulrasool2016-07-091-3/+1
| | | | | | | | | Place the structure data into `cfstring`. This both isolates the structures to permit coalescing in the future (by the linker) as well as ensures that it doesnt get marked as read-only data. The structures themselves are not read-only, only the string contents. llvm-svn: 274956
* PR28394: For compatibility with c++11 and c++14, if a static constexpr dataRichard Smith2016-07-021-1/+13
| | | | | | | | member is redundantly redeclared outside the class definition in code built in c++17 mode, ensure we emit a non-discardable definition of the data member for c++11 and c++14 compilations to use. llvm-svn: 274416
* fix typo; NFCSanjay Patel2016-06-301-1/+1
| | | | llvm-svn: 274278
* [CUDA] Give templated device functions internal linkage, templated kernels ↵Justin Lebar2016-06-301-3/+12
| | | | | | | | | | | | | | | | | external linkage. Summary: This lets LLVM perform IPO over these functions. In particular, it allows LLVM to emit ld.global.nc for loads to __restrict pointers in kernels that are never written to. Reviewers: rsmith Subscribers: cfe-commits, tra Differential Revision: http://reviews.llvm.org/D21337 llvm-svn: 274261
* P0136R1, DR1573, DR1645, DR1715, DR1736, DR1903, DR1941, DR1959, DR1991:Richard Smith2016-06-281-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace inheriting constructors implementation with new approach, voted into C++ last year as a DR against C++11. Instead of synthesizing a set of derived class constructors for each inherited base class constructor, we make the constructors of the base class visible to constructor lookup in the derived class, using the normal rules for using-declarations. For constructors, UsingShadowDecl now has a ConstructorUsingShadowDecl derived class that tracks the requisite additional information. We create shadow constructors (not found by name lookup) in the derived class to model the actual initialization, and have a new expression node, CXXInheritedCtorInitExpr, to model the initialization of a base class from such a constructor. (This initialization is special because it performs real perfect forwarding of arguments.) In cases where argument forwarding is not possible (for inalloca calls, variadic calls, and calls with callee parameter cleanup), the shadow inheriting constructor is not emitted and instead we directly emit the initialization code into the caller of the inherited constructor. Note that this new model is not perfectly compatible with the old model in some corner cases. In particular: * if B inherits a private constructor from A, and C uses that constructor to construct a B, then we previously required that A befriends B and B befriends C, but the new rules require A to befriend C directly, and * if a derived class has its own constructors (and so its implicit default constructor is suppressed), it may still inherit a default constructor from a base class llvm-svn: 274049
* Implement C++17 P0386R2, inline variables. (The 'inline' specifier gives aRichard Smith2016-06-251-0/+6
| | | | | | | variable weak discardable linkage and partially-ordered initialization, and is implied for constexpr static data members.) llvm-svn: 273754
* CodeGen: Update Clang to use the new type metadata.Peter Collingbourne2016-06-241-50/+20
| | | | | | Differential Revision: http://reviews.llvm.org/D21054 llvm-svn: 273730
* Restructure the propagation of -fPIC/-fPIE.Rafael Espindola2016-06-231-5/+2
| | | | | | | | | | | | | The PIC and PIE levels are not independent. In fact, if PIE is defined it is always the same as PIC. This is clear in the driver where ParsePICArgs returns a PIC level and a IsPIE boolean. Unfortunately that is currently lost and we pass two redundant levels down the pipeline. This patch keeps a bool and a PIC level all the way down to codegen. llvm-svn: 273566
* Remove MaxFunctionCount module flag annotation.Easwaran Raman2016-06-201-1/+0
| | | | | | Differential revision: http://reviews.llvm.org/D19184 llvm-svn: 273198
* Update clang for D20348Peter Collingbourne2016-06-141-6/+6
| | | | | | Differential Revision: http://reviews.llvm.org/D20339 llvm-svn: 272710
* CodeGen: tweak CFString emission for COFF targetsSaleem Abdulrasool2016-06-011-0/+21
| | | | | | | | | The `isa' member was previously not given the correct DLL Storage. Ensure that we give the `isa' constant `__CFConstantStringClassReference' the correct DLL storage. Default to dllimport unless an explicit specification gives it a dllexport storage. llvm-svn: 271361
* CodeGen: address post-commit review commentsSaleem Abdulrasool2016-05-301-1/+1
| | | | | | David Majnemer pointed out that isOSBinFormatMachO is more compact. NFC. llvm-svn: 271221
* CodeGen: tweak CFConstantStrings for COFF and ELFSaleem Abdulrasool2016-05-301-20/+31
| | | | | | | | Adjust the constant CFString emission to emit into more appropriate sections on ELF and COFF targets. It would previously try to use MachO section names irrespective of the file format. llvm-svn: 271211
* Check for nullptr argument.Artem Belevich2016-05-191-2/+2
| | | | | | | | Addresses static analysis report in PR15492. Differential Revision: http://reviews.llvm.org/D20141 llvm-svn: 270086
* Reapply^3 "[ProfileData] (clang) Use Error in InstrProf and Coverage, NFC"Vedant Kumar2016-05-191-3/+5
| | | | | | Sync up with "(llvm) Use Error in InstrProf and Coverage". llvm-svn: 270021
* Revert "Reapply^2 "[ProfileData] (clang) Use Error in InstrProf and ↵Vedant Kumar2016-05-161-5/+3
| | | | | | | | Coverage, NFC"" This reverts commit r269695. The llvm commit does not pass the MSVC bot. llvm-svn: 269701
* Reapply^2 "[ProfileData] (clang) Use Error in InstrProf and Coverage, NFC"Vedant Kumar2016-05-161-3/+5
| | | | | | | | Sync up with "(llvm) Use Error in InstrProf and Coverage". Differential Revision: http://reviews.llvm.org/D19902 llvm-svn: 269695
* Revert "Reapply "[ProfileData] (clang) Use Error in InstrProf and Coverage, ↵Chandler Carruth2016-05-141-5/+3
| | | | | | | | | | NFC"" This reverts commit r269492 as the corresponding LLVM commit was reverted due to lots of warnings. See the review thread for the original LLVM commit (r269491) for details. llvm-svn: 269549
* Reapply "[ProfileData] (clang) Use Error in InstrProf and Coverage, NFC"Vedant Kumar2016-05-131-3/+5
| | | | | | | | Sync up with "(llvm) Use Error in InstrProf and Coverage". Differential Revision: http://reviews.llvm.org/D19902 llvm-svn: 269492
* Revert "[ProfileData] (clang) Use Error in InstrProf and Coverage, NFC"Vedant Kumar2016-05-131-5/+3
| | | | | | This reverts commit r269463. It fails two llvm-profdata tests. llvm-svn: 269468
* [ProfileData] (clang) Use Error in InstrProf and Coverage, NFCVedant Kumar2016-05-131-3/+5
| | | | | | Sync up with "(llvm) Use Error in InstrProf and Coverage". llvm-svn: 269463
* Differential Revision: http://reviews.llvm.org/D19687Sriraman Tallam2016-04-281-8/+6
| | | | | | Set module flag PIELevel. Simplify code that sets PICLevel flag. llvm-svn: 267948
* Re-apply r267784, r267824 and r267830.Peter Collingbourne2016-04-281-3/+1
| | | | | | I have updated the compiler-rt tests. llvm-svn: 267903
* Revert r267784, r267824 and r267830.Benjamin Kramer2016-04-281-1/+3
| | | | | | | | | | It makes compiler-rt tests fail if the gold plugin is enabled. Revert "Rework interface for bitset-using features to use a notion of LTO visibility." Revert "Driver: only produce CFI -fvisibility= error when compiling." Revert "clang/test/CodeGenCXX/cfi-blacklist.cpp: Exclude ms targets. They would be non-cfi." llvm-svn: 267871
* Rework interface for bitset-using features to use a notion of LTO visibility.Peter Collingbourne2016-04-271-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Bitsets, and the compiler features they rely on (vtable opt, CFI), only have visibility within the LTO'd part of the linkage unit. Therefore, only enable these features for classes with hidden LTO visibility. This notion is based on object file visibility or (on Windows) dllimport/dllexport attributes. We provide the [[clang::lto_visibility_public]] attribute to override the compiler's LTO visibility inference in cases where the class is defined in the non-LTO'd part of the linkage unit, or where the ABI supports calling classes derived from abstract base classes with hidden visibility in other linkage units (e.g. COM on Windows). If the cross-DSO CFI mode is enabled, bitset checks are emitted even for classes with public LTO visibility, as that mode uses a separate mechanism to cause bitsets to be exported. This mechanism replaces the whole-program-vtables blacklist, so remove the -fwhole-program-vtables-blacklist flag. Because __declspec(uuid()) now implies [[clang::lto_visibility_public]], the support for the special attr:uuid blacklist entry is removed. Differential Revision: http://reviews.llvm.org/D18635 llvm-svn: 267784
* [CodeGen] Avoid ctor/dtor boilerplate with some C++11Reid Kleckner2016-04-131-31/+13
| | | | | | | | | | | | | | Non-owning pointers that cache LLVM types and constants can use 'nullptr' default member initializers so that we don't need to mention them in the constructor initializer list. Owning pointers should use std::unique_ptr so that we don't need to manually delete them in the destructor. They also don't need to be mentioned in the constructor at that point. NFC llvm-svn: 266263
* [GCC] Attribute ifunc support in clangDmitry Polukhin2016-04-111-21/+100
| | | | | | | | | | | This patch add support for GCC attribute((ifunc("resolver"))) for targets that use ELF as object file format. In general ifunc is a special kind of function alias with type @gnu_indirect_function. LLVM patch http://reviews.llvm.org/D15525 Differential Revision: http://reviews.llvm.org/D15524 llvm-svn: 265917
* revert SVN r265702, r265640Saleem Abdulrasool2016-04-081-1/+1
| | | | | | | | | | | Revert the two changes to thread CodeGenOptions into the TargetInfo allocation and to fix the layering violation by moving CodeGenOptions into Basic. Code Generation is arguably not particularly "basic". This addresses Richard's post-commit review comments. This change purely does the mechanical revert and will be followed up with an alternate approach to thread the desired information into TargetInfo. llvm-svn: 265806
* Adapt to LLVM API changeSanjoy Das2016-04-081-1/+1
| | | | | | Replace mayBeOverridden with isInterposable llvm-svn: 265767
* Replace Sema-level implementation of -fassume-sane-operator-new with aRichard Smith2016-04-071-3/+13
| | | | | | | | | | | | | | CodeGen-level implementation. Instead of adding an attribute to clang's FunctionDecl, add the IR attribute directly. This means a module built with this flag is now compatible with code built without it and vice versa. This change also results in the 'noalias' attribute no longer being added to calls to operator new in the IR; it's now only added to the declaration. It also fixes a bug where we failed to add the attribute to the 'nothrow' versions (because we didn't implicitly declare them, there was no good time to inject a fake attribute). llvm-svn: 265728
* Basic: move CodeGenOptions from FrontendSaleem Abdulrasool2016-04-071-1/+1
| | | | | | | | This is a mechanical move of CodeGenOptions from libFrontend to libBasic. This fixes the layering violation introduced earlier by threading CodeGenOptions into TargetInfo. It should also fix the modules based self-hosting builds. NFC. llvm-svn: 265702
OpenPOWER on IntegriCloud