summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* Use zeroinitializer for (trailing zero portion of) large array initializersRichard Smith2018-05-231-71/+78
| | | | | | | | | | | | | | | | | | | | | | | more reliably. Clang has two different ways it emits array constants (from InitListExprs and from APValues), and both had some ability to emit zeroinitializer, but neither was able to catch all cases where we could use zeroinitializer reliably. In particular, emitting from an APValue would fail to notice if all the explicit array elements happened to be zero. In addition, for large arrays where only an initial portion has an explicit initializer, we would emit the complete initializer (which could be huge) rather than emitting only the non-zero portion. With this change, when the element would have a suffix of more than 8 zero elements, we emit the array constant as a packed struct of its initial portion followed by a zeroinitializer constant for the trailing zero portion. In passing, I found a bug where SemaInit would sometimes walk the entire array when checking an initializer that only covers the first few elements; that's fixed here to unblock testing of the rest. Differential Revision: https://reviews.llvm.org/D47166 llvm-svn: 333044
* [CodeGen] use nsw negation for builtin absSanjay Patel2018-05-221-1/+2
| | | | | | | | | | | | | The clang builtins have the same semantics as the stdlib functions. The stdlib functions are defined in section 7.20.6.1 of the C standard with: "If the result cannot be represented, the behavior is undefined." That lets us mark the negation with 'nsw' because "sub i32 0, INT_MIN" would be UB/poison. Differential Revision: https://reviews.llvm.org/D47202 llvm-svn: 333038
* [X86] Remove mask argument from some builtins that are handled completely in ↵Craig Topper2018-05-221-19/+11
| | | | | | CGBuiltin.cpp. Just wrap a select builtin around them in the header file instead. llvm-svn: 333027
* Reland r332885, "CodeGen, Driver: Start using direct split dwarf emission in ↵Peter Collingbourne2018-05-221-26/+49
| | | | | | | | | clang." As well as two follow-on commits r332906, r332911 with a fix for test clang/test/CodeGen/split-debug-filename.c. llvm-svn: 333013
* Revert r332982 Call CreateTempMemWithoutCast for ActiveFlagYaxun Liu2018-05-224-55/+36
| | | | | | Due to regression on arm. llvm-svn: 332991
* [CodeGen] produce the LLVM canonical form of absSanjay Patel2018-05-221-8/+4
| | | | | | | | We chose the 'slt' form as canonical in IR with: rL332819 ...so we should generate that form directly for efficiency. llvm-svn: 332989
* Call CreateTempMemWithoutCast for ActiveFlagYaxun Liu2018-05-224-36/+55
| | | | | | | | | | | | | | | | Introduced CreateMemTempWithoutCast and CreateTemporaryAllocaWithoutCast to emit alloca without casting to default addr space. ActiveFlag is a temporary variable emitted for clean up. It is defined as AllocaInst* type and there is a cast to AlllocaInst in SetActiveFlag. An alloca casted to generic pointer causes assertion in SetActiveFlag. Since there is only load/store of ActiveFlag, it is safe to use the original alloca, therefore use CreateMemTempWithoutCast is called. Differential Revision: https://reviews.llvm.org/D47099 llvm-svn: 332982
* [CodeView] Enable debugging of captured variables within C++ lambdasBrock Wyma2018-05-221-19/+43
| | | | | | | | | This change will help Visual Studio resolve forward references to C++ lambda routines used by captured variables. Differential Revision: https://reviews.llvm.org/D45438 llvm-svn: 332975
* Revert "CodeGen, Driver: Start using direct split dwarf emission in clang."Amara Emerson2018-05-221-48/+26
| | | | | | This reverts commit r332885 as it broke several greendragon buildbots. llvm-svn: 332973
* Revert "Fix another make_unique ambiguity."Amara Emerson2018-05-221-2/+1
| | | | | | This reverts commit r332906 as a dependency to revert r332885. llvm-svn: 332972
* [objc-gnustep2] Use unsigned char to avoid potential UB in isalnum.David Chisnall2018-05-221-1/+1
| | | | | | Suggested by Gabor Buella. llvm-svn: 332966
* [objc-gnustep2] Use isalnum instead of a less efficient and nonportable ↵David Chisnall2018-05-221-1/+1
| | | | | | | | equivalent. Patch by Hans Wennborg! llvm-svn: 332964
* Revert "Revert r332955 "GNUstep Objective-C ABI version 2""David Chisnall2018-05-221-351/+1399
| | | | llvm-svn: 332963
* Revert r332955 "GNUstep Objective-C ABI version 2"Bjorn Pettersson2018-05-221-1399/+351
| | | | | | | Reverted due to buildbot failures. Seems like isnumber() is some Apple addition to cctype. llvm-svn: 332957
* Add cctype include.David Chisnall2018-05-221-0/+1
| | | | | | | This appears to leak in already on libc++ platforms, but is breaking on some other targets. llvm-svn: 332955
* GNUstep Objective-C ABI version 2David Chisnall2018-05-221-351/+1399
| | | | | | | | | | | | | | | | | | | | | Summary: This includes initial support for the (hopefully final) updated Objective-C ABI, developed here: https://github.com/davidchisnall/clang-gnustep-abi-2 It also includes some cleanups and refactoring from older GNU ABIs. The current version is ELF only, other formats to follow. Reviewers: rjmccall, DHowett-MSFT Reviewed By: rjmccall Subscribers: smeenai, cfe-commits Differential Revision: https://reviews.llvm.org/D46052 llvm-svn: 332950
* Fix another make_unique ambiguity.Peter Collingbourne2018-05-211-1/+2
| | | | llvm-svn: 332906
* [X86] Remove masking from pternlog llvm intrinsics and use a select ↵Craig Topper2018-05-211-0/+47
| | | | | | | | | | | | instruction instead. Because the intrinsics in the headers are implemented as macros, we can't just use a select builtin and pternlog builtin. This would require one of the macro arguments to be used twice. Depending on what was passed to the macro we could expand an expression twice leading to weird behavior. We could maybe declare our local variable in the macro, but that would need to worry about name collisions. To avoid that just generate IR directly in CGBuiltin.cpp. Differential Revision: https://reviews.llvm.org/D47125 llvm-svn: 332891
* Revert r332847; it caused us to miscompile certain forms of reference ↵Richard Smith2018-05-211-30/+10
| | | | | | initialization. llvm-svn: 332886
* CodeGen, Driver: Start using direct split dwarf emission in clang.Peter Collingbourne2018-05-211-26/+48
| | | | | | | | Fixes PR37466. Differential Revision: https://reviews.llvm.org/D47093 llvm-svn: 332885
* CodeGen: Add a dwo output file argument to addPassesToEmitFile and hook it ↵Peter Collingbourne2018-05-211-1/+1
| | | | | | | | | | up to dwo output. Part of PR37466. Differential Revision: https://reviews.llvm.org/D47089 llvm-svn: 332881
* Revert r332028; see PR37545 for details.Richard Smith2018-05-211-63/+58
| | | | llvm-svn: 332879
* [AMDGPU] fixes for lds f32 builtinsDaniil Fukalov2018-05-211-0/+43
| | | | | | | | | | | | 1. added restrictions to memory scope, order and volatile parameters 2. added custom processing for these builtins - currently is not used code, needed to switch off GCCBuiltin link to the builtins (ongoing change to llvm tree) 3. builtins renamed as requested Differential Revision: https://reviews.llvm.org/D43281 llvm-svn: 332848
* [CodeGen] Recognize more cases of zero initializationSerge Pavlov2018-05-211-10/+30
| | | | | | | | | | | | | | | | | | | | | If a variable has an initializer, codegen tries to build its value. If the variable is large in size, building its value requires substantial resources. It causes strange behavior from user viewpoint: compilation of huge zero initialized arrays like: char data_1[2147483648u] = { 0 }; consumes enormous amount of time and memory. With this change codegen tries to determine if variable initializer is equivalent to zero initializer. In this case variable value is not constructed. This change fixes PR18978. Differential Revision: https://reviews.llvm.org/D46241 llvm-svn: 332847
* [CodeGen] Disable aggressive structor optimizations at -O0, take 2Pavel Labath2018-05-211-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | The first version of the patch (r332228) was flawed because it was putting structors into C5/D5 comdats very eagerly. This is correct only if we can ensure the comdat contains all required versions of the structor (which wasn't the case). This version uses a more nuanced approach: - for local structor symbols we use an alias because we don't have to worry about comdats or other compilation units. - linkonce symbols are emitted separately, as we cannot guarantee we will have all symbols we need to form a comdat (they are emitted lazily, only when referenced). - available_externally symbols are also emitted separately, as the code seemed to be worried about emitting an alias in this case. - other linkage types are not affected by the optimization level. They either get put into a comdat (weak) or get aliased (external). Reviewers: rjmccall, aprantl Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D46685 llvm-svn: 332839
* CodeGen: block capture shouldn't ICEJF Bastien2018-05-191-13/+26
| | | | | | | | | | When a lambda capture captures a __block in the same statement, the compiler asserts out because isCapturedBy assumes that an Expr can only be a BlockExpr, StmtExpr, or if it's a Stmt then all the statement's children are expressions. That's wrong, we need to visit all sub-statements even if they're not expressions to see if they also capture. Fix this issue by pulling out the isCapturedBy logic to use RecursiveASTVisitor. <rdar://problem/39926584> llvm-svn: 332801
* [HIP] Support offloading by linker scriptYaxun Liu2018-05-181-38/+77
| | | | | | | | | | | | To support linking device code in different source files, it is necessary to embed fat binary at host linking stage. This patch emits an external symbol for fat binary in host codegen, then embed the fat binary by lld through a linker script. Differential Revision: https://reviews.llvm.org/D46472 llvm-svn: 332724
* Support: Add a raw_ostream::write_zeros() function. NFCI.Peter Collingbourne2018-05-171-2/+1
| | | | | | | | | | This will eventually replace MCObjectWriter::WriteZeros. Part of PR37466. Differential Revision: https://reviews.llvm.org/D47033 llvm-svn: 332675
* Fix a mangling failure on clang-cl C++17Reid Kleckner2018-05-173-14/+5
| | | | | | | | | | | | | | MethodVFTableLocations in MigrosoftVTableContext contains canonicalized decl. But, it's sometimes asked to lookup for non-canonicalized decl, and that causes assertion failure, and compilation failure. Fixes PR37481. Patch by Taiju Tsuiki! Differential Revision: https://reviews.llvm.org/D46929 llvm-svn: 332639
* CodeGen: Fix invalid bitcast for lifetime.start/endYaxun Liu2018-05-175-34/+76
| | | | | | | | | | | | | | lifetime.start/end expects pointer argument in alloca address space. However in C++ a temporary variable is in default address space. This patch changes API CreateMemTemp and CreateTempAlloca to get the original alloca instruction and pass it lifetime.start/end. It only affects targets with non-zero alloca address space. Differential Revision: https://reviews.llvm.org/D45900 llvm-svn: 332593
* [OPENMP] DO not crash on combined constructs in declare targetAlexey Bataev2018-05-161-1/+1
| | | | | | | | | | | functions. If the combined construct is specified in the declare target function and the device code is emitted, the compiler crashes because of the incorrectly chosen captured stmt. We should choose the innermost captured statement, not the outermost. llvm-svn: 332477
* [OPENMP, NVPTX] Add check for SPMD mode in orphaned parallel directives.Alexey Bataev2018-05-161-6/+34
| | | | | | | | If the orphaned directive is executed in SPMD mode, we need to emit the check for the SPMD mode and run the orphaned parallel directive in sequential mode. llvm-svn: 332467
* Move helper classes into anonymous namespaces. NFCI.Benjamin Kramer2018-05-151-3/+4
| | | | llvm-svn: 332400
* Address post-commit review comments after r328731. NFC.Akira Hatanaka2018-05-152-4/+6
| | | | | | | | | | | | | | | | | | | | | | - Define a function (canPassInRegisters) that determines whether a record can be passed in registers based on language rules and target-specific ABI rules. - Set flag RecordDecl::ParamDestroyedInCallee to true in MSVC mode and remove ASTContext::isParamDestroyedInCallee, which is no longer needed. - Use the same type (unsigned) for RecordDecl's bit-field members. For more background, see the following discussions that took place on cfe-commits. http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180326/223498.html http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180402/223688.html http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180409/224754.html http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180423/226494.html http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180507/227647.html llvm-svn: 332397
* [OPENMP, NVPTX] Do not globalize variables with reference/pointer types.Alexey Bataev2018-05-151-20/+19
| | | | | | | | In generic data-sharing mode we do not need to globalize variables/parameters of reference/pointer types. They already are placed in the global memory. llvm-svn: 332380
* [clang] Update uses of DEBUG macro to LLVM_DEBUG.Nicola Zaghen2018-05-151-1/+1
| | | | | | | | | | | | | The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM Explicitly avoided changing the strings in the clang-format tests. Differential Revision: https://reviews.llvm.org/D44975 llvm-svn: 332350
* [CodeView] Improve debugging of virtual base class member variablesBrock Wyma2018-05-141-2/+6
| | | | | | | | Initial support for passing the virtual base pointer offset to CodeViewDebug. https://reviews.llvm.org/D46271 llvm-svn: 332296
* CodeGen: Emit string literal in constant address spaceYaxun Liu2018-05-143-12/+53
| | | | | | | | | 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 llvm-svn: 332279
* Revert "[CodeGen] Disable aggressive structor optimizations at -O0"Pavel Labath2018-05-141-10/+6
| | | | | | | | | It breaks the sanitizer build <http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/23739> This reverts commit r332228. llvm-svn: 332232
* [CodeGen] Disable aggressive structor optimizations at -O0Pavel Labath2018-05-141-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Removing the full structor and replacing all usages with the base one can degrade debug quality as it will leave the debugger unable to locate the full object structor. This is apparent when evaluating an expression in the debugger which requires constructing an object of class which has had this optimization applied to it. When compiling the expression, we pretend that the class and its methods have been defined in another compilation unit, so the expression compiler assumes the structor definition must be available. This didn't use to be the case for structors with internal linkage. Less aggressive optimizations like emitting the full structor as an alias remain in place, as they do not cause the structor symbol to disappear completely. This improves debug quality on non-darwin platforms (darwin does not have -mconstructor-aliases on by default, so it is spared these problems) and enable us to remove some workarounds from LLDB which attempt to mitigate this issue. Reviewers: rjmccall, aprantl Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D46685 llvm-svn: 332228
* Added atomic_fetch_min, max, umin, umax intrinsics to clang.Elena Demikhovsky2018-05-131-0/+8
| | | | | | | | | These intrinsics work exactly as all other atomic_fetch_* intrinsics and allow to create *atomicrmw* with ordering. Updated the clang-extensions document. Differential Revision: https://reviews.llvm.org/D46386 llvm-svn: 332193
* [OPENMP, NVPTX] Do not use SPMD mode for target simd and target teamsAlexey Bataev2018-05-111-19/+13
| | | | | | | | | distribute simd directives. Directives `target simd` and `target teams distribute simd` must be executed in non-SPMD mode. llvm-svn: 332129
* [Itanium] Emit type info names with external linkage.Eric Fiselier2018-05-101-58/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The Itanium ABI requires that the type info for pointer-to-incomplete types to have internal linkage, so that it doesn't interfere with the type info once completed. Currently it also marks the type info name as internal as well. However, this causes a bug with the STL implementations, which use the type info name pointer to perform ordering and hashing of type infos. For example: ``` // header.h struct T; extern std::type_info const& Info; // tu_one.cpp #include "header.h" std::type_info const& Info = typeid(T*); // tu_two.cpp #include "header.h" struct T {}; int main() { auto &TI1 = Info; auto &TI2 = typeid(T*); assert(TI1 == TI2); // Fails assert(TI1.hash_code() == TI2.hash_code()); // Fails } ``` This patch fixes the STL bug by emitting the type info name as linkonce_odr when the type-info is for a pointer-to-incomplete type. Note that libc++ could fix this without a compiler change, but the quality of fix would be poor. The library would either have to: (A) Always perform strcmp/string hashes. (B) Determine if we have a pointer-to-incomplete type, and only do strcmp then. This would require an ABI break for libc++. Reviewers: rsmith, rjmccall, majnemer, vsapsai Reviewed By: rjmccall Subscribers: smeenai, cfe-commits Differential Revision: https://reviews.llvm.org/D46665 llvm-svn: 332028
* Reland '[clang] Adding CharacteristicKind to PPCallbacks::InclusionDirective'Julie Hockett2018-05-102-2/+4
| | | | | | | | | | | | | | This commit relands r331904. Adding a SrcMgr::CharacteristicKind parameter to the InclusionDirective in PPCallbacks, and updating calls to that function. This will be useful in https://reviews.llvm.org/D43778 to determine which includes are system headers. Differential Revision: https://reviews.llvm.org/D46614 llvm-svn: 332021
* [OPENMP, NVPTX] Initial support for L2 parallelism in SPMD mode.Alexey Bataev2018-05-102-61/+176
| | | | | | | | Added initial support for L2 parallelism in SPMD mode. Note, though, that the orphaned parallel directives are not currently supported in SPMD mode. llvm-svn: 332016
* This patch provides that bitfields are splitted even in caseStrahinja Petrovic2018-05-101-10/+12
| | | | | | | | when current field is not legal integer type. Differential Revision: https://reviews.llvm.org/D39053 llvm-svn: 331979
* Revert "[Itanium] Emit type info names with external linkage."Eric Fiselier2018-05-101-63/+58
| | | | | | | This reverts commit r331957. It seems to be causing failures on ppc64le-linux. llvm-svn: 331963
* [X86] Change the implementation of scalar masked load/store intrinsics to ↵Craig Topper2018-05-101-2/+2
| | | | | | | | | | not use a 512-bit intermediate vector. This is unnecessary for AVX512VL supporting CPUs like SKX. We can just emit a 128-bit masked load/store here no matter what. The backend will widen it to 512-bits on KNL CPUs. Fixes the frontend portion of PR37386. Need to fix the backend to optimize the new sequences well. llvm-svn: 331958
* [Itanium] Emit type info names with external linkage.Eric Fiselier2018-05-101-58/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The Itanium ABI requires that the type info for pointer-to-incomplete types to have internal linkage, so that it doesn't interfere with the type info once completed. Currently it also marks the type info name as internal as well. However, this causes a bug with the STL implementations, which use the type info name pointer to perform ordering and hashing of type infos. For example: ``` // header.h struct T; extern std::type_info const& Info; // tu_one.cpp #include "header.h" std::type_info const& Info = typeid(T*); // tu_two.cpp #include "header.h" struct T {}; int main() { auto &TI1 = Info; auto &TI2 = typeid(T*); assert(TI1 == TI2); // Fails assert(TI1.hash_code() == TI2.hash_code()); // Fails } ``` This patch fixes the STL bug by emitting the type info name as linkonce_odr when the type-info is for a pointer-to-incomplete type. Note that libc++ could fix this without a compiler change, but the quality of fix would be poor. The library would either have to: (A) Always perform strcmp/string hashes. (B) Determine if we have a pointer-to-incomplete type, and only do strcmp then. This would require an ABI break for libc++. Reviewers: rsmith, rjmccall, majnemer, vsapsai Reviewed By: rjmccall Subscribers: smeenai, cfe-commits Differential Revision: https://reviews.llvm.org/D46665 llvm-svn: 331957
* [Builtins] Improve the IR emitted for MSVC compatible rotr/rotl builtins to ↵Craig Topper2018-05-101-24/+12
| | | | | | | | | | | | | | | | | | | | | | | match what the middle and backends understand Previously we emitted something like rotl(x, n) { n &= bitwidth-1; return n != 0 ? ((x << n) | (x >> (bitwidth - n)) : x; } We use a select to avoid the undefined behavior on the (bitwidth - n) shift. The middle and backend don't really recognize this as a rotate and end up emitting a cmov or control flow because of the select. A better pattern is (x << (n & mask)) | (x << (-n & mask)) where mask is bitwidth - 1. Fixes the main complaint in PR37387. There's still some work to be done if the user writes that sequence directly on a short or char where type promotion rules can prevent it from being recognized. The builtin is emitting direct IR with unpromoted types so that isn't a problem for it. Differential Revision: https://reviews.llvm.org/D46656 llvm-svn: 331943
OpenPOWER on IntegriCloud