summaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/CodeGenModule.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merging r323935:Hans Wennborg2018-02-051-17/+1
| | | | | | | | | | | | | | | ------------------------------------------------------------------------ r323935 | rsmith | 2018-02-01 01:28:36 +0100 (Thu, 01 Feb 2018) | 5 lines PR36181: Teach CodeGen to properly ignore requests to emit dependent entities. Previously, friend function definitions within class templates slipped through the gaps and caused the MS mangler to assert. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324215 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Support for -fopenmp-simd option with compilation of simd loopsAlexey Bataev2017-12-291-1/+7
| | | | | | | | | only. Added support for -fopenmp-simd option that allows compilation of simd-based constructs without emission of OpenMP runtime calls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321560 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Fix for PR32990"Reid Kleckner2017-12-211-33/+9
| | | | | | | | | | | | This reverts commit r321239. It broke the Chromium DLL build: [8834/50217] LINK(DLL) icui18n.dll icui18n.dll.lib icui18n.dll.pdb FAILED: icui18n.dll icui18n.dll.lib icui18n.dll.pdb zrule.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl icu_60::UnicodeString::`vbase destructor'(void)" (__imp_??_DUnicodeString@icu_60@@QEAAXXZ) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321298 91177308-0d34-0410-b5e6-96231b3b80d8
* [AARch64] Add ARMv8.2-A FP16 vector intrinsicsAbderrazek Zaafrani2017-12-211-0/+1
| | | | | | | | Putting back the code that was reverted few weeks ago. Differential Revision: https://reviews.llvm.org/D34161 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321294 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix for PR32990Erich Keane2017-12-211-9/+33
| | | | | | | | | | This fixes the bug in https://bugs.llvm.org/show_bug.cgi?id=32990. Patch By: zahiraam Differential Revision: https://reviews.llvm.org/D39063 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321239 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Fix use-after free in coverage emissionEli Friedman2017-12-191-1/+5
| | | | | | | | | | | | | Fixes regression from r320533. This fixes the undefined behavior, but I'm not sure it's really right... I think we end up with missing coverage for code in modules. Differential Revision: https://reviews.llvm.org/D41374 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321052 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Codegen `declare simd` for function declarations.Alexey Bataev2017-12-151-0/+3
| | | | | | | Previously the attributes were emitted only for function definitions. Patch adds emission of the attributes for function declarations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320826 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Always emit unused coverage mappings in the same order.Eli Friedman2017-12-131-13/+3
| | | | | | | | | | Non-determinism is confusing at best. Differential Revision: https://reviews.llvm.org/D41140 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320533 91177308-0d34-0410-b5e6-96231b3b80d8
* Hardware-assisted AddressSanitizer (clang part).Evgeniy Stepanov2017-12-091-1/+1
| | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320232 91177308-0d34-0410-b5e6-96231b3b80d8
* Mark all library options as hidden.Zachary Turner2017-12-011-1/+1
| | | | | | | | | | | | | | | | | These command line options are not intended for public use, and often don't even make sense in the context of a particular tool anyway. About 90% of them are already hidden, but when people add new options they forget to hide them, so if you were to make a brand new tool today, link against one of LLVM's libraries, and run tool -help you would get a bunch of junk that doesn't make sense for the tool you're writing. This patch hides these options. The real solution is to not have libraries defining command line options, but that's a much larger effort and not something I'm prepared to take on. Differential Revision: https://reviews.llvm.org/D40674 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319505 91177308-0d34-0410-b5e6-96231b3b80d8
* Reland "Fix vtable not receiving hidden visibility when using push(visibility)"Jake Ehrlich2017-11-291-13/+13
| | | | | | | | | | I had to reland this change in order to make the test work on windows This change should resolve https://bugs.llvm.org/show_bug.cgi?id=35022 https://reviews.llvm.org/D39627 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319269 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Collect information about sizes of accesses and access types for TBAAIvan A. Kosarev2017-11-271-4/+11
| | | | | | | | | | | | | | | The information about access and type sizes is necessary for producing TBAA metadata in the new size-aware format. With this patch, D39955 and D39956 in place we should be able to change CodeGenTBAA::createScalarTypeNode() and CodeGenTBAA::getBaseTypeInfo() to generate metadata in the new format under the -new-struct-path-tbaa command-line option. For now, this new information remains unused. Differential Revision: https://reviews.llvm.org/D40176 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319012 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[CodeGen] Fix vtable not receiving hidden visibility when using ↵Petr Hosek2017-11-221-13/+13
| | | | | | | | push(visibility)" This reverts commit r318853: tests are failing on Windows bots git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318866 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Fix vtable not receiving hidden visibility when using push(visibility)Petr Hosek2017-11-221-13/+13
| | | | | | | | | | This change should resolve https://bugs.llvm.org/show_bug.cgi?id=35022 Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D39627 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318853 91177308-0d34-0410-b5e6-96231b3b80d8
* Add CLANG_DEFAULT_OBJCOPY to allow Clang to use llvm-objcopy for dwarf fissionJake Ehrlich2017-11-111-22/+22
| | | | | | | | | | | | llvm-objcopy is getting to where it can be used in non-trivial ways (such as for dwarf fission in clang). It now supports dwarf fission but this feature hasn't been thoroughly tested yet. This change allows people to optionally build clang to use llvm-objcopy rather than GNU objcopy. By default GNU objcopy is still used so nothing should change. Differential Revision: https://reviews.llvm.org/D39029 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@317960 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGenCXX: no default dllimport storage for mingwMartell Malone2017-11-041-1/+2
| | | | | | | | | | | GNU frontends don't have options like /MT, /MD This fixes a few link error regressions with libc++ and libc++abi Reviewers: rnk, mstorsjo, compnerd Differential Revision: https://reviews.llvm.org/D33620 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@317398 91177308-0d34-0410-b5e6-96231b3b80d8
* [c++17] Visit class template explicit specializations just like all other ↵Richard Smith2017-11-031-9/+7
| | | | | | | | | class definitions in codegen. If an explicit specialization has a static data member, it may be a definition and we may need to register it for emission. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@317296 91177308-0d34-0410-b5e6-96231b3b80d8
* [CFI] Add CFI-icall pointer type generalizationVlad Tsyrklevich2017-10-311-0/+55
| | | | | | | | | | | | | | | | | | | | | | | Summary: This change allows generalizing pointers in type signatures used for cfi-icall by enabling the -fsanitize-cfi-icall-generalize-pointers flag. This works by 1) emitting an additional generalized type signature metadata node for functions and 2) llvm.type.test()ing for the generalized type for translation units with the flag specified. This flag is incompatible with -fsanitize-cfi-cross-dso because it would require emitting twice as many type hashes which would increase artifact size. Reviewers: pcc, eugenis Reviewed By: pcc Subscribers: kcc Differential Revision: https://reviews.llvm.org/D39358 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@317044 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Propagate may-alias'ness of lvalues with TBAA infoIvan A. Kosarev2017-10-311-5/+7
| | | | | | | | | | | | | | This patch fixes various places in clang to propagate may-alias TBAA access descriptors during construction of lvalues, thus eliminating the need for the LValueBaseInfo::MayAlias flag. This is part of D38126 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D39008 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316988 91177308-0d34-0410-b5e6-96231b3b80d8
* Filter out invalid 'target' items from being passed to LLVMErich Keane2017-10-271-2/+11
| | | | | | | | | | | | | | | | | | | Craig noticed that CodeGen wasn't properly ignoring the values sent to the target attribute. This patch ignores them. This patch also sets the 'default' for this checking to 'supported', since only X86 has implemented the support for checking valid CPU names and Feature Names. One test was changed to i686, since it uses a lakemont, which would otherwise be prohibited in x86_64. Differential Revision: https://reviews.llvm.org/D39357 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316783 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue ↵Ivan A. Kosarev2017-10-171-0/+7
| | | | | | | | | base info Differential Revision: https://reviews.llvm.org/D38796 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315984 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert clang::LangAS to a strongly typed enumAlexander Richardson2017-10-151-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Convert clang::LangAS to a strongly typed enum Currently both clang AST address spaces and target specific address spaces are represented as unsigned which can lead to subtle errors if the wrong type is passed. It is especially confusing in the CodeGen files as it is not possible to see what kind of address space should be passed to a function without looking at the implementation. I originally made this change for our LLVM fork for the CHERI architecture where we make extensive use of address spaces to differentiate between capabilities and pointers. When merging the upstream changes I usually run into some test failures or runtime crashes because the wrong kind of address space is passed to a function. By converting the LangAS enum to a C++11 we can catch these errors at compile time. Additionally, it is now obvious from the function signature which kind of address space it expects. I found the following errors while writing this patch: - ItaniumRecordLayoutBuilder::LayoutField was passing a clang AST address space to TargetInfo::getPointer{Width,Align}() - TypePrinter::printAttributedAfter() prints the numeric value of the clang AST address space instead of the target address space. However, this code is not used so I kept the current behaviour - initializeForBlockHeader() in CGBlocks.cpp was passing LangAS::opencl_generic to TargetInfo::getPointer{Width,Align}() - CodeGenFunction::EmitBlockLiteral() was passing a AST address space to TargetInfo::getPointerWidth() - CGOpenMPRuntimeNVPTX::translateParameter() passed a target address space to Qualifiers::addAddressSpace() - CGOpenMPRuntimeNVPTX::getParameterAddress() was using llvm::Type::getPointerTo() with a AST address space - clang_getAddressSpace() returns either a LangAS or a target address space. As this is exposed to C I have kept the current behaviour and added a comment stating that it is probably not correct. Other than this the patch should not cause any functional changes. Reviewers: yaxunl, pcc, bader Reviewed By: yaxunl, bader Subscribers: jlebar, jholewinski, nhaehnle, Anastasia, cfe-commits Differential Revision: https://reviews.llvm.org/D38816 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315871 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[CodeGen] EmitPointerWithAlignment() to generate TBAA info along ↵Ivan A. Kosarev2017-10-131-7/+0
| | | | | | | | | | | with LValue base info", r315731. With this change we fail on the clang-x86_64-linux-selfhost-modules builder. Differential Revision: https://reviews.llvm.org/D38796 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315739 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue ↵Ivan A. Kosarev2017-10-131-0/+7
| | | | | | | | | base info Differential Revision: https://reviews.llvm.org/D38796 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315731 91177308-0d34-0410-b5e6-96231b3b80d8
* Refine generation of TBAA information in clangIvan A. Kosarev2017-10-061-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is an attempt to clarify and simplify generation and propagation of TBAA information. The idea is to pack all values that describe a memory access, namely, base type, access type and offset, into a single structure. This is supposed to make further changes, such as adding support for unions and array members, easier to prepare and review. DecorateInstructionWithTBAA() is no more responsible for converting types to tags. These implicit conversions not only complicate reading the code, but also suggest assigning scalar access tags while we generally prefer full-size struct-path tags. TBAAPathTag is replaced with TBAAAccessInfo; the latter is now the type of the keys of the cache map that translates access descriptors to metadata nodes. Fixed a bug with writing to a wrong map in getTBAABaseTypeMetadata() (former getTBAAStructTypeInfo()). We now check for valid base access types every time we dereference a field. The original code only checks the top-level base type. See isValidBaseType() / isTBAAPathStruct() calls. Some entities have been renamed to sound more adequate and less confusing/misleading in presence of path-aware TBAA information. Now we do not lookup twice for the same cache entry in getAccessTagInfo(). Refined relevant comments and descriptions. Differential Revision: https://reviews.llvm.org/D37826 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315048 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Unify generation of scalar and struct-path TBAA tagsIvan A. Kosarev2017-10-051-19/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes it possible to produce access tags in a uniform manner regardless whether the resulting tag will be a scalar or a struct-path one. getAccessTagInfo() now takes care of the actual translation of access descriptors to tags and can handle all kinds of accesses. Facilities that specific to scalar accesses are eliminated. Some more details: * DecorateInstructionWithTBAA() is not responsible for conversion of types to access tags anymore. Instead, it takes an access descriptor (TBAAAccessInfo) and generates corresponding access tag from it. * getTBAAInfoForVTablePtr() reworked to getTBAAVTablePtrAccessInfo() that now returns the virtual-pointer access descriptor and not the virtual-point type metadata. * Added function getTBAAMayAliasAccessInfo() that returns the descriptor for may-alias accesses. * getTBAAStructTagInfo() renamed to getTBAAAccessTagInfo() as now it is the only way to generate access tag by a given access descriptor. It is capable of producing both scalar and struct-path tags, depending on options and availability of the base access type. getTBAAScalarTagInfo() and its cache ScalarTagMetadataCache are eliminated. * Now that we do not need to care about whether the resulting access tag should be a scalar or struct-path one, getTBAAStructTypeInfo() is renamed to getBaseTypeInfo(). * Added function getTBAAAccessInfo() that constructs access descriptor by a given QualType access type. This is part of D37826 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38503 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314979 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r314977 "[CodeGen] Unify generation of scalar and struct-path TBAA tags"Ivan A. Kosarev2017-10-051-20/+18
| | | | | | | | | D37826 has been mistakenly committed where it should be the patch from D38503. Differential Revision: https://reviews.llvm.org/D38503 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314978 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Unify generation of scalar and struct-path TBAA tagsIvan A. Kosarev2017-10-051-18/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes it possible to produce access tags in a uniform manner regardless whether the resulting tag will be a scalar or a struct-path one. getAccessTagInfo() now takes care of the actual translation of access descriptors to tags and can handle all kinds of accesses. Facilities that specific to scalar accesses are eliminated. Some more details: * DecorateInstructionWithTBAA() is not responsible for conversion of types to access tags anymore. Instead, it takes an access descriptor (TBAAAccessInfo) and generates corresponding access tag from it. * getTBAAInfoForVTablePtr() reworked to getTBAAVTablePtrAccessInfo() that now returns the virtual-pointer access descriptor and not the virtual-point type metadata. * Added function getTBAAMayAliasAccessInfo() that returns the descriptor for may-alias accesses. * getTBAAStructTagInfo() renamed to getTBAAAccessTagInfo() as now it is the only way to generate access tag by a given access descriptor. It is capable of producing both scalar and struct-path tags, depending on options and availability of the base access type. getTBAAScalarTagInfo() and its cache ScalarTagMetadataCache are eliminated. * Now that we do not need to care about whether the resulting access tag should be a scalar or struct-path one, getTBAAStructTypeInfo() is renamed to getBaseTypeInfo(). * Added function getTBAAAccessInfo() that constructs access descriptor by a given QualType access type. This is part of D37826 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38503 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314977 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Introduce generic TBAA access descriptorsIvan A. Kosarev2017-10-031-5/+2
| | | | | | | | | | | | | | With this patch we implement a concept of TBAA access descriptors that are capable of representing both scalar and struct-path accesses in a generic way. This is part of D37826 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38456 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314780 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Have a special function to get TBAA info for may-alias accessesIvan A. Kosarev2017-10-021-0/+6
| | | | | | | | | | This is part of D37826 reworked to be a separate patch to simplify review. Differential Revision: https://reviews.llvm.org/D38408 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314660 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Do not refer to complete TBAA info where we actually deal with ↵Ivan A. Kosarev2017-10-021-2/+2
| | | | | | | | | | | | | | | just TBAA access types This patch fixes misleading names of entities related to getting, setting and generation of TBAA access type descriptors. This is effectively an attempt to provide a review for D37826 by breaking it into smaller pieces. Differential Revision: https://reviews.llvm.org/D38404 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314657 91177308-0d34-0410-b5e6-96231b3b80d8
* Emit section information for extern variables. Erich Keane2017-09-261-0/+6
| | | | | | | | | | | | | | | | | | | Currently, if _attribute_((section())) is used for extern variables, section information is not emitted in generated IR when the variables are used. This is expected since sections are not generated for external linkage objects. However NiosII requires this information as it uses special GP-relative accesses for any objects that use attribute section (.sdata). GCC keeps this attribute in middle-end. This change emits the section information for all targets. Patch By: Elizabeth Andrews Differential Revision:https://reviews.llvm.org/D36487 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314262 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGenModule: Adapt to LLVM TargetLibraryInfo changesMatthias Braun2017-09-261-8/+2
| | | | | | | | Adapt to LLVM TargetLibraryInfo changes in r314185. See also https://reviews.llvm.org/D38106 and https://reviews.llvm.org/D37891 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314187 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow specifying sanitizers in blacklistsVlad Tsyrklevich2017-09-251-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314171 91177308-0d34-0410-b5e6-96231b3b80d8
* [Coverage] Add an option to emit limited coverage infoVedant Kumar2017-09-221-0/+8
| | | | | | | | | | | | | | | | | | | | | Add an option to emit limited coverage info for unused decls. It's just a cl::opt for now to allow us to experiment quickly. When building llc, this results in an 84% size reduction in the llvm_covmap section, and a similar size reduction in the llvm_prf_names section. In practice I expect the size reduction to be roughly quadratic with the size of the program. The downside is that coverage for headers will no longer be complete. This will make the line/function/region coverage metrics incorrect, since they will be artificially high. One mitigation would be to somehow disable those metrics when using limited-coverage=true. This is related to: llvm.org/PR34533 (make SourceBasedCodeCoverage scale) Differential Revision: https://reviews.llvm.org/D38107 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314002 91177308-0d34-0410-b5e6-96231b3b80d8
* [codeview] omit debug locations for nested exprs unless column info enabledBob Haarman2017-09-111-0/+4
| | | | | | | | | | | | | | | | | | | | | | Summary: Microsoft Visual Studio expects debug locations to correspond to statements. We used to emit locations for expressions nested inside statements. This would confuse the debugger, causing it to stop multiple times on the same line and breaking the "step into specific" feature. This change inhibits the emission of debug locations for nested expressions when emitting CodeView debug information, unless column information is enabled. Fixes PR34312. Reviewers: rnk, zturner Reviewed By: rnk Subscribers: majnemer, echristo, aprantl, cfe-commits Differential Revision: https://reviews.llvm.org/D37529 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@312965 91177308-0d34-0410-b5e6-96231b3b80d8
* Emit static constexpr member as available_externally definitionMehdi Amini2017-09-051-0/+42
| | | | | | | | | | | | | | | | | | By exposing the constant initializer, the optimizer can fold many of these constructs. This is a recommit of r311857 that was reverted in r311898 because an assert was hit when building Chromium. We have to take into account that the GlobalVariable may be first created with a different type than the initializer. This can happen for example when the variable is a struct with tail padding while the initializer does not have padding. In such case, the variable needs to be destroyed an replaced with a new one with the type of the initializer. Differential Revision: https://reviews.llvm.org/D34992 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@312512 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r311857 "Emit static constexpr member as available_externally definition"Hans Wennborg2017-08-281-22/+0
| | | | | | | | | | | | | It caused PR759744. > Emit static constexpr member as available_externally definition > > By exposing the constant initializer, the optimizer can fold many > of these constructs. > > Differential Revision: https://reviews.llvm.org/D34992 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311898 91177308-0d34-0410-b5e6-96231b3b80d8
* Emit static constexpr member as available_externally definitionMehdi Amini2017-08-271-0/+22
| | | | | | | | | By exposing the constant initializer, the optimizer can fold many of these constructs. Differential Revision: https://reviews.llvm.org/D34992 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311857 91177308-0d34-0410-b5e6-96231b3b80d8
* Extract IRGen's constant-emitter into its own helper class and clean upJohn McCall2017-08-151-5/+16
| | | | | | | | | | | | the interface. The ultimate goal here is to make it easier to do some more interesting things in constant emission, like emit constant initializers that have ignorable side-effects, or doing the majority of an initialization in-place and then patching up the last few things with calls. But for now this is mostly just a refactoring. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310964 91177308-0d34-0410-b5e6-96231b3b80d8
* [OpenCL] Allow targets to select address space per typeSven van Haastregt2017-08-151-1/+1
| | | | | | | | | | | | | | Generalize getOpenCLImageAddrSpace into getOpenCLTypeAddrSpace, such that targets can select the address space per type. No functional changes intended. Initial patch by Simon Perretta. Differential Revision: https://reviews.llvm.org/D33989 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310911 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGenModule.cpp: [PR33810][Modules] Remove an assertion that confirms ↵NAKAMURA Takumi2017-07-301-2/+0
| | | | | | | | MangledDeclNames[CanonicalGD] might be still empty. FIXME: It is accepted that MangledDeclNames[CanonicalGD] is overwritten here? git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309504 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGenModule.cpp: [PR33810][Modules] Avoid reusing FoundStr to try to fix ↵NAKAMURA Takumi2017-07-301-6/+6
| | | | | | | | crash. MangledDeclNames might grow up and be reallocated when it were reused by reentering CodeGenModule::getMangledName(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309501 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGenModule.cpp: [PR33810][Modules] Make sure actual memory corruption ↵NAKAMURA Takumi2017-07-301-0/+2
| | | | | | before random crash with -fmodules. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309499 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen][mips] Support `long_call/far/near` attributesSimon Atanasyan2017-07-201-4/+12
| | | | | | | | | | | This patch adds support for the `long_call`, `far`, and `near` attributes for MIPS targets. The `long_call` and `far` attributes are synonyms. All these attributes override `-mlong-calls` / `-mno-long-calls` command line options for particular function. Differential revision: https://reviews.llvm.org/D35479 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308667 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert attribute 'target' parsing from a 'pair' to a 'struct' to make ↵Erich Keane2017-07-181-4/+5
| | | | | | | | | | | | | | | further improvements easier Convert attribute 'target' parsing from a 'pair' to a 'struct' to make further improvements easier The attribute 'target' parse function previously returned a pair. Convert this to a 'pair' in order to add more functionality, and improve usability. Differential Revision: https://reviews.llvm.org/D35574 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308357 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix build failure with gcc about mixing enum and non-enumYaxun Liu2017-07-081-2/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307483 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Fold variable into assert.Benjamin Kramer2017-07-081-2/+2
| | | | | | Avoids warnings in Release builds. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307472 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: Fix address space of global variableYaxun Liu2017-07-081-22/+44
| | | | | | | | | | | | | | Certain targets (e.g. amdgcn) require global variable to stay in global or constant address space. In C or C++ global variables are emitted in the default (generic) address space. This patch introduces virtual functions TargetCodeGenInfo::getGlobalVarAddressSpace and TargetInfo::getConstantAddressSpace to handle this in a general approach. It only affects IR generated for amdgcn target. Differential Revision: https://reviews.llvm.org/D33842 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307470 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules ts] Basic for module linkage.Richard Smith2017-07-071-1/+1
| | | | | | | | | | | In addition to the formal linkage rules, the Modules TS includes cases where internal-linkage symbols within a module interface unit can be referenced from outside the module via exported inline functions / templates. We give such declarations "module-internal linkage", which is formally internal linkage, but results in an externally-visible symbol. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307434 91177308-0d34-0410-b5e6-96231b3b80d8