summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [OPENMP] Add support for OMP5 requires directive + unified_address clauseKelvin Li2018-09-261-0/+4
| | | | | | | | | | Add support for OMP5.0 requires directive and unified_address clause. Patches to follow will include support for additional clauses. Differential Revision: https://reviews.llvm.org/D52359 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343063 91177308-0d34-0410-b5e6-96231b3b80d8
* Reland "[Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with ↵Kristina Brooks2018-09-251-24/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `-fconstant-cfstrings`" Relanding rL342883 with more fragmented tests to test ELF-specific section emission separately from broad-scope CFString tests. Now this tests the following separately 1). CoreFoundation builds and linkage for ELF while building it. 2). CFString ELF section emission outside CF in assembly output. 3). Broad scope `cfstring3.c` tests which cover all object formats at bitcode level and assembly level (including ELF). This fixes non-bridged CoreFoundation builds on ELF targets that use -fconstant-cfstrings. The original changes from differential for a similar patch to PE/COFF (https://reviews.llvm.org/D44491) did not check for an edge case where the global could be a constant which surfaced as an issue when building for ELF because of different linkage semantics. This patch addresses several issues with crashes related to CF builds on ELF as well as improves data layout by ensuring string literals that back the actual CFConstStrings end up in .rodata in line with Mach-O. Change itself tested with CoreFoundation on Linux x86_64 but should be valid for BSD-like systems as well that use ELF as the native object format. Differential Revision: https://reviews.llvm.org/D52344 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343038 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "rL342883: [Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with ↵Kristina Brooks2018-09-241-39/+24
| | | | | | | | | | `-fconstant-cfstrings`." Seems to be causing buildbot failures, need to look into it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342893 91177308-0d34-0410-b5e6-96231b3b80d8
* [Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`.Kristina Brooks2018-09-241-24/+39
| | | | | | | | | | | | | | | | | | | | | [Clang][CodeGen][ObjC]: Fix non-bridged CoreFoundation builds on ELF targets that use `-fconstant-cfstrings`. The original changes from differential for a similar patch to PE/COFF (https://reviews.llvm.org/D44491) did not check for an edge case where the global could be a constant which surfaced as an issue when building for ELF because of different linkage semantics. This patch addresses several issues with crashes related to CF builds on ELF as well as improves data layout by ensuring string literals that back the actual CFConstStrings end up in .rodata in line with Mach-O. Change itself tested with CoreFoundation on Linux x86_64 but should be valid for BSD-like systems as well that use ELF as the native object format. Differential Revision: https://reviews.llvm.org/D52344 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342883 91177308-0d34-0410-b5e6-96231b3b80d8
* Add necessary support for storing code-model to module IR.Caroline Tice2018-09-211-0/+16
| | | | | | | | | | | | | | Currently the code-model does not get saved in the module IR, so if a code model is specified when compiling with LTO, it gets lost and is not propagated properly to LTO. This patch does what is necessary in the front end to pass the code-model to the module, so that the back end can store it in the Module . Differential Revision: https://reviews.llvm.org/D52323 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342758 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][clang] Emit "never-instrument" attributeDean Michael Berris2018-09-141-3/+0
| | | | | | | | | | | | | | | | | | | | | | | Summary: Before this change, we only emit the XRay attributes in LLVM IR when the -fxray-instrument flag is provided. This may cause issues with thinlto when the final binary is being built/linked with -fxray-instrument, and the constitutent LLVM IR gets re-lowered with xray instrumentation. With this change, we can honour the "never-instrument "attributes provided in the source code and preserve those in the IR. This way, even in thinlto builds, we retain the attributes which say whether functions should never be XRay instrumented. This change addresses llvm.org/PR38922. Reviewers: mboerger, eizan Subscribers: mehdi_amini, dexonsmith, cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D52015 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342200 91177308-0d34-0410-b5e6-96231b3b80d8
* [NFC]Refactor MultiVersion Resolver Emission to combine typesErich Keane2018-09-131-11/+36
| | | | | | | | | Previously, both types (plus the future target-clones) of multiversioning had a separate ResolverOption structure and emission function. This patch combines the two, at the expense of a slightly more expensive sorting function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342152 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Align rtti and vtable dataDavid Green2018-09-121-4/+5
| | | | | | | | | | | Previously the alignment on the newly created rtti/typeinfo data was largely not set, meaning that DataLayout::getPreferredAlignment was free to overalign it to 16 bytes. This causes unnecessary code bloat. Differential Revision: https://reviews.llvm.org/D51416 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342053 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-land r334417 "[MS] Use mangled names and comdats for string merging with ↵Reid Kleckner2018-09-061-7/+5
| | | | | | | | | ASan" The issue with -fprofile-generate was fixed and the dependent CL relanded in r340232. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341572 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Fix PR38710: static functions are not emitted as implicitlyAlexey Bataev2018-08-301-11/+10
| | | | | | | | | 'declare target'. All the functions, referenced in implicit|explicit target regions must be emitted during code emission for the device. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341093 91177308-0d34-0410-b5e6-96231b3b80d8
* [MinGW] Don't mark external variables as DSO localMartin Storsjo2018-08-291-0/+8
| | | | | | | | | | | | Since MinGW supports automatically importing external variables from DLLs even without the DLLImport attribute, we shouldn't mark them as DSO local unless we actually know them to be local for sure. Keep marking thread local variables as DSO local. Differential Revision: https://reviews.llvm.org/D51382 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340941 91177308-0d34-0410-b5e6-96231b3b80d8
* Currently clang does not emit unused static constants. GCC emits theseElizabeth Andrews2018-08-221-0/+13
| | | | | | | | | | | | | | | | | constants by default when there is no optimization. GCC's option -fno-keep-static-consts can be used to not emit unused static constants. In Clang, since default behavior does not keep unused static constants, -fkeep-static-consts can be used to emit these if required. This could be useful for producing identification strings like SVN identifiers inside the object file even though the string isn't used by the program. Differential Revision: https://reviews.llvm.org/D40925 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340439 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Fix crash on the emission of the weak function declaration.Alexey Bataev2018-08-201-9/+11
| | | | | | | | | If the function is actually a weak reference, it should not be marked as deferred definition as this is only a declaration. Patch adds checks for the definitions if they must be emitted. Otherwise, only declaration is emitted. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340191 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] FIx processing of declare target variables.Alexey Bataev2018-08-151-1/+16
| | | | | | | | The compiler may produce unexpected error messages/crashes when declare target variables were used. Patch fixes problems with the declarations marked as declare target to or link. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339805 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-cl: Support /guard:cf,nochecksHans Wennborg2018-08-101-1/+1
| | | | | | | | | | This extension emits the guard cf table without inserting the instrumentation. Currently that's what clang-cl does with /guard:cf anyway, but this allows a user to request that explicitly. Differential Revision: https://reviews.llvm.org/D50513 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339420 91177308-0d34-0410-b5e6-96231b3b80d8
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-4/+4
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339385 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Mark variables captured in declare target region as implicitlyAlexey Bataev2018-08-071-0/+4
| | | | | | | | | declare target. According to OpenMP 5.0, variables captured in lambdas in declare target regions must be considered as implicitly declare target. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339152 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove trailing spaceFangrui Song2018-07-301-1/+1
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338291 91177308-0d34-0410-b5e6-96231b3b80d8
* [CUDA][HIP] Allow function-scope static const variableYaxun Liu2018-07-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | | CUDA 8.0 E.3.9.4 says: Within the body of a __device__ or __global__ function, only __shared__ variables or variables without any device memory qualifiers may be declared with static storage class. It is unclear how a function-scope non-const static variable without device memory qualifier is implemented, therefore only static const variable without device memory qualifier is allowed, which can be emitted as a global variable in constant address space. Currently clang only allows function-scope static variable with __shared__ qualifier. This patch also allows function-scope static const variable without device memory qualifier and emits it as a global variable in constant address space. Differential Revision: https://reviews.llvm.org/D49931 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338188 91177308-0d34-0410-b5e6-96231b3b80d8
* [HIP] Support -fcuda-flush-denormals-to-zero for amdgcnYaxun Liu2018-07-211-1/+1
| | | | | | | Differential Revision: https://reviews.llvm.org/D48287 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337639 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement cpu_dispatch/cpu_specific MultiversioningErich Keane2018-07-201-29/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As documented here: https://software.intel.com/en-us/node/682969 and https://software.intel.com/en-us/node/523346. cpu_dispatch multiversioning is an ICC feature that provides for function multiversioning. This feature is implemented with two attributes: First, cpu_specific, which specifies the individual function versions. Second, cpu_dispatch, which specifies the location of the resolver function and the list of resolvable functions. This is valuable since it provides a mechanism where the resolver's TU can be specified in one location, and the individual implementions each in their own translation units. The goal of this patch is to be source-compatible with ICC, so this implementation diverges from the ICC implementation in a few ways: 1- Linux x86/64 only: This implementation uses ifuncs in order to properly dispatch functions. This is is a valuable performance benefit over the ICC implementation. A future patch will be provided to enable this feature on Windows, but it will obviously more closely fit ICC's implementation. 2- CPU Identification functions: ICC uses a set of custom functions to identify the feature list of the host processor. This patch uses the cpu_supports functionality in order to better align with 'target' multiversioning. 1- cpu_dispatch function def/decl: ICC's cpu_dispatch requires that the function marked cpu_dispatch be an empty definition. This patch supports that as well, however declarations are also permitted, since the linker will solve the issue of multiple emissions. Differential Revision: https://reviews.llvm.org/D47474 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337552 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for __declspec(code_seg("segname"))Erich Keane2018-07-181-4/+8
| | | | | | | | | | | | | | | | | | | | | This patch uses CodeSegAttr to represent __declspec(code_seg) rather than building on the existing support for #pragma code_seg. The code_seg declspec is applied on functions and classes. This attribute enables the placement of code into separate named segments, including compiler- generated codes and template instantiations. For more information, please see the following: https://msdn.microsoft.com/en-us/library/dn636922.aspx This patch fixes the regression for the support for attribute ((section). https://github.com/llvm-mirror/clang/commit/746b78de7812bc785fbb5207b788348040b23fa7 Patch by Soumi Manna (Manna) Differential Revision: https://reviews.llvm.org/D48841 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337420 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix setting of empty implicit-section-name attributePetr Pavlu2018-07-111-4/+0
| | | | | | | | | | | | | | | | | | | | Code in `CodeGenModule::SetFunctionAttributes()` could set an empty attribute `implicit-section-name` on a function that is affected by `#pragma clang text="section"`. This is incorrect because the attribute should contain a valid section name. If the function additionally also used `__attribute__((section("section")))` then this could result in emitting the function in a section with an empty name. The patch fixes the issue by removing the problematic code that sets empty `implicit-section-name` from `CodeGenModule::SetFunctionAttributes()` because it is sufficient to set this attribute only from a similar code in `setNonAliasAttributes()` when the function is emitted. Differential Revision: https://reviews.llvm.org/D48916 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336842 91177308-0d34-0410-b5e6-96231b3b80d8
* [CUDA] Use atexit() to call module destructor.Artem Belevich2018-06-271-3/+2
| | | | | | | | | | This matches the way NVCC does it. Doing module cleanup at global destructor phase used to work, but is, apparently, too late for the CUDA runtime in CUDA-9.2, which ends up crashing with double-free. Differential Revision: https://reviews.llvm.org/D48613 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335763 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[MS] Use mangled names and comdats for string merging with ASan"Evgeniy Stepanov2018-06-261-5/+7
| | | | | | Depends on r334313, which has been reverted in r335681. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335684 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement CFI for indirect calls via a member function pointer.Peter Collingbourne2018-06-261-26/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similarly to CFI on virtual and indirect calls, this implementation tries to use program type information to make the checks as precise as possible. The basic way that it works is as follows, where `C` is the name of the class being defined or the target of a call and the function type is assumed to be `void()`. For virtual calls: - Attach type metadata to the addresses of function pointers in vtables (not the functions themselves) of type `void (B::*)()` for each `B` that is a recursive dynamic base class of `C`, including `C` itself. This type metadata has an annotation that the type is for virtual calls (to distinguish it from the non-virtual case). - At the call site, check that the computed address of the function pointer in the vtable has type `void (C::*)()`. For non-virtual calls: - Attach type metadata to each non-virtual member function whose address can be taken with a member function pointer. The type of a function in class `C` of type `void()` is each of the types `void (B::*)()` where `B` is a most-base class of `C`. A most-base class of `C` is defined as a recursive base class of `C`, including `C` itself, that does not have any bases. - At the call site, check that the function pointer has one of the types `void (B::*)()` where `B` is a most-base class of `C`. Differential Revision: https://reviews.llvm.org/D47567 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335569 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Do not consider address constant vars as possiblyAlexey Bataev2018-06-251-1/+2
| | | | | | | | | threadprivate. Do not delay emission of the address constant variables in OpenMP mode as they cannot be defined as threadprivate. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335483 91177308-0d34-0410-b5e6-96231b3b80d8
* [CUDA][HIP] Set kernel calling convention before arrange functionYaxun Liu2018-06-121-2/+0
| | | | | | | | | | | | | | Currently clang set kernel calling convention for CUDA/HIP after arranging function, which causes incorrect kernel function type since it depends on calling convention. This patch moves setting kernel convention before arranging function. Differential Revision: https://reviews.llvm.org/D47733 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334457 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS] Use mangled names and comdats for string merging with ASanReid Kleckner2018-06-111-7/+5
| | | | | | | | This should reduce the binary size penalty of ASan on Windows. After r334313, ASan will add red zones to globals in comdats, so we will still find OOB accesses to string literals. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334417 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Improve diagnostics related to target attributesGabor Buella2018-06-071-10/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When requirement imposed by __target__ attributes on functions are not satisfied, prefer printing those requirements, which are explicitly mentioned in the attributes. This makes such messages more useful, e.g. printing avx512f instead of avx2 in the following scenario: ``` $ cat foo.c static inline void __attribute__((__always_inline__, __target__("avx512f"))) x(void) { } int main(void) { x(); } $ clang foo.c foo.c:7:2: error: always_inline function 'x' requires target feature 'avx2', but would be inlined into function 'main' that is compiled without support for 'avx2' x(); ^ 1 error generated. ``` bugzilla: https://bugs.llvm.org/show_bug.cgi?id=37338 Reviewers: craig.topper, echristo, dblaikie Reviewed By: craig.topper, echristo Differential Revision: https://reviews.llvm.org/D46541 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334174 91177308-0d34-0410-b5e6-96231b3b80d8
* [CUDA][HIP] Do not emit type info when compiling for deviceYaxun Liu2018-06-051-1/+1
| | | | | | | | | | | | | | CUDA/HIP does not support RTTI on device side, therefore there is no point of emitting type info when compiling for device. Emitting type info for device not only clutters the IR with useless global variables, but also causes undefined symbol at linking since vtable for cxxabiv1::class_type_info has external linkage. Differential Revision: https://reviews.llvm.org/D47694 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334021 91177308-0d34-0410-b5e6-96231b3b80d8
* Make the mangled name collision diagnostic a bit more useful by listing the ↵Richard Smith2018-05-301-5/+6
| | | | | | | | | | | mangling. This helps especially when the collision is for a template specialization, where the template arguments are not available from anywhere else in the diagnostic, and are likely relevant to the problem. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333489 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: Emit string literal in constant address spaceYaxun Liu2018-05-141-6/+41
| | | | | | | | | | Some targets have constant address space (e.g. amdgcn). For them string literal should be emitted in constant address space then casted to default address space. Differential Revision: https://reviews.llvm.org/D46643 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332279 91177308-0d34-0410-b5e6-96231b3b80d8
* [Clang] Implement function attribute no_stack_protector.Manoj Gupta2018-05-091-6/+8
| | | | | | | | | | | | | | | | | | | | | | Summary: This attribute tells clang to skip this function from stack protector when -stack-protector option is passed. GCC option for this is: __attribute__((__optimize__("no-stack-protector"))) and the equivalent clang syntax would be: __attribute__((no_stack_protector)) This is used in Linux kernel to selectively disable stack protector in certain functions. Reviewers: aaron.ballman, rsmith, rnk, probinson Reviewed By: aaron.ballman Subscribers: probinson, srhines, cfe-commits Differential Revision: https://reviews.llvm.org/D46300 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331925 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-1/+1
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331834 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP, NVPTX] Added support for L2 parallelism.Alexey Bataev2018-05-071-2/+11
| | | | | | | Added initial codegen for level 2, 3 etc. parallelism. Currently, all the second, the third etc. parallel regions will run sequentially. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331642 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Support C++ member functions in the device constructs.Alexey Bataev2018-05-021-1/+1
| | | | | | | Added correct emission of the C++ member functions for the device function when they are used in the device constructs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331365 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert rC330794 and some dependent tiny bug fixes Faisal Vali2018-04-261-1/+0
| | | | | | | | | | | | | | | | | | See Richard's humbling feedback here: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226482.html http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226486.html Wish I'd had the patience to solicit the feedback prior to committing :) Sorry for the noise guys. Thank you Richard for being the steward that clang deserves! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330888 91177308-0d34-0410-b5e6-96231b3b80d8
* [c++2a] [concepts] Add rudimentary parsing support for template concept ↵Faisal Vali2018-04-251-0/+1
| | | | | | | | | | | | | | | declarations This patch is a tweak of changyu's patch: https://reviews.llvm.org/D40381. It differs in that the recognition of the 'concept' token is moved into the machinery that recognizes declaration-specifiers - this allows us to leverage the attribute handling machinery more seamlessly. See the test file to get a sense of the basic parsing that this patch supports. There is much more work to be done before concepts are usable... Thanks Changyu! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330794 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Reland r330442: Add an option to suppress output of llvm.identMikhail Maltsev2018-04-231-1/+2
| | | | | | | | The test case in the original patch was overly contrained and failed on PPC targets. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330575 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r330442, CodeGen/no-ident-version.c is failing on PPCMikhail Maltsev2018-04-201-2/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330451 91177308-0d34-0410-b5e6-96231b3b80d8
* [CUDA] Set LLVM calling convention for CUDA kernelYaxun Liu2018-04-201-0/+3
| | | | | | | | | | | | | | | Some targets need special LLVM calling convention for CUDA kernel. This patch does that through a TargetCodeGenInfo hook. It only affects amdgcn target. Patch by Greg Rodgers. Revised and lit tests added by Yaxun Liu. Differential Revision: https://reviews.llvm.org/D45223 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330447 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Add an option to suppress output of llvm.identMikhail Maltsev2018-04-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: By default Clang outputs its version (including git commit hash, in case of trunk builds) into object and assembly files. It might be useful to have an option to disable this, especially for debugging purposes. This patch implements new command line flags -Qn and -Qy (the names are chosen for compatibility with GCC). -Qn disables output of the 'llvm.ident' metadata string and the 'producer' debug info. -Qy (enabled by default) does the opposite. Reviewers: faisalv, echristo, aprantl Reviewed By: aprantl Subscribers: aprantl, cfe-commits, JDevlieghere, rogfer01 Differential Revision: https://reviews.llvm.org/D45255 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330442 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement proper support for `-falign-functions`Saleem Abdulrasool2018-04-191-0/+4
| | | | | | | | | | | | | | | | This implements support for the previously ignored flag `-falign-functions`. This allows the frontend to request alignment on function definitions in the translation unit where they are not explicitly requested in code. This is compatible with the GCC behaviour and the ICC behaviour. The scalar value passed to `-falign-functions` aligns functions to a power-of-two boundary. If flag is used, the functions are aligned to 16-byte boundaries. If the scalar is specified, it must be an integer less than or equal to 4096. If the value is not a power-of-two, the driver will round it up to the nearest power of two. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330378 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a command line option 'fregister_global_dtors_with_atexit' toAkira Hatanaka2018-04-171-0/+6
| | | | | | | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330199 91177308-0d34-0410-b5e6-96231b3b80d8
* Use export_as for autolinking frameworksBruno Cardoso Lopes2018-04-161-0/+6
| | | | | | | | | | | | | | | | framework module SomeKitCore { ... export_as SomeKit } Given the module above, while generting autolink information during codegen, clang should to emit '-framework SomeKitCore' only if SomeKit was not imported in the relevant TU, otherwise it should use '-framework SomeKit' instead. rdar://problem/38269782 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330152 91177308-0d34-0410-b5e6-96231b3b80d8
* hwasan: add -fsanitize=kernel-hwaddress flagAndrey Konovalov2018-04-131-1/+2
| | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330044 91177308-0d34-0410-b5e6-96231b3b80d8
* [XRay][clang] Add flag to choose instrumentation bundlesDean Michael Berris2018-04-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change addresses http://llvm.org/PR36926 by allowing users to pick which instrumentation bundles to use, when instrumenting with XRay. In particular, the flag `-fxray-instrumentation-bundle=` has four valid values: - `all`: the default, emits all instrumentation kinds - `none`: equivalent to -fnoxray-instrument - `function`: emits the entry/exit instrumentation - `custom`: emits the custom event instrumentation These can be combined either as comma-separated values, or as repeated flag values. Reviewers: echristo, kpw, eizan, pelikan Reviewed By: pelikan Subscribers: mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D44970 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329985 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typos in clangAlexander Kornienko2018-04-061-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329399 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Added emission of offloading data sections for declare targetAlexey Bataev2018-03-301-1/+9
| | | | | | | | | | variables. Added emission of the offloading data sections for the variables within declare target regions + fixes emission of the declare target variables marked as declare target not within the declare target region. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328888 91177308-0d34-0410-b5e6-96231b3b80d8