summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Pass a GlobalDecl to SetInternalFunctionAttributes. NFC.Rafael Espindola2018-02-287-26/+27
| | | | | | | | This just reduces the noise in a followup patch. Part of D43900. llvm-svn: 326385
* [OpenMP] Extend NVPTX SPMD implementation of combined constructsCarlo Bertolli2018-02-282-21/+14
| | | | | | | | Differential Revision: https://reviews.llvm.org/D43852 This patch extends the SPMD implementation to all target constructs and guards this implementation under a new flag. llvm-svn: 326368
* CodeGenObjCXX: handle inalloca appropriately for msgSend variantSaleem Abdulrasool2018-02-281-1/+2
| | | | | | | | | | | objc_msgSend_stret takes a hidden parameter for the returned structure's address for the construction. When the function signature is rewritten for the inalloca passing, the return type is no longer marked as indirect but rather inalloca stret. This enhances the test for the indirect return to check for that case as well. This fixes the incorrect return classification for Windows x86. llvm-svn: 326362
* Fix gcc -Wreturn-type warnings after r326307.Nico Weber2018-02-281-0/+2
| | | | llvm-svn: 326355
* [CUDA] Include single GPU binary, NFCI.Jonas Hahnfeld2018-02-281-75/+60
| | | | | | | | | Binaries for multiple architectures are combined by fatbinary, so the current code was effectively not needed. Differential Revision: https://reviews.llvm.org/D43461 llvm-svn: 326342
* [ObjC] Allow declaring __strong pointer fields in structs in Objective-CAkira Hatanaka2018-02-288-71/+1076
| | | | | | | | | | | | | | | | | | | | | ARC mode. Declaring __strong pointer fields in structs was not allowed in Objective-C ARC until now because that would make the struct non-trivial to default-initialize, copy/move, and destroy, which is not something C was designed to do. This patch lifts that restriction. Special functions for non-trivial C structs are synthesized that are needed to default-initialize, copy/move, and destroy the structs and manage the ownership of the objects the __strong pointer fields point to. Non-trivial structs passed to functions are destructed in the callee function. rdar://problem/33599681 Differential Revision: https://reviews.llvm.org/D41228 llvm-svn: 326307
* Inline trivial function. NFC.Rafael Espindola2018-02-281-7/+1
| | | | llvm-svn: 326272
* Pass a GlobalDecl to setAliasAttributes. NFC.Rafael Espindola2018-02-284-6/+6
| | | | | | This just makes a followup change easier to read. llvm-svn: 326270
* Pass a GlobalDecl to setFunctionDefinitionAttributes. NFC.Rafael Espindola2018-02-273-6/+5
| | | | | | This just makes a followup patch easier to read. llvm-svn: 326265
* [DebugInfo] Support DWARF v5 source code embedding extensionScott Linder2018-02-262-5/+27
| | | | | | | | | | | | | In DWARF v5 the Line Number Program Header is extensible, allowing values with new content types. This vendor extension to DWARF v5 allows source text to be embedded directly in the line tables of the debug line section. Add new flag (-g[no-]embed-source) to Driver and CC1 which indicates that source should be passed through to LLVM during CodeGen. Differential Revision: https://reviews.llvm.org/D42766 llvm-svn: 326102
* [CodeGen][DebugInfo] Refactor duplicated code, NFCScott Linder2018-02-261-6/+2
| | | | llvm-svn: 326099
* Set Module Metadata "RtLibUseGOT" when fno-plt is used.Sriraman Tallam2018-02-231-0/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D42217 llvm-svn: 325961
* Bring r325915 back.Rafael Espindola2018-02-234-3/+20
| | | | | | | | | | | | | | | The tests that failed on a windows host have been fixed. Original message: Start setting dso_local for COFF. With this there are still some GVs where we don't set dso_local because setGVProperties is never called. I intend to fix that in followup commits. This is just the bare minimum to teach shouldAssumeDSOLocal what it should do for COFF. llvm-svn: 325940
* Revert "Start setting dso_local for COFF."Rafael Espindola2018-02-234-20/+3
| | | | | | | | This reverts commit r325915. It will take some time to fix the failures on a windows host. llvm-svn: 325929
* Start setting dso_local for COFF.Rafael Espindola2018-02-234-3/+20
| | | | | | | | | With this there are still some GVs where we don't set dso_local because setGVProperties is never called. I intend to fix that in followup commits. This is just the bare minimum to teach shouldAssumeDSOLocal what it should do for COFF. llvm-svn: 325915
OpenPOWER on IntegriCloud