summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* [coroutines] Add __builtin_coro_noop => llvm.coro.noopGor Nishanov2018-04-021-0/+2
| | | | | | | | | | | | | A recent addition to Coroutines TS (https://wg21.link/p0913) adds a pre-defined coroutine noop_coroutine that does nothing. To implement this feature, we implemented an llvm.coro.noop intrinsic that returns a coroutine handle to a coroutine that does nothing when resumed or destroyed. This patch adds a builtin __builtin_coro_noop() that maps to llvm.coro.noop intrinsic. Related llvm change: https://reviews.llvm.org/D45114 llvm-svn: 328993
* [Coroutines] Schedule coro-split before asanBrian Gesiak2018-04-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The docs for the LLVM coroutines intrinsic `@llvm.coro.id` state that "The second argument, if not null, designates a particular alloca instruction to be a coroutine promise." However, if the address sanitizer pass is run before the `@llvm.coro.id` intrinsic is lowered, the `alloca` instruction passed to the intrinsic as its second argument is converted, as per the https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm docs, to an `inttoptr` instruction that accesses the address of the promise. On optimization levels `-O1` and above, the `-asan` pass is run after `-coro-early`, `-coro-split`, and `-coro-elide`, and before `-coro-cleanup`, and so there is no issue. At `-O0`, however, `-asan` is run in between `-coro-early` and `-coro-split`, which causes an assertion to be hit when the `inttoptr` instruction is forcibly cast to an `alloca`. Rearrange the passes such that the coroutine passes are registered before the sanitizer passes. Test Plan: Compile a simple C++ program that uses coroutines in `-O0` with `-fsanitize-address`, and confirm no assertion is hit: `clang++ coro-example.cpp -fcoroutines-ts -g -fsanitize=address -fno-omit-frame-pointer`. Reviewers: GorNishanov, lewissbaker, EricWF Reviewed By: GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43927 llvm-svn: 328951
* Fix a major swiftcall ABI bug with trivial C++ class types.John McCall2018-04-011-16/+4
| | | | | | | | | | | | | | | | | | | | | | The problem with the previous logic was that there might not be any explicit copy/move constructor declarations, e.g. if the type is trivial and we've never type-checked a copy of it. Relying on Sema's computation seems much more reliable. Also, I believe Richard's recommendation is exactly the rule we use now on the Itanium ABI, modulo the trivial_abi attribute (which this change of course fixes our handling of in Swift). This does mean that we have a less portable rule for deciding indirectness for swiftcall. I would prefer it if we just applied the Itanium rule universally under swiftcall, but in the meantime, I need to fix this bug. This only arises when defining functions with class-type arguments in C++, as we do in the Swift runtime. It doesn't affect normal Swift operation because we don't import code as C++. llvm-svn: 328942
* Revert r328845, it caused crbug.com/827810.Nico Weber2018-03-312-12/+14
| | | | llvm-svn: 328922
* [OPENMP] Added emission of offloading data sections for declare targetAlexey Bataev2018-03-306-159/+386
| | | | | | | | | | 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. llvm-svn: 328888
* Hoist MethodVFTableLocation out of MicrosoftVTableContext, NFCReid Kleckner2018-03-292-14/+12
| | | | | | | | | | | | | This allows forward declaring it so that we can add it to MicrosoftMangleContext::mangleVirtualMemPtrThunk without including VTableBuilder.h. That saves a hashtable lookup when emitting virtual member pointer functions. It also shortens a really long type name. This struct has "VFtable" in the name, so it seems pretty unlikely that someone will assume it is generally useful for non-MS C++ ABI stuff. llvm-svn: 328845
* Set dso_local on cfi_slowpath.Rafael Espindola2018-03-291-4/+5
| | | | llvm-svn: 328836
* Mark __cfi_check as dso_local.Rafael Espindola2018-03-291-0/+1
| | | | llvm-svn: 328825
* Generalize NRVO to cover C structs.Akira Hatanaka2018-03-291-12/+46
| | | | | | | | | | | This commit generalizes NRVO to cover C structs (both trivial and non-trivial structs). rdar://problem/33599681 Differential Revision: https://reviews.llvm.org/D44968 llvm-svn: 328809
* Set dso_local when clearing dllimport.Rafael Espindola2018-03-291-1/+3
| | | | llvm-svn: 328801
* Set calling convention for CUDA kernelYaxun Liu2018-03-294-0/+16
| | | | | | | | | | | This patch sets target specific calling convention for CUDA kernels in IR. Patch by Greg Rodgers. Revised and lit test added by Yaxun Liu. Differential Revision: https://reviews.llvm.org/D44747 llvm-svn: 328795
* Disable emitting static extern C aliases for amdgcn target for CUDAYaxun Liu2018-03-293-3/+16
| | | | | | | | | Patch by Greg Rodgers. Revised and lit test added by Yaxun Liu. Differential Revision: https://reviews.llvm.org/D44987 llvm-svn: 328793
* [Hexagon] Aid bit-reverse load intrinsics lowering with bitcodeKrzysztof Parzyszek2018-03-291-0/+51
| | | | | | | | | | | The conversion of operatios to bitcode helps to eliminate an additional store in certain cases. We used to lower these load intrinsics in DAG to DAG conversion by which time, the "Dead Store Elimination" pass is already run. There is an associated LLVM patch. Patch by Sumanth Gundapaneni. llvm-svn: 328776
* [ObjC++] Make parameter passing and function return compatible with ObjCAkira Hatanaka2018-03-284-76/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ObjC and ObjC++ pass non-trivial structs in a way that is incompatible with each other. For example: typedef struct { id f0; __weak id f1; } S; // this code is compiled in c++. extern "C" { void foo(S s); } void caller() { // the caller passes the parameter indirectly and destructs it. foo(S()); } // this function is compiled in c. // 'a' is passed directly and is destructed in the callee. void foo(S a) { } This patch fixes the incompatibility by passing and returning structs with __strong or weak fields using the C ABI in C++ mode. __strong and __weak fields in a struct do not cause the struct to be destructed in the caller and __strong fields do not cause the struct to be passed indirectly. Also, this patch fixes the microsoft ABI bug mentioned here: https://reviews.llvm.org/D41039?id=128767#inline-364710 rdar://problem/38887866 Differential Revision: https://reviews.llvm.org/D44908 llvm-svn: 328731
* [Hexagon] Add support for "new" circular buffer intrinsicsKrzysztof Parzyszek2018-03-281-0/+94
| | | | | | | | | | | | | These instructions have been around for a long time, but we haven't supported intrinsics for them. The "new" vesrions use the CSx register for the start of the buffer instead of the K field in the Mx register. There is a related llvm patch. Patch by Brendon Cahoon. llvm-svn: 328725
* Fix for LLVM header changesDavid Blaikie2018-03-281-0/+1
| | | | llvm-svn: 328718
* [OPENMP] Codegen for ctor|dtor of declare target variables.Alexey Bataev2018-03-284-69/+209
| | | | | | | | When the declare target variables are emitted for the device, constructors|destructors for these variables must emitted and registered by the runtime in the offloading sections. llvm-svn: 328705
* [clang] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang2018-03-273-5/+5
| | | | | | | | | | | r327219 added wrappers to std::sort which randomly shuffle the container before sorting. This will help in uncovering non-determinism caused due to undefined sorting order of objects having the same key. To make use of that infrastructure we need to invoke llvm::sort instead of std::sort. llvm-svn: 328636
* [OPENMP] Codegen for declare target with link clause.Alexey Bataev2018-03-263-67/+149
| | | | | | | | If the link clause is used on the declare target directive, the object should be linked on target or target data directives, not during the codegen. Patch adds support for this clause. llvm-svn: 328544
* [libFuzzer] Use OptForFuzzing attribute with -fsanitize=fuzzer.Matt Morehouse2018-03-231-0/+4
| | | | | | | | | | | | | | | | | | | Summary: Disables certain CMP optimizations to improve fuzzing signal under -O1 and -O2. Switches all fuzzer tests to -O2 except for a few leak tests where the leak is optimized out under -O2. Reviewers: kcc, vitalybuka Reviewed By: vitalybuka Subscribers: cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D44798 llvm-svn: 328384
* Change for an LLVM header file moveDavid Blaikie2018-03-231-1/+1
| | | | llvm-svn: 328380
* [AMDGPU] Fix codegen for inline assemblyYaxun Liu2018-03-231-1/+1
| | | | | | | | Need to override convertConstraint to recognise amdgpu specific register names. Differential Revision: https://reviews.llvm.org/D44533 llvm-svn: 328359
* [AMDGPU] Update OpenCL to use 48 bytes of implicit arguments for AMDGPU (CLANG)Tony Tye2018-03-231-1/+1
| | | | | | | | Add two additional implicit arguments for OpenCL for the AMDGPU target using the AMDHSA runtime to support device enqueue. Differential Revision: https://reviews.llvm.org/D44696 llvm-svn: 328350
* [AMDGPU] Remove use of OpenCL triple environment and replace with function ↵Tony Tye2018-03-231-0/+5
| | | | | | | | | | | attribute for AMDGPU (CLANG) - Remove use of the opencl and amdopencl environment member of the target triple for the AMDGPU target. - Use a function attribute to communicate to the AMDGPU backend. Differential Revision: https://reviews.llvm.org/D43735 llvm-svn: 328347
* Bring r328238 back with a fix.Rafael Espindola2018-03-231-0/+1
| | | | | | | | | | | | The issues was that we were setting hidden visibility if, when processing a hidden class, we found out that we needed to emit a reference to a vtable provided by the standard library. Original message: Set dso_local on vtables. llvm-svn: 328288
* [ARM] Add ARMv8.2-A FP16 vector intrinsicAbderrazek Zaafrani2018-03-231-20/+42
| | | | | | | | Putting back the code in commit r327189 that was reverted in r322737. The code is being committed in three stages and this one is the last stage: 1) r327455 fp16 feature flags, 2) r327836 pass half type or i16 based on FullFP16, and 3) the code here which the front-end fp16 vector intrinsic for ARM. Differential revision https://reviews.llvm.org/D43650 llvm-svn: 328277
* Set dso_local on __ImageBase.Rafael Espindola2018-03-221-4/+6
| | | | llvm-svn: 328266
* Revert "Set dso_local on vtables."Rafael Espindola2018-03-221-3/+2
| | | | | | | | This reverts commit r328238. Looks like it broke some buildbots. llvm-svn: 328242
* Set dso_local on vtables.Rafael Espindola2018-03-221-2/+3
| | | | llvm-svn: 328238
* Set dso_local on builtin functions.Rafael Espindola2018-03-221-7/+1
| | | | | | | | | | The difference between CreateRuntimeFunction and CreateBuiltinFunction is that CreateBuiltinFunction would not set dllimport or dso_local. To keep the current semantics, just forward to CreateRuntimeFunction with Local=true so it doesn't add dllimport. llvm-svn: 328224
* [OpenMP][Clang] Add call to global data sharing stack initialization on the ↵Gheorghe-Teodor Bercea2018-03-221-0/+5
| | | | | | | | | | | | | | | | workers side Summary: The workers also need to initialize the global stack. The call to the initialization function needs to happen after the kernel_init() function is called by the master. This ensures that the per-team data structures of the runtime have been initialized. Reviewers: ABataev, grokos, carlo.bertolli, caomhin Reviewed By: ABataev Subscribers: jholewinski, guansong, cfe-commits Differential Revision: https://reviews.llvm.org/D44749 llvm-svn: 328219
* [CodeGen] Emit DWARF "constructor" calling conventionJonas Devlieghere2018-03-221-3/+11
| | | | | | | | | | | Now that LLVM has support for emitting calling conventions in DWARF (see r328191) have clang emit them. Patch by: Adrien Guinet Differential revision: https://reviews.llvm.org/D42351 llvm-svn: 328196
* Fix for LLVM change (Transforms/Utils/Local.h -> Analysis/Utils/Local.h)David Blaikie2018-03-211-3/+3
| | | | llvm-svn: 328166
* [NVPTX] Make tensor shape part of WMMA intrinsic's name.Artem Belevich2018-03-211-23/+23
| | | | | | | | | | This is needed for the upcoming implementation of the new 8x32x16 and 32x8x16 variants of WMMA instructions introduced in CUDA 9.1. Differential Revision: https://reviews.llvm.org/D44719 llvm-svn: 328158
* [Builtins] Overload __builtin_operator_new/delete to allow forwarding to ↵Eric Fiselier2018-03-213-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | usual allocation/deallocation functions. Summary: Libc++'s default allocator uses `__builtin_operator_new` and `__builtin_operator_delete` in order to allow the calls to new/delete to be ellided. However, libc++ now needs to support over-aligned types in the default allocator. In order to support this without disabling the existing optimization Clang needs to support calling the aligned new overloads from the builtins. See llvm.org/PR22634 for more information about the libc++ bug. This patch changes `__builtin_operator_new`/`__builtin_operator_delete` to call any usual `operator new`/`operator delete` function. It does this by performing overload resolution with the arguments passed to the builtin to determine which allocation function to call. If the selected function is not a usual allocation function a diagnostic is issued. One open issue is if the `align_val_t` overloads should be considered "usual" when `LangOpts::AlignedAllocation` is disabled. In order to allow libc++ to detect this new behavior the value for `__has_builtin(__builtin_operator_new)` has been updated to `201802`. Reviewers: rsmith, majnemer, aaron.ballman, erik.pilkington, bogner, ahatanak Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43047 llvm-svn: 328134
* Set dso_local on runtime variables.Rafael Espindola2018-03-211-1/+4
| | | | llvm-svn: 328068
* Delete BuiltinCC. NFC.Rafael Espindola2018-03-205-26/+3
| | | | | | It is always identical to RuntimeCC. llvm-svn: 328050
* Set dso_local on string literals.Rafael Espindola2018-03-201-0/+1
| | | | llvm-svn: 328040
* [AArch64] Add vmulxh_lane fp16 vector intrinsicAbderrazek Zaafrani2018-03-201-0/+10
| | | | | | https://reviews.llvm.org/D44591 llvm-svn: 328038
* Set dso_local for runtime function.Rafael Espindola2018-03-201-0/+1
| | | | | | | This is another case where there is special logic for adding dllimport and so we cannot use setGVProperties. llvm-svn: 328036
* [NVPTX] Make tensor load/store intrinsics overloaded.Artem Belevich2018-03-201-5/+3
| | | | | | | | | | | | | | | | This way we can support address-space specific variants without explicitly encoding the space in the name of the intrinsic. Less intrinsics to deal with -> less boilerplate. Added a bit of tablegen magic to match/replace an intrinsics with a pointer argument in particular address space with the space-specific instruction variant. Updated tests to use non-default address spaces. Differential Revision: https://reviews.llvm.org/D43268 llvm-svn: 328006
* Set dso_local for CFConstantStringClassReference.Rafael Espindola2018-03-201-7/+7
| | | | | | | This one cannot use setGVProperties since it has special logic for when it is dllimport or not. llvm-svn: 327993
* Set dso_local for guid decls.Rafael Espindola2018-03-201-0/+1
| | | | llvm-svn: 327991
* [OPENMP, NVPTX] Codegen for target distribute parallel combinedAlexey Bataev2018-03-201-8/+46
| | | | | | | | | | constructs in generic mode. Fixed codegen for distribute parallel combined constructs. We have to pass and read the shared lower and upper bound from the distribute region in the inner parallel region. Patch is for generic mode. llvm-svn: 327990
* [OPENMP, NVPTX] Globalization of the private redeclarations.Alexey Bataev2018-03-203-91/+157
| | | | | | | | If the generic codegen is enabled and private copy of the original variable escapes the declaration context, this private copy should be globalized just like it was the original variable. llvm-svn: 327985
* [CodeGen] Ignore OpaqueValueExprs that are unique references to theirAkira Hatanaka2018-03-205-26/+52
| | | | | | | | | | | | | | | | | | | | | | | | | source expressions when iterating over a PseudoObjectExpr's semantic subexpression list. Previously the loop in emitPseudoObjectExpr would emit the IR for each OpaqueValueExpr that was in a PseudoObjectExpr's semantic-form expression list and use the result when the OpaqueValueExpr later appeared in other expressions. This caused an assertion failure when AggExprEmitter tried to copy the result of an OpaqueValueExpr and the copied type didn't have trivial copy/move constructors or assignment operators. This patch adds flag IsUnique to OpaqueValueExpr which indicates it is a unique reference to its source expression (it is not used in multiple places). The loop in emitPseudoObjectExpr ignores OpaqueValueExprs that are unique and CodeGen visitors simply traverse the source expressions of such OpaqueValueExprs. rdar://problem/34363596 Differential Revision: https://reviews.llvm.org/D39562 llvm-svn: 327939
* [CodeGen] Add funclet token to ARC markerShoaib Meenai2018-03-191-1/+1
| | | | | | | | | | | | | | | | The inline assembly generated for the ARC autorelease elision marker must have a funclet token if it's emitted inside a funclet, otherwise the inline assembly (and all subsequent code in the funclet) will be marked unreachable. r324689 fixed this issue for regular inline assembly blocks. Note that clang only emits the marker at -O0, so this only fixes that case. The optimizations case (where the marker is emitted by the backend) will be fixed in a separate change. Differential Revision: https://reviews.llvm.org/D44640 llvm-svn: 327892
* [OPENMP, NVPTX] Reworked castToType() function, NFC.Alexey Bataev2018-03-191-27/+34
| | | | | | | Reworked function castToType to use more frontend functionality rather than the backend. llvm-svn: 327873
* [ObjC] Allow declaring __weak pointer fields in C structs in ARC.Akira Hatanaka2018-03-195-14/+96
| | | | | | | | | | | | | | | | | | | This patch uses the infrastructure added in r326307 for enabling non-trivial fields to be declared in C structs to allow __weak fields in C structs in ARC. This recommits r327206, which was reverted because it caused module-enabled builders to fail. I discovered that the CXXRecordDecl::CanPassInRegisters flag wasn't being set correctly in some cases after I moved it to RecordDecl. Thanks to Eric Liu for helping me investigate the bug. rdar://problem/33599681 https://reviews.llvm.org/D44095 llvm-svn: 327870
* [OPENMP] Fix build with MSVC, NFC.Alexey Bataev2018-03-191-2/+2
| | | | llvm-svn: 327868
OpenPOWER on IntegriCloud