aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-09-11CodeGen: remove unnecessary else caseSaleem Abdulrasool1-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
2016-09-08C++ Modules TS: Add parsing and some semantic analysis support forRichard Smith1-15/+16
export-declarations. These don't yet have an effect on name visibility; we still export everything by default. llvm-svn: 280999
2016-08-31Add -fprofile-dir= to clang.Nick Lewycky1-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
2016-08-19Re-commit [OpenCL] AMDGCN: Fix size_t typeYaxun Liu1-1/+4
There was a premature cast to pointer type in emitPointerArithmetic which caused assertion in tests with assertion enabled. llvm-svn: 279206
2016-08-18Revert [OpenCL] AMDGCN: Fix size_t typeYaxun Liu1-4/+1
due to regressions in test/CodeGen/exprs.c on certain platforms. llvm-svn: 279127
2016-08-18[OpenCL] AMDGCN: Fix size_t typeYaxun Liu1-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
2016-08-15Add the notion of deferred diagnostics.Justin Lebar1-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
2016-08-15P0217R3: code generation support for decomposition declarations.Richard Smith1-0/+4
llvm-svn: 278642
2016-07-29CodeGen: try harder to make the CFString structure RWSaleem Abdulrasool1-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
2016-07-28[OpenCL] Generate opaque type for sampler_t and function call for the ↵Yaxun Liu1-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
2016-07-22P0217R3: Parsing support and framework for AST representation of C++1zRichard Smith1-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
2016-07-20[modules] Don't emit initializers for VarDecls within a module eagerly wheneverRichard Smith1-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
2016-07-18[NFC] Header cleanupMehdi Amini1-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
2016-07-11[CodeGen] Treat imported static local variables as declarationsDavid Majnemer1-0/+4
Imported variables cannot really be definitions for the purposes of IR generation. llvm-svn: 275040
2016-07-09CodeGen: tweak CFString section for COFF, ELFSaleem Abdulrasool1-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
2016-07-02PR28394: For compatibility with c++11 and c++14, if a static constexpr dataRichard Smith1-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
2016-06-30fix typo; NFCSanjay Patel1-1/+1
llvm-svn: 274278
2016-06-30[CUDA] Give templated device functions internal linkage, templated kernels ↵Justin Lebar1-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
2016-06-28P0136R1, DR1573, DR1645, DR1715, DR1736, DR1903, DR1941, DR1959, DR1991:Richard Smith1-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
2016-06-25Implement C++17 P0386R2, inline variables. (The 'inline' specifier gives aRichard Smith1-0/+6
variable weak discardable linkage and partially-ordered initialization, and is implied for constexpr static data members.) llvm-svn: 273754
2016-06-24CodeGen: Update Clang to use the new type metadata.Peter Collingbourne1-50/+20
Differential Revision: http://reviews.llvm.org/D21054 llvm-svn: 273730
2016-06-23Restructure the propagation of -fPIC/-fPIE.Rafael Espindola1-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
2016-06-20Remove MaxFunctionCount module flag annotation.Easwaran Raman1-1/+0
Differential revision: http://reviews.llvm.org/D19184 llvm-svn: 273198
2016-06-14Update clang for D20348Peter Collingbourne1-6/+6
Differential Revision: http://reviews.llvm.org/D20339 llvm-svn: 272710
2016-06-01CodeGen: tweak CFString emission for COFF targetsSaleem Abdulrasool1-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
2016-05-30CodeGen: address post-commit review commentsSaleem Abdulrasool1-1/+1
David Majnemer pointed out that isOSBinFormatMachO is more compact. NFC. llvm-svn: 271221
2016-05-30CodeGen: tweak CFConstantStrings for COFF and ELFSaleem Abdulrasool1-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
2016-05-19Check for nullptr argument.Artem Belevich1-2/+2
Addresses static analysis report in PR15492. Differential Revision: http://reviews.llvm.org/D20141 llvm-svn: 270086
2016-05-19Reapply^3 "[ProfileData] (clang) Use Error in InstrProf and Coverage, NFC"Vedant Kumar1-3/+5
Sync up with "(llvm) Use Error in InstrProf and Coverage". llvm-svn: 270021
2016-05-16Revert "Reapply^2 "[ProfileData] (clang) Use Error in InstrProf and ↵Vedant Kumar1-5/+3
Coverage, NFC"" This reverts commit r269695. The llvm commit does not pass the MSVC bot. llvm-svn: 269701
2016-05-16Reapply^2 "[ProfileData] (clang) Use Error in InstrProf and Coverage, NFC"Vedant Kumar1-3/+5
Sync up with "(llvm) Use Error in InstrProf and Coverage". Differential Revision: http://reviews.llvm.org/D19902 llvm-svn: 269695
2016-05-14Revert "Reapply "[ProfileData] (clang) Use Error in InstrProf and Coverage, ↵Chandler Carruth1-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
2016-05-13Reapply "[ProfileData] (clang) Use Error in InstrProf and Coverage, NFC"Vedant Kumar1-3/+5
Sync up with "(llvm) Use Error in InstrProf and Coverage". Differential Revision: http://reviews.llvm.org/D19902 llvm-svn: 269492
2016-05-13Revert "[ProfileData] (clang) Use Error in InstrProf and Coverage, NFC"Vedant Kumar1-5/+3
This reverts commit r269463. It fails two llvm-profdata tests. llvm-svn: 269468
2016-05-13[ProfileData] (clang) Use Error in InstrProf and Coverage, NFCVedant Kumar1-3/+5
Sync up with "(llvm) Use Error in InstrProf and Coverage". llvm-svn: 269463
2016-04-28Differential Revision: http://reviews.llvm.org/D19687Sriraman Tallam1-8/+6
Set module flag PIELevel. Simplify code that sets PICLevel flag. llvm-svn: 267948
2016-04-28Re-apply r267784, r267824 and r267830.Peter Collingbourne1-3/+1
I have updated the compiler-rt tests. llvm-svn: 267903
2016-04-28Revert r267784, r267824 and r267830.Benjamin Kramer1-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
2016-04-27Rework interface for bitset-using features to use a notion of LTO visibility.Peter Collingbourne1-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
2016-04-13[CodeGen] Avoid ctor/dtor boilerplate with some C++11Reid Kleckner1-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
2016-04-11[GCC] Attribute ifunc support in clangDmitry Polukhin1-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
2016-04-08revert SVN r265702, r265640Saleem Abdulrasool1-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
2016-04-08Adapt to LLVM API changeSanjoy Das1-1/+1
Replace mayBeOverridden with isInterposable llvm-svn: 265767
2016-04-07Replace Sema-level implementation of -fassume-sane-operator-new with aRichard Smith1-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
2016-04-07Basic: move CodeGenOptions from FrontendSaleem Abdulrasool1-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
2016-04-05[CUDA] Add -fcuda-flush-denormals-to-zero.Justin Lebar1-0/+8
Summary: Setting this flag causes all functions are annotated with the "nvvm-f32ftz" = "true" attribute. In addition, we annotate the module with "nvvm-reflect-ftz" set to 0 or 1, depending on whether -cuda-flush-denormals-to-zero is set. This is read by the NVVMReflect pass. Reviewers: tra, rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18671 llvm-svn: 265435
2016-03-28Fix serialization/deserialization for __uuidofDavid Majnemer1-1/+1
I broke this back in r264529 because I forgot to serialize the UuidAttr member. Fix this by replacing the UuidAttr with a StringRef which is properly serialized and deserialized. llvm-svn: 264562
2016-03-27Use the correct alignment for uuid descriptorsDavid Majnemer1-2/+2
The _GUID_ descriptors emitted by MSVC have alignment 8 for 64-bit builds: we should do the same if the linker picks the "wrong" COMDAT. llvm-svn: 264530
2016-03-27Improve the representation of CXXUuidofExprDavid Majnemer1-1/+1
Keep a pointer to the UuidAttr that the CXXUuidofExpr corresponds to. This makes translating from __uuidof to the underlying constant a lot more straightforward. llvm-svn: 264529
2016-03-24Attach profile summary information to Module.Easwaran Raman1-0/+1
Differential Revision: http://reviews.llvm.org/D18289 llvm-svn: 264342