summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* [OPENMP, NVPTX] Emit correct thread id.Alexey Bataev2018-03-192-28/+31
| | | | | | | We emitted fake thread id for the outined function in NVPTX codegen. Patch adds emission of the real thread id. llvm-svn: 327867
* [ARM] Pass half or i16 types for NEON intrinsicsSjoerd Meijer2018-03-191-15/+17
| | | | | | | | | | | | | | | For generating NEON intrinsics, this determines the NEON data type, and whether it should be a half type or an i16 type. I.e., we always pass a half type for AArch64, this hasn't changed, but now also for ARM but only when FullFP16 is enabled, and i16 otherwise. This is intended to be non-functional change, but together with the backend work in D44538 which adds support for f16 vectors, this enables adding the AArch32 FP16 (vector) intrinsics. Differential Revision: https://reviews.llvm.org/D44561 llvm-svn: 327836
* Fix codegen for structured binding binding in conditionsZhihao Yuan2018-03-171-5/+5
| | | | | | | | | | | | | | | | | | | | | Summary: The codegen for conditions assumes that a normal variable declaration is used in a condition, but this is not the case when a structured binding is used. This fixes [PR36747](http://llvm.org/pr36747). Thanks Nicolas Lesser for contributing the patch. Reviewers: lichray, rsmith Reviewed By: lichray Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D44534 llvm-svn: 327780
* Adding nocf_check attribute for cf-protection fine tuningOren Ben Simhon2018-03-171-0/+3
| | | | | | | | | | The patch adds nocf_check target independent attribute for disabling checks that were enabled by cf-protection flag. The attribute can be appertained to functions and function pointers. Attribute name follows GCC's similar attribute name. Differential Revision: https://reviews.llvm.org/D41880 llvm-svn: 327768
* [MS] Fix bug in r327732 with devirtualized complete destructor callsReid Kleckner2018-03-161-0/+10
| | | | llvm-svn: 327754
* [MS] Don't escape MS C++ names with \01Reid Kleckner2018-03-163-3/+3
| | | | | | | It is not needed after LLVM r327734. Now it will be easier to copy-paste IR symbol names from Clang. llvm-svn: 327738
* [MS] Always use base dtors in place of complete/vbase dtors when possibleReid Kleckner2018-03-165-26/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously we tried too hard to uphold the fiction that destructor variants work like they do on Itanium throughout the ABI-neutral parts of clang. This lead to MS C++ ABI incompatiblities and other bugs. Now, -mconstructor-aliases will no longer control this ABI detail, and clang -cc1's LLVM IR output will be this much closer to the clang driver's. Based on a patch by Zahira Ammarguellat: https://reviews.llvm.org/D39063 I've tried to move the logic that Zahira added into MicrosoftCXXABI.cpp. There is only one ABI-specific detail sticking out, and that is in CodeGenModule::getAddrOfCXXStructor, where we collapse complete dtors to base dtors in the MS ABI. This fixes PR32990. Reviewers: erichkeane, zahiraam, majnemer, rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44505 llvm-svn: 327732
* Fix compilation warning introduced in r327654Mikael Holmen2018-03-161-1/+1
| | | | | | | | | | | | | | The compiler complained about ../tools/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:184:15: error: unused variable 'CSI' [-Werror,-Wunused-variable] if (auto *CSI = CGF.CapturedStmtInfo) { ^ 1 error generated. I don't know this code but it seems like an easy fix so I push it anyway to get rid of the warning. llvm-svn: 327694
* [OPENMP, NVPTX] Improve globalization of the variables captured by value.Alexey Bataev2018-03-153-86/+205
| | | | | | | | | | | | | If the variable is captured by value and the corresponding parameter in the outlined function escapes its declaration context, this parameter must be globalized. To globalize it we need to get the address of the original parameter, load the value, store it to the global address and use this global address instead of the original. Patch improves globalization for parallel|teams regions + functions in declare target regions. llvm-svn: 327654
* [OPENMP] Codegen for `omp declare target` construct.Alexey Bataev2018-03-155-6/+95
| | | | | | | | Added initial codegen for device side of declarations inside `omp declare target` construct + codegen for implicit `declare target` functions, which are used in the target regions. llvm-svn: 327636
* Recommit r326946 after reducing CallArgList memory footprintYaxun Liu2018-03-1512-108/+202
| | | | llvm-svn: 327634
* Set dso_local for NSConcreteStackBlock.Rafael Espindola2018-03-141-4/+4
| | | | llvm-svn: 327544
* Set dso_local on external rtti GVs.Rafael Espindola2018-03-142-6/+5
| | | | | | | | | | | In this particular case it would be possible to just add an else with CGM.setDSOLocal(GV), but it seems better to have as many callers as possible just call setGVProperties so that we can centralize the logic there. This patch then makes setGVProperties able to handle null Decls. llvm-svn: 327543
* CodeGen: Reduce LValue and CallArgList memory footprint before recommitting ↵Yaxun Liu2018-03-142-6/+9
| | | | | | | | | | | | | | | | | | r326946 Recent change r326946 (https://reviews.llvm.org/D34367) causes regression in Eigen due to increased memory footprint of CallArg. This patch reduces LValue size from 112 to 96 bytes and reduces inline argument count of CallArgList from 16 to 8. It has been verified that this will let the added deep AST tree test pass with r326946. In the long run, CallArg or LValue memory footprint should be further optimized. Differential Revision: https://reviews.llvm.org/D44445 llvm-svn: 327515
* [OpenMP] Add OpenMP data sharing infrastructure using global memoryGheorghe-Teodor Bercea2018-03-147-29/+658
| | | | | | | | | | | | | | | | | Summary: This patch handles the Clang code generation phase for the OpenMP data sharing infrastructure. TODO: add a more detailed description. Reviewers: ABataev, carlo.bertolli, caomhin, hfinkel, Hahnfeld Reviewed By: ABataev Subscribers: jholewinski, guansong, cfe-commits Differential Revision: https://reviews.llvm.org/D43660 llvm-svn: 327513
* This reverts "r327189 - [ARM] Add ARMv8.2-A FP16 vector intrinsic"Sjoerd Meijer2018-03-132-66/+57
| | | | | | | This is causing problems in testing, and PR36683 was raised. Reverting it until we have sorted out how to pass f16 vectors. llvm-svn: 327437
* Reland "[Attr] Fix parameter indexing for several attributes"Joel E. Denny2018-03-131-5/+4
| | | | | | | | | Relands r326602 (reverted in r326862) with new test and fix for PR36620. Differential Revision: https://reviews.llvm.org/D43248 llvm-svn: 327405
* Revert "[ObjC] Allow declaring __weak pointer fields in C structs inAkira Hatanaka2018-03-125-96/+14
| | | | | | | | | | | ARC." This reverts commit r327206 as there were test failures caused by this patch. http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180312/221427.html llvm-svn: 327294
* [CodeGen] Eagerly emit lifetime.end markers for callsGeorge Burgess IV2018-03-101-6/+28
| | | | | | | | | | | | | | | | | | | | | | In C, we'll wait until the end of the scope to clean up aggregate temporaries used for returns from calls. This means in cases like: { // Assuming that `Bar` is large enough to warrant indirect returns struct Bar b = {}; b = foo(&b); b = foo(&b); b = foo(&b); b = foo(&b); } ...We'll allocate space for 5 Bars on the stack (`b`, and 4 temporaries). This becomes painful in things like large switch statements. If cleaning up sooner is trivial, we should do it. llvm-svn: 327229
* [ObjC] Allow declaring __weak pointer fields in C structs in ARC.Akira Hatanaka2018-03-105-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. rdar://problem/33599681 Differential Revision: https://reviews.llvm.org/D44095 llvm-svn: 327206
* Revert r326946. It caused stack overflows by significantly increasing the ↵Richard Smith2018-03-1012-201/+108
| | | | | | size of a CallArgList. llvm-svn: 327195
* [CodeGen] Try to not call a dtor after lifetime.endGeorge Burgess IV2018-03-101-47/+51
| | | | | | | | | | | | | | | | | | | | If CodeGenFunction::EmitCall is: - asked to emit a call with an indirectly returned value, - given an invalid return value slot, and - told the return value of the function it's calling is unused then it'll make its own temporary, and add lifetime markers so that the temporary's lifetime ends immediately after the call. The early lifetime.end becomes problematic when we need to run a destructor on the result of the function. Instead of unconditionally saying that results of all calls are used here (which would be correct, but would also cause us to never emit lifetime markers for these temporaries), we just build our own temporary to pass in when a dtor has to be run. llvm-svn: 327192
* [ARM] Add ARMv8.2-A FP16 vector intrinsicAbderrazek Zaafrani2018-03-092-57/+66
| | | | | | | | Add the fp16 neon vector intrinsic for ARM as described in the ARM ACLE document. Reviews in https://reviews.llvm.org/D43650 llvm-svn: 327189
* [OPENMP] Fix the address of the original variable in task reductions.Alexey Bataev2018-03-091-0/+3
| | | | | | | | If initialization of the task reductions requires pointer to original variable, which is stored in the threadprivate storage, we used the address of this pointer instead. llvm-svn: 327136
* CodeGen: simplify and validate exception personalitiesSaleem Abdulrasool2018-03-091-19/+13
| | | | | | | | | | | | Simplify the dispatching for the personality routines. This really had no test coverage previously, so add test coverage for the various cases. This turns out to be pretty complicated as the various languages and models interact to change personalities around. You really should feel bad for the compiler if you are using exceptions. There is no reason for this type of cruelty. llvm-svn: 327105
* [OPENMP] Emit sizes/init ptrs etc. data for task reductions beforeAlexey Bataev2018-03-081-10/+10
| | | | | | | | | | | using. We may emit the code in wrong order because of incorrect implementation of the runtime functions for task reductions. Threadprivate storages may be initialized after real initialization of the reduction items. Patch fixes this problem. llvm-svn: 327008
* [CodeGen] Emit lifetime.ends in both EH and non-EH blocksGeorge Burgess IV2018-03-081-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this, we'd only emit lifetime.ends for these temps in non-exceptional paths. This potentially made our stack larger than it needed to be for any code that follows an EH cleanup. e.g. in ``` struct Foo { char cs[32]; }; void escape(void *); struct Bar { ~Bar() { char cs[64]; escape(cs); } }; Foo getFoo(); void baz() { Bar b; getFoo(); } ``` baz() would require 96 bytes of stack, since the temporary from getFoo() only had a lifetime.end on the non-exceptional path. This also makes us keep hold of the Value* returned by EmitLifetimeStart, so we don't have to remake it later. llvm-svn: 326988
* Fix a doc typo; NFCGeorge Burgess IV2018-03-081-1/+1
| | | | llvm-svn: 326968
* Set dso_local on tls init functions.Rafael Espindola2018-03-071-1/+3
| | | | | | | We copy the visibility, so copying the dso_local flag seems the natural thing to do. llvm-svn: 326961
* [ms] Emit vtordisp initializers in a deterministic order.Nico Weber2018-03-071-5/+6
| | | | | | | | | | No effective behavior change, just for cleanliness. Analysis and typing by me, actual patch mostly by Reid. Fixes PR36159. https://reviews.llvm.org/D44223 llvm-svn: 326960
* [OpenMP] Remove implicit data sharing code gen that aims to use device ↵Gheorghe-Teodor Bercea2018-03-072-197/+26
| | | | | | | | | | | | | | | | shared memory Summary: Remove this scheme for now since it will be covered by another more generic scheme using global memory. This code will be worked into an optimization for the generic data sharing scheme. Removing this completely and then adding it via future patches will make all future data sharing patches cleaner. Reviewers: ABataev, carlo.bertolli, caomhin Reviewed By: ABataev Subscribers: jholewinski, guansong, cfe-commits Differential Revision: https://reviews.llvm.org/D43625 llvm-svn: 326948
* CodeGen: Fix address space of indirect function argumentYaxun Liu2018-03-0712-108/+201
| | | | | | | | | | | | | | | | | | | | | The indirect function argument is in alloca address space in LLVM IR. However, during Clang codegen for C++, the address space of indirect function argument should match its address space in the source code, i.e., default addr space, even for indirect argument. This is because destructor of the indirect argument may be called in the caller function, and address of the indirect argument may be taken, in either case the indirect function argument is expected to be in default addr space, not the alloca address space. Therefore, the indirect function argument should be mapped to the temp var casted to default address space. The caller will cast it to alloca addr space when passing it to the callee. In the callee, the argument is also casted to the default address space and used. CallArg is refactored to facilitate this fix. Differential Revision: https://reviews.llvm.org/D34367 llvm-svn: 326946
* [OpenCL] Remove block invoke function from emitted block literal structYaxun Liu2018-03-073-88/+68
| | | | | | | | | | | | | | | | | | | | | OpenCL runtime tracks the invoke function emitted for any block expression. Due to restrictions on blocks in OpenCL (v2.0 s6.12.5), it is always possible to know the block invoke function when emitting call of block expression or __enqueue_kernel builtin functions. Since __enqueu_kernel already has an argument for the invoke function, it is redundant to have invoke function member in the llvm block literal structure. This patch removes invoke function from the llvm block literal structure. It also removes the bitcast of block invoke function to the generic block literal type which is useless for OpenCL. This will save some space for the kernel argument, and also eliminate some store instructions. Differential Revision: https://reviews.llvm.org/D43783 llvm-svn: 326937
* [OPENMP] Fix lifetime of the loop counters.Alexey Bataev2018-03-072-76/+102
| | | | | | | | We may emit incorrect lifetime info during codegen for loop counters in OpenMP constructs because of automatic scope cleanup when we needed temporarily locations for private loop counters. llvm-svn: 326922
* Revert r326602, it caused PR36620.Nico Weber2018-03-071-4/+5
| | | | llvm-svn: 326862
* [CodeGen] Don't emit lifetime.end without lifetime.startGeorge Burgess IV2018-03-061-3/+1
| | | | | | | | EmitLifetimeStart returns a non-null `size` pointer if it actually emits a lifetime.start. Later in this function, we use `tempSize`'s nullness to determine whether or not we should emit a lifetime.end. llvm-svn: 326844
* [OPENMP] Fix generation of the unique names for task reductionAlexey Bataev2018-03-062-16/+29
| | | | | | | | | | | variables. If the task has reduction construct and this construct for some variable requires unique threadprivate storage, we may generate different names for variables used in taskgroup task_reduction clause and in task in_reduction clause. Patch fixes this problem. llvm-svn: 326827
* Do not generate calls to fentry with __attribute__((no_instrument_function))Manoj Gupta2018-03-021-4/+6
| | | | | | | | | | | | | | | | | | | Summary: Currently only calls to mcount were suppressed with no_instrument_function attribute. Linux kernel requires that calls to fentry should also not be generated. This is an extended fix for PR PR33515. Reviewers: hfinkel, rengolin, srhines, rnk, rsmith, rjmccall, hans Reviewed By: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43995 llvm-svn: 326639
* Range-ify a for loop. NFCGeorge Burgess IV2018-03-021-5/+2
| | | | llvm-svn: 326607
* [Attr] Fix parameter indexing for several attributesJoel E. Denny2018-03-021-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The patch fixes a number of bugs related to parameter indexing in attributes: * Parameter indices in some attributes (argument_with_type_tag, pointer_with_type_tag, nonnull, ownership_takes, ownership_holds, and ownership_returns) are specified in source as one-origin including any C++ implicit this parameter, were stored as zero-origin excluding any this parameter, and were erroneously printing (-ast-print) and confusingly dumping (-ast-dump) as the stored values. * For alloc_size, the C++ implicit this parameter was not subtracted correctly in Sema, leading to assert failures or to silent failures of __builtin_object_size to compute a value. * For argument_with_type_tag, pointer_with_type_tag, and ownership_returns, the C++ implicit this parameter was not added back to parameter indices in some diagnostics. This patch fixes the above bugs and aims to prevent similar bugs in the future by introducing careful mechanisms for handling parameter indices in attributes. ParamIdx stores a parameter index and is designed to hide the stored encoding while providing accessors that require each use (such as printing) to make explicit the encoding that is needed. Attribute declarations declare parameter index arguments as [Variadic]ParamIdxArgument, which are exposed as ParamIdx[*]. This patch rewrites all attribute arguments that are processed by checkFunctionOrMethodParameterIndex in SemaDeclAttr.cpp to be declared as [Variadic]ParamIdxArgument. The only exception is xray_log_args's argument, which is encoded as a count not an index. Differential Revision: https://reviews.llvm.org/D43248 llvm-svn: 326602
* [OPENMP] Scan all redeclarations looking for `declare simd` attribute.Alexey Bataev2018-03-021-65/+69
| | | | | | | | | Patch fixes the problem with the functions marked as `declare simd`. If the canonical declaration does not have associated `declare simd` construct, we may not generate required code even if other redeclarations are marked as `declare simd`. llvm-svn: 326594
* Add possibility to specify output stream for CompilerInstanceAlexey Sotkin2018-03-021-1/+4
| | | | | | | | | | | | | | Patch by: krisb Reviewers: teemperor Reviewed By: teemperor Subscribers: klimek, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D43809 llvm-svn: 326566
* Add an option to disable tail-call optimization for escaping blocks.Akira Hatanaka2018-03-021-4/+15
| | | | | | | | | | | | | This makes it easier to debug crashes and hangs in block functions since users can easily find out where the block is called from. The option doesn't disable tail-calls from non-escaping blocks since non-escaping blocks are not as hard to debug as escaping blocks. rdar://problem/35758207 Differential Revision: https://reviews.llvm.org/D43841 llvm-svn: 326530
* Always set dso_local in CodeGenModule::setDSOLocal.Rafael Espindola2018-03-021-2/+7
| | | | | | | | | | | | | This shouldn't change any results for now, but is more consistent with how we set dllimport/dllexport and will make future changes easier. Since clang produces IR as it parses, it can find out mid file that something is dllimport. When that happens we have to drop dso_local. This is not a problem right now because CodeGenModule::setDSOLocal is called from relatively few places at the moment. llvm-svn: 326527
* [Driver] Pass -f[no-]emulated-tls and set up ExplicitEmulatedTLSChih-Hung Hsieh2018-03-011-0/+1
| | | | | | | | | | Since LLVM r326341, default EmulatedTLS mode is decided in backend according to target triple. Any front-end should pass -f[no]-emulated-tls to backend and set up ExplicitEmulatedTLS only when the flags are used. Differential Revision: https://reviews.llvm.org/D43965 llvm-svn: 326499
* Remove redundant casts. NFCGeorge Burgess IV2018-03-0111-24/+15
| | | | | | | | | | | | | | | | | | | So I wrote a clang-tidy check to lint out redundant `isa`, `cast`, and `dyn_cast`s for fun. This is a portion of what it found for clang; I plan to do similar cleanups in LLVM and other subprojects when I find time. Because of the volume of changes, I explicitly avoided making any change that wasn't highly local and obviously correct to me (e.g. we still have a number of foo(cast<Bar>(baz)) that I didn't touch, since overloading is a thing and the cast<Bar> did actually change the type -- just up the class hierarchy). I also tried to leave the types we were cast<>ing to somewhere nearby, in cases where it wasn't locally obvious what we were dealing with before. llvm-svn: 326416
* Start setting dllimport/dllexport in setGVProperties.Rafael Espindola2018-03-0110-140/+81
| | | | | | | | | | This is the next step in setting dso_local for COFF. The patches changes setGVProperties to first set dllimport/dllexport and changes a few cases that were setting dllimport/dllexport manually. With this a few more GVs are marked dso_local. llvm-svn: 326397
* Pass a GlobalDecl to SetCommonAttributes. NFC.Rafael Espindola2018-03-012-6/+6
| | | | | | Part of D43900. llvm-svn: 326392
* Inline a trivial function. NFC.Rafael Espindola2018-03-013-10/+2
| | | | llvm-svn: 326391
* Pass a GlobalDecl to setNonAliasAttributes. NFC.Rafael Espindola2018-02-282-4/+5
| | | | | | Also part of D43900. llvm-svn: 326388
OpenPOWER on IntegriCloud