summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* [Clang] Harmonize Split DWARF options with llcAaron Puchert2019-06-152-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: With Split DWARF the resulting object file (then called skeleton CU) contains the file name of another ("DWO") file with the debug info. This can be a problem for remote compilation, as it will contain the name of the file on the compilation server, not on the client. To use Split DWARF with remote compilation, one needs to either * make sure only relative paths are used, and mirror the build directory structure of the client on the server, * inject the desired file name on the client directly. Since llc already supports the latter solution, we're just copying that over. We allow setting the actual output filename separately from the value of the DW_AT_[GNU_]dwo_name attribute in the skeleton CU. Fixes PR40276. Reviewers: dblaikie, echristo, tejohnson Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D59673 llvm-svn: 363496
* [Clang] Rename -split-dwarf-file to -split-dwarf-outputAaron Puchert2019-06-152-7/+7
| | | | | | | | | | | | | | | | | | Summary: This is the first in a series of changes trying to align clang -cc1 flags for Split DWARF with those of llc. The unfortunate side effect of having -split-dwarf-output for single file Split DWARF will disappear again in a subsequent change. The change is the result of a discussion in D59673. Reviewers: dblaikie, echristo Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D63130 llvm-svn: 363494
* [CodeGen][ObjC] Annotate retain-agnostic ObjC globals with attributeAkira Hatanaka2019-06-142-1/+4
| | | | | | | | | | | | | | | 'objc_arc_inert' The attribute enables the ARC optimizer to delete ObjC ARC runtime calls on the annotated globals (see https://reviews.llvm.org/D62433). We currently only annotate global variables for string literals and global blocks with the attribute. rdar://problem/49839633 Differential Revision: https://reviews.llvm.org/D62831 llvm-svn: 363467
* [OpenMP] Add target task alloc function with device IDGheorghe-Teodor Bercea2019-06-141-12/+49
| | | | | | | | | | | | | | | | Summary: Add a new call to Clang to perform task allocation for the target. Reviewers: ABataev, AlexEichenberger, caomhin Reviewed By: ABataev, AlexEichenberger Subscribers: openmp-commits, Hahnfeld, guansong, jdoerfert, cfe-commits Tags: #clang, #openmp Differential Revision: https://reviews.llvm.org/D63009 llvm-svn: 363451
* [OpenMP] Avoid emitting maps for target link variables when unified memory ↵Gheorghe-Teodor Bercea2019-06-142-1/+9
| | | | | | | | | | | | | | | | | | is used Summary: This patch avoids the emission of maps for target link variables when unified memory is present. Reviewers: ABataev, caomhin Reviewed By: ABataev Subscribers: guansong, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60883 llvm-svn: 363435
* PR23833, DR2140: an lvalue-to-rvalue conversion on a glvalue of typeRichard Smith2019-06-142-3/+4
| | | | | | | | | | | nullptr_t does not access memory. We now reuse CK_NullToPointer to represent a conversion from a glvalue of type nullptr_t to a prvalue of nullptr_t where necessary. This reinstates r363337, reverted in r363352. llvm-svn: 363429
* C++ DR712 and others: handle non-odr-use resulting from an lvalue-to-rvalue ↵Richard Smith2019-06-143-52/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | conversion applied to a member access or similar not-quite-trivial lvalue expression. Summary: When a variable is named in a context where we can't directly emit a reference to it (because we don't know for sure that it's going to be defined, or it's from an enclosing function and not captured, or the reference might not "work" for some reason), we emit a copy of the variable as a global and use that for the known-to-be-read-only access. This reinstates r363295, reverted in r363352, with a fix for PR42276: we now produce a proper name for a non-odr-use reference to a static constexpr data member. The name <mangled-name>.const is used in that case; such names are reserved to the implementation for cases such as this and should demangle nicely. Reviewers: rjmccall Subscribers: jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63157 llvm-svn: 363428
* Reland: [Remarks] Refactor optimization remarks setupFrancis Visoiu Mistrih2019-06-141-27/+24
| | | | | | | | * Add a common function to setup opt-remarks * Rename common options to the same names * Add error types to distinguish between file errors and regex errors llvm-svn: 363415
* [AMDGPU] Enable the implicit arguments for HIP (CLANG)Yaxun Liu2019-06-141-1/+2
| | | | | | | | Enable 48-bytes of implicit arguments for HIP as well. Earlier it was enabled for OpenCL. This code is specific to AMDGPU target. Differential Revision: https://reviews.llvm.org/D62244 llvm-svn: 363414
* Revert 363295, it caused PR42276. Also revert follow-ups 363337, 363340.Nico Weber2019-06-145-143/+54
| | | | | | | | Revert 363340 "Remove unused SK_LValueToRValue initialization step." Revert 363337 "PR23833, DR2140: an lvalue-to-rvalue conversion on a glvalue of type" Revert 363295 "C++ DR712 and others: handle non-odr-use resulting from an lvalue-to-rvalue conversion applied to a member access or similar not-quite-trivial lvalue expression." llvm-svn: 363352
* Revert "[Remarks] Refactor optimization remarks setup"Francis Visoiu Mistrih2019-06-141-24/+27
| | | | | | | | This reverts commit 6e6e3af55bb97e1a4c97375c15a2b0099120c5a7. This breaks greendragon. llvm-svn: 363343
* [AMDGPU] gfx1010 wave32 clang supportStanislav Mekhanoshin2019-06-131-4/+20
| | | | | | Differential Revision: https://reviews.llvm.org/D63209 llvm-svn: 363341
* PR23833, DR2140: an lvalue-to-rvalue conversion on a glvalue of typeRichard Smith2019-06-132-3/+4
| | | | | | | | | | | | nullptr_t does not access memory. We now reuse CK_NullToPointer to represent a conversion from a glvalue of type nullptr_t to a prvalue of nullptr_t where necessary. This reinstates r345562, reverted in r346065, now that CodeGen's handling of non-odr-used variables has been fixed. llvm-svn: 363337
* Use fully qualified name when printing S_CONSTANT recordsAmy Huang2019-06-131-2/+7
| | | | | | | | | | | | | | | | Summary: Before it was using the fully qualified name only for static data members. Now it does for all variable names to match MSVC. Reviewers: rnk Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63012 llvm-svn: 363335
* [Remarks] Refactor optimization remarks setupFrancis Visoiu Mistrih2019-06-131-27/+24
| | | | | | | | * Add a common function to setup opt-remarks * Rename common options to the same names * Add error types to distinguish between file errors and regex errors llvm-svn: 363328
* C++ DR712 and others: handle non-odr-use resulting from an lvalue-to-rvalue ↵Richard Smith2019-06-133-51/+139
| | | | | | | | | | | | | | | | | | | | | conversion applied to a member access or similar not-quite-trivial lvalue expression. Summary: When a variable is named in a context where we can't directly emit a reference to it (because we don't know for sure that it's going to be defined, or it's from an enclosing function and not captured, or the reference might not "work" for some reason), we emit a copy of the variable as a global and use that for the known-to-be-read-only access. Reviewers: rjmccall Subscribers: jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63157 llvm-svn: 363295
* PR42182: Allow thread-local to use __cxa_thread_atexit whenErich Keane2019-06-131-5/+7
| | | | | | | | | | | -fno-use-cxx-atexit is used This matches the GCC behavior, __cxa_thread_atexit should be permissible even though cxa_atexit is disabled. Differential Revision: https://reviews.llvm.org/D63283/ llvm-svn: 363288
* [clang][NewPM] Fix split debug testLeonard Chan2019-06-131-1/+2
| | | | | | | | | This contains the part of D62225 which fixes CodeGen/split-debug-single-file.c by not placing .dwo sections when using -enable-split-dwarf=split. Differential Revision: https://reviews.llvm.org/D63168 llvm-svn: 363281
* [clang][NewPM] Fix broken profile testLeonard Chan2019-06-131-0/+6
| | | | | | | | | | This contains the part of D62225 which fixes Profile/gcc-flag-compatibility.c by adding the pass that allows default profile generation to work under the new PM. It seems that ./default.profraw was not being generated with new PM enabled. Differential Revision: https://reviews.llvm.org/D63155 llvm-svn: 363278
* [clang][NewPM] Fix broken -O0 test from the AlwaysInlinerLeonard Chan2019-06-131-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | This contains the part of D62225 which prevents insertion of lifetime intrinsics when creating the AlwaysInliner. This fixes the following tests when the new PM is enabled by default: Clang :: CodeGen/aarch64-neon-across.c Clang :: CodeGen/aarch64-neon-fcvt-intrinsics.c Clang :: CodeGen/aarch64-neon-fma.c Clang :: CodeGen/aarch64-neon-perm.c Clang :: CodeGen/aarch64-neon-tbl.c Clang :: CodeGen/aarch64-poly128.c Clang :: CodeGen/aarch64-v8.2a-neon-intrinsics.c Clang :: CodeGen/arm-neon-fma.c Clang :: CodeGen/arm-neon-numeric-maxmin.c Clang :: CodeGen/arm-neon-vcvtX.c Clang :: CodeGen/avx-builtins.c Clang :: CodeGen/builtins-ppc-p9vector.c Clang :: CodeGen/builtins-ppc-vsx.c Clang :: CodeGen/lifetime.c Clang :: CodeGen/sse-builtins.c Clang :: CodeGen/sse2-builtins.c Differential Revision: https://reviews.llvm.org/D63153 llvm-svn: 363277
* [X86] [ABI] Fix i386 ABI "__m64" type bugPengfei Wang2019-06-121-20/+36
| | | | | | | | | | | | | | | | According to System V i386 ABI: the __m64 type paramater and return value are passed by MMX registers. But current implementation treats __m64 as i64 which results in parameter passing by stack and returning by EDX and EAX. This patch fixes the bug (https://bugs.llvm.org/show_bug.cgi?id=41029) for Linux and NetBSD. Patch by Wei Xiao (wxiao3) Differential Revision: https://reviews.llvm.org/D59744 llvm-svn: 363116
* Remove redundant check for whether a DeclRefExpr that names a captureRichard Smith2019-06-111-10/+1
| | | | | | | | constitutes an odr-use. We now track this accurately on the DeclRefExpr. llvm-svn: 363088
* For DR712: store on a MemberExpr whether it constitutes an odr-use.Richard Smith2019-06-111-7/+1
| | | | llvm-svn: 363087
* For DR712: store on a DeclRefExpr whether it constitutes an odr-use.Richard Smith2019-06-112-8/+15
| | | | | | | Begin restructuring to support the forms of non-odr-use reference permitted by DR712. llvm-svn: 363086
* [X86] Enable intrinsics that convert float and bf16 data to each otherPengfei Wang2019-06-111-0/+14
| | | | | | | | | | | | | | | | Scalar version : _mm_cvtsbh_ss , _mm_cvtness_sbh Vector version: _mm512_cvtpbh_ps , _mm256_cvtpbh_ps _mm512_maskz_cvtpbh_ps , _mm256_maskz_cvtpbh_ps _mm512_mask_cvtpbh_ps , _mm256_mask_cvtpbh_ps Patch by Shengchen Kan (skan) Differential Revision: https://reviews.llvm.org/D62363 llvm-svn: 363018
* DebugInfo: Add support for 'nodebug' attribute on typedefs and alias templatesDavid Blaikie2019-06-081-8/+16
| | | | | | | | | Seems like a logical extension to me - and of interest because it might help reduce the debug info size of libc++ by applying this attribute to type traits that have a disproportionate debug info cost compared to the benefit (& possibly harm/confusion) they cause users. llvm-svn: 362856
* Driver, IRGen: Set partitions on GlobalValues according to ↵Peter Collingbourne2019-06-073-7/+10
| | | | | | | | -fsymbol-partition flag. Differential Revision: https://reviews.llvm.org/D62636 llvm-svn: 362829
* LLVM IR: Generate new-style byval-with-Type from ClangTim Northover2019-06-052-2/+2
| | | | | | | | | | | LLVM IR recently added a Type parameter to the byval Attribute, so that when pointers become opaque and no longer have an element type the information will still be present in IR. For now the Type parameter is optional (which is why Clang didn't need this change at the time), but it will become mandatory soon. llvm-svn: 362652
* Reduce memory consumption of coverage dumpsSerge Guelton2019-06-051-4/+13
| | | | | | | | | | | Avoiding an intermediate join operation removes the need for an intermediate buffer that may be quite large, as showcased by https://bugs.llvm.org/show_bug.cgi?id=41965 Differential Revision: https://reviews.llvm.org/D62623 llvm-svn: 362584
* Initial support for vectorization using MASSV (IBM MASS vector library)Nemanja Ivanovic2019-06-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Part 2 (the Clang portion) of D59881. This patch (first of two patches) enables the vectorizer to recognize the IBM MASS vector library routines. This patch specifically adds support for recognizing the -vector-library=MASSV option, and defines mappings from IEEE standard scalar math functions to generic PowerPC MASS vector counterparts. For instance, the generic PowerPC MASS vector entry for double-precision cbrt function is __cbrtd2_massv. The second patch will further lower the generic PowerPC vector entries to PowerPC subtarget-specific entries. For instance, the PowerPC generic entry cbrtd2_massv is lowered to cbrtd2_P9 for Power9 subtarget. The overall support for MASS vector library is presented as such in two patches for ease of review. Patch by Jeeva Paudel. Differential revision: https://reviews.llvm.org/D59881 llvm-svn: 362571
* PR42111: Use guarded initialization for thread-local variables withRichard Smith2019-06-051-1/+7
| | | | | | | | | unordered initialization and internal linkage. We'll run their initializers once on each reference, so we need a guard variable even though they only have a single definition. llvm-svn: 362562
* [CodeGen][ObjC] Convert '[self alloc]' in a class method to a call toAkira Hatanaka2019-06-041-11/+33
| | | | | | | | | | | | | 'objc_alloc(self)' Also convert '[[self alloc] init]' in a class method to a call to 'objc_alloc_init(self)'. rdar://problem/50855121 Differential Revision: https://reviews.llvm.org/D62643 llvm-svn: 362521
* Re-check in clang support gun asm goto after fixing tests.Jennifer Yu2019-06-031-44/+82
| | | | llvm-svn: 362410
* [X86] Add VP2INTERSECT instructionsPengfei Wang2019-05-311-0/+42
| | | | | | | | | | Support intel AVX512 VP2INTERSECT instructions in clang Patch by Xiang Zhang (xiangzhangllvm) Differential Revision: https://reviews.llvm.org/D62367 llvm-svn: 362196
* Revert "[X86] Fix i386 struct and union parameter alignment"Pengfei Wang2019-05-311-11/+2
| | | | | | | | | | This reverts commit d61cb749f4ac2c90244906d756e80a5c4a7ffa89 (SVN: 361934). According to James suggestion, revert this change. Please ref: https://reviews.llvm.org/D60748 llvm-svn: 362186
* Fix -DBUILD_SHARED_LIBS=ON build after rL362160Sam Clegg2019-05-311-0/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D62709 llvm-svn: 362180
* Add enums as global variables in the IR metadata.Amy Huang2019-05-301-5/+7
| | | | | | | | | | | | | | | | Summary: Keeps track of the enums that were used by saving them as DIGlobalVariables, since CodeView emits debug info for global constants. Reviewers: rnk Subscribers: aprantl, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D62635 llvm-svn: 362166
* [Remarks][NFC] Move the serialization to lib/RemarksFrancis Visoiu Mistrih2019-05-301-1/+2
| | | | | | | | | | | | Separate the remark serialization to YAML from the LLVM Diagnostics. This adds a new serialization abstraction: remarks::Serializer. It's completely independent from lib/IR and it provides an easy way to replace YAML by providing a new remarks::Serializer. Differential Revision: https://reviews.llvm.org/D62632 llvm-svn: 362160
* Revert "clang support gnu asm goto."Erich Keane2019-05-301-82/+44
| | | | | | | | | | | This reverts commit 954ec09aed4f2be04bb5f4e10dbb4ea8bd19ef9a. Reverting due to test failures as requested by Jennifer Yu. Conflicts: clang/test/CodeGen/asm-goto.c llvm-svn: 362106
* [OpenCL] Fix OpenCL/SPIR version metadata in C++ mode.Anastasia Stulova2019-05-301-4/+9
| | | | | | | | | C++ is derived from OpenCL v2.0 therefore set the versions identically. Differential Revision: https://reviews.llvm.org/D62657 llvm-svn: 362102
* Add the `objc_class_stub` attribute.John McCall2019-05-301-13/+90
| | | | | | | | | | | | | | | | | | | | | | | | | Swift requires certain classes to be not just initialized lazily on first use, but actually allocated lazily using information that is only available at runtime. This is incompatible with ObjC class initialization, or at least not efficiently compatible, because there is no meaningful class symbol that can be put in a class-ref variable at load time. This leaves ObjC code unable to access such classes, which is undesirable. objc_class_stub says that class references should be resolved by calling a new ObjC runtime function with a pointer to a new "class stub" structure. Non-ObjC compilers (like Swift) can simply emit this structure when ObjC interop is required for a class that cannot be statically allocated, then apply this attribute to the `@interface` in the generated ObjC header for the class. This attribute can be thought of as a generalization of the existing `objc_runtime_visible` attribute which permits more efficient class resolution as well as supporting the additon of categories to the class. Subclassing these classes from ObjC is currently not allowed. Patch by Slava Pestov! llvm-svn: 362054
* clang support gnu asm goto.Jennifer Yu2019-05-301-44/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Syntax: asm [volatile] goto ( AssemblerTemplate : : InputOperands : Clobbers : GotoLabels) https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html New llvm IR is "callbr" for inline asm goto instead "call" for inline asm For: asm goto("testl %0, %0; jne %l1;" :: "r"(cond)::label_true, loop); IR: callbr void asm sideeffect "testl $0, $0; jne ${1:l};", "r,X,X,~{dirflag},~{fpsr},~{flags}"(i32 %0, i8* blockaddress(@foo, %label_true), i8* blockaddress(@foo, %loop)) #1 to label %asm.fallthrough [label %label_true, label %loop], !srcloc !3 asm.fallthrough: Compiler need to generate: 1> a dummy constarint 'X' for each label. 2> an unique fallthrough label for each asm goto stmt " asm.fallthrough%number". Diagnostic 1> duplicate asm operand name are used in output, input and label. 2> goto out of scope. llvm-svn: 362045
* CodeView - add static data members to global variable debug info.Amy Huang2019-05-291-4/+14
| | | | | | | | | | | | | | | | | | Summary: Add static data members to IR debug info's list of global variables so that they are emitted as S_CONSTANT records. Related to https://bugs.llvm.org/show_bug.cgi?id=41615. Reviewers: rnk Subscribers: aprantl, cfe-commits, llvm-commits, thakis Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D62167 llvm-svn: 362038
* [CUDA][HIP] Skip setting `externally_initialized` for static device variables.Michael Liao2019-05-291-1/+2
| | | | | | | | | | | | | | | | | Summary: - By declaring device variables as `static`, we assume they won't be addressable from the host side. Thus, no `externally_initialized` is required. Reviewers: yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62603 llvm-svn: 361994
* [X86] Fix i386 struct and union parameter alignmentPengfei Wang2019-05-291-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to i386 System V ABI 2.1: Structures and unions assume the alignment of their most strictly aligned component. But current implementation always takes them as 4-byte aligned which will result in incorrect code, e.g: 1 #include <immintrin.h> 2 typedef union { 3 int d[4]; 4 __m128 m; 5 } M128; 6 extern void foo(int, ...); 7 void test(void) 8 { 9 M128 a; 10 foo(1, a); 11 foo(1, a.m); 12 } The first call (line 10) takes the second arg as 4-byte aligned while the second call (line 11) takes the second arg as 16-byte aligned. There is oxymoron for the alignment of the 2 calls because they should be the same. This patch fixes the bug by following i386 System V ABI and apply it to Linux only since other System V OS (e.g Darwin, PS4 and FreeBSD) don't want to spend any effort dealing with the ramifications of ABI breaks at present. Patch by Wei Xiao (wxiao3) Differential Revision: https://reviews.llvm.org/D60748 llvm-svn: 361934
* [CUDA][HIP] Emit dependent libs for host onlyYaxun Liu2019-05-281-1/+6
| | | | | | | | | | | | | Recently D60274 was introduced to allow lld to handle dependent libs. However current usage of dependent libs (e.g. pragma comment(lib, *) in windows header files) are intended for host only. Emitting the metadata in device IR causes link error in device path. Until there is a way to different it dependent libs for device or host, metadata for dependent libs should be emitted for host only. This patch enforces that. Differential Revision: https://reviews.llvm.org/D62483 llvm-svn: 361880
* [clang] Handle lrint/llrint builtinsAdhemerval Zanella2019-05-281-0/+16
| | | | | | | | | | | | As for other floating-point rounding builtins that can be optimized when build with -fno-math-errno, this patch adds support for lrint and llrint. It currently only optimize for AArch64 backend. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D62019 llvm-svn: 361878
* [NewPassManager] Add tuning option: LoopUnrolling [clang-change]Alina Sbirlea2019-05-241-0/+1
| | | | | | | | | | | | | | | | Summary: Use CodeGenOpts's setting for loop unrolling. [to be coupled with D61618] Reviewers: chandlerc Subscribers: jlebar, dmgreen, cfe-commits, llvm-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61620 llvm-svn: 361653
* [OPENMP]Do not crash for const firstprivates.Alexey Bataev2019-05-231-1/+19
| | | | | | | | | If the variable is a firstprivate variable and it was not emitted beause this a constant variable with the constant initializer, we can use the initial value instead of the variable itself. It also fixes the problem with the compiler crash in this case. llvm-svn: 361564
* [NewPassManager] Add tuning option: SLPVectorization [clang-change]Alina Sbirlea2019-05-231-1/+8
| | | | | | | | | | | | | | | | Summary: NewPassManager is not using CodeGenOpts values before this patch. [to be coupled with D61616] Reviewers: chandlerc Subscribers: jlebar, cfe-commits, llvm-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61617 llvm-svn: 361534
OpenPOWER on IntegriCloud