summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCall.cpp
Commit message (Collapse)AuthorAgeFilesLines
* revert SVN r265702, r265640Saleem Abdulrasool2016-04-081-2/+2
| | | | | | | | | | | Revert the two changes to thread CodeGenOptions into the TargetInfo allocation and to fix the layering violation by moving CodeGenOptions into Basic. Code Generation is arguably not particularly "basic". This addresses Richard's post-commit review comments. This change purely does the mechanical revert and will be followed up with an alternate approach to thread the desired information into TargetInfo. llvm-svn: 265806
* Basic: move CodeGenOptions from FrontendSaleem Abdulrasool2016-04-071-2/+2
| | | | | | | | This is a mechanical move of CodeGenOptions from libFrontend to libBasic. This fixes the layering violation introduced earlier by threading CodeGenOptions into TargetInfo. It should also fix the modules based self-hosting builds. NFC. llvm-svn: 265702
* [CUDA] Add -fcuda-flush-denormals-to-zero.Justin Lebar2016-04-051-0/+4
| | | | | | | | | | | | | | | | | | Summary: Setting this flag causes all functions are annotated with the "nvvm-f32ftz" = "true" attribute. In addition, we annotate the module with "nvvm-reflect-ftz" set to 0 or 1, depending on whether -cuda-flush-denormals-to-zero is set. This is read by the NVVMReflect pass. Reviewers: tra, rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18671 llvm-svn: 265435
* IRGen-level lowering for the Swift calling convention.John McCall2016-04-041-23/+155
| | | | llvm-svn: 265324
* [PGO] More comments how function pointers for indirect calls are mappedAdam Nemet2016-03-281-1/+3
| | | | | | | | | | | | | | | | to function names Summary: Hopefully this will make it easier for the next person to figure all this out... Reviewers: bogner, davidxl Subscribers: davidxl, cfe-commits Differential Revision: http://reviews.llvm.org/D18489 llvm-svn: 264681
* Add attributes for preserve_mostcc/preserve_allcc calling conventions to the ↵Roman Levenstein2016-03-161-0/+8
| | | | | | | | | | | | | | | C/C++ front-end Till now, preserve_mostcc/preserve_allcc calling convention attributes were only available at the LLVM IR level. This patch adds attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end. The code was mostly written by Juergen Ributzka. I just added support for the AArch64 target and tests. Differential Revision: http://reviews.llvm.org/D18025 llvm-svn: 263647
* Remove compile time PreserveName in favor of a runtime cc1 ↵Mehdi Amini2016-03-131-1/+1
| | | | | | | | | | | | | | | | | | | | -discard-value-names option Summary: This flag is enabled by default in the driver when NDEBUG is set. It is forwarded on the LLVMContext to discard all value names (but GlobalValue) for performance purpose. This an improved version of D18024 Reviewers: echristo, chandlerc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18127 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 263394
* Temporarily revert these patches:Eric Christopher2016-03-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 60d9845f6a037122d9be9a6d92d4de617ef45b04 Author: Mehdi Amini <mehdi.amini@apple.com> Date: Fri Mar 11 18:48:02 2016 +0000 Fix clang crash: when CodeGenAction is initialized without a context, use the member and not the parameter From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263273 91177308-0d34-0410-b5e6-96231b3b80d8 commit af7ce3bf04a75ad5124b457b805df26006bd215b Author: Mehdi Amini <mehdi.amini@apple.com> Date: Fri Mar 11 17:32:58 2016 +0000 Fix build: use -> with pointers and not . Silly typo. From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263267 91177308-0d34-0410-b5e6-96231b3b80d8 commit d0eea119192814954e7368c77d0dc5a9eeec1fbb Author: Mehdi Amini <mehdi.amini@apple.com> Date: Fri Mar 11 17:15:44 2016 +0000 Remove compile time PreserveName switch based on NDEBUG Summary: Following r263086, we are now relying on a flag on the Context to discard Value names in release builds. Reviewers: chandlerc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18024 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263257 91177308-0d34-0410-b5e6-96231b3b80d8 until we can fix the Release builds. This reverts commits 263257, 263267, 263273 llvm-svn: 263320
* Remove compile time PreserveName switch based on NDEBUGMehdi Amini2016-03-111-1/+1
| | | | | | | | | | | | | | | Summary: Following r263086, we are now relying on a flag on the Context to discard Value names in release builds. Reviewers: chandlerc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18024 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 263257
* Add a coerce-and-expand ABIArgInfo as a generalization of someJohn McCall2016-03-111-5/+122
| | | | | | | | of the things we do with Expand / Direct. NFC for now, but this will be used by swiftcall expansion. llvm-svn: 263192
* Preserve ExtParameterInfos into CGFunctionInfo.John McCall2016-03-111-46/+182
| | | | | | | | | As part of this, make the function-arrangement interfaces a little simpler and more semantic. NFC. llvm-svn: 263191
* Resolved Bug 26414.Amjad Aboud2016-03-071-3/+6
| | | | | | | | | https://llvm.org/bugs/show_bug.cgi?id=26414 Since interrupt handler must be returned with iret, tail call can't be used. Differential Revision: http://reviews.llvm.org/D17853 llvm-svn: 262830
* [CUDA] Mark all CUDA device-side function defs, decls, and calls as convergent.Justin Lebar2016-02-241-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is important for e.g. the following case: void sync() { __syncthreads(); } void foo() { do_something(); sync(); do_something_else(): } Without this change, if the optimizer does not inline sync() (which it won't because __syncthreads is also marked as noduplicate, for now anyway), it is free to perform optimizations on sync() that it would not be able to perform on __syncthreads(), because sync() is not marked as convergent. Similarly, we need a notion of convergent calls, since in the case when we can't statically determine a call's target(s), we need to know whether it's safe to perform optimizations around the call. This change is conservative; the optimizer will remove these attrs where it can, see r260318, r260319. Reviewers: majnemer Subscribers: cfe-commits, jhen, echristo, tra Differential Revision: http://reviews.llvm.org/D17056 llvm-svn: 261779
* [WinEH] Make sure terminate handlers have funclet operandsDavid Majnemer2016-02-241-10/+13
| | | | | | | Calls to the terminate handler must be annotated within the exception region they are within. llvm-svn: 261751
* [CodeGen] Fix an assert in CodeGenFunction::EmitFunctionEpilogAkira Hatanaka2016-02-171-1/+19
| | | | | | | | | | | | | | The assert is triggered because isObjCRetainableType() is called on the canonicalized return type that has been stripped of the typedefs and attributes attached to it. To fix this assert, this commit gets the original return type from CurCodeDecl or BlockInfo and uses it instead of the canoicalized type. rdar://problem/24470031 Differential Revision: http://reviews.llvm.org/D16914 llvm-svn: 261151
* RValue refs do not work that way.Benjamin Kramer2016-02-131-1/+2
| | | | llvm-svn: 260823
* Fix undefined behavior when compiling in C++14 due to sized operator deleteRichard Smith2016-02-091-2/+1
| | | | | | | being called with the wrong size: convert CGFunctionInfo to use TrailingObjects and ask TrailingObjects to provide a working 'operator delete' for us. llvm-svn: 260181
* [WinEH] Annotate calls to __RTtypeid with a funclet bundleDavid Majnemer2016-01-261-2/+5
| | | | | | | | | | Clang's CodeGen has several paths which end up invoking or calling a function. The one that we used for calls to __RTtypeid did not appropriately annotate the call with a funclet bundle. This fixes PR26329. llvm-svn: 258877
* Clang changes for value profilingBetul Buyukkurt2016-01-231-0/+5
| | | | | | Differential Revision: http://reviews.llvm.org/D8940 llvm-svn: 258650
* fix formatting; NFCSanjay Patel2016-01-181-7/+5
| | | | llvm-svn: 258097
* [Driver] Add support for -fno-builtin-foo options.Chad Rosier2016-01-061-8/+8
| | | | | | | Addresses PR4941 and rdar://6756912. http://reviews.llvm.org/D15195 llvm-svn: 256937
* [WinEH] Update clang to use operand bundles on call sitesDavid Majnemer2015-12-151-4/+30
| | | | | | | | | | | This updates clang to use bundle operands to associate an invoke with the funclet which it is contained within. Depends on D15517. Differential Revision: http://reviews.llvm.org/D15518 llvm-svn: 255675
* Update clang to use the updated LLVM EH instructionsDavid Majnemer2015-12-121-13/+18
| | | | | | | | | | Depends on D15139. Reviewers: rnk Differential Revision: http://reviews.llvm.org/D15140 llvm-svn: 255423
* Add the `pass_object_size` attribute to clang.George Burgess IV2015-12-021-10/+55
| | | | | | | | | | | | | `pass_object_size` is our way of enabling `__builtin_object_size` to produce high quality results without requiring inlining to happen everywhere. A link to the design doc for this attribute is available at the Differential review link below. Differential Revision: http://reviews.llvm.org/D13263 llvm-svn: 254554
* Preserve exceptions information during calls code generation.Samuel Antao2015-11-231-9/+29
| | | | | | | | | | | This patch changes the generation of CGFunctionInfo to contain the FunctionProtoType if it is available. This enables the code generation for call instructions to look into this type for exception information and therefore generate better quality IR - it will not create invoke instructions for functions that are know not to throw. llvm-svn: 253926
* Add support for function attribute 'disable_tail_calls'.Akira Hatanaka2015-11-131-1/+5
| | | | | | | | | | | | | | | | | | | | | | The ``disable_tail_calls`` attribute instructs the backend to not perform tail call optimization inside the marked function. For example, int callee(int); int foo(int a) __attribute__((disable_tail_calls)) { return callee(a); // This call is not tail-call optimized. } Note that this attribute is different from 'not_tail_called', which prevents tail-call optimization to the marked function. rdar://problem/8973573 Differential Revision: http://reviews.llvm.org/D12547 llvm-svn: 252986
* Extract out a function onto CodeGenModule for getting the map ofEric Christopher2015-11-111-18/+8
| | | | | | | features for a particular function, then use it to clean up some code. llvm-svn: 252819
* Replace tab with 8 spaces, NFC.Yaron Keren2015-11-081-1/+1
| | | | llvm-svn: 252426
* Add support for function attribute 'not_tail_called'.Akira Hatanaka2015-11-061-0/+4
| | | | | | | | | | | | | | | | | | | | | | This attribute is used to prevent tail-call optimizations to the marked function. For example, in the following piece of code, foo1 will not be tail-call optimized: int __attribute__((not_tail_called)) foo1(int); int foo2(int a) { return foo1(a); // Tail-call optimization is not performed. } The attribute has effect only on statically bound calls. It has no effect on indirect calls. Also, virtual functions and objective-c methods cannot be marked as 'not_tail_called'. rdar://problem/22667622 Differential Revision: http://reviews.llvm.org/D12922 llvm-svn: 252369
* CodeGen: Remove implicit ilist iterator conversions, NFCDuncan P. N. Exon Smith2015-11-061-3/+3
| | | | | | | Make ilist iterator conversions explicit in clangCodeGen. Eventually I'll remove them everywhere. llvm-svn: 252358
* [WinEH] Mark calls inside cleanups as noinlineReid Kleckner2015-10-281-2/+8
| | | | | | | | | | | | | | | This works around PR25162. The MSVC tables make it very difficult to correctly inline a C++ destructor that contains try / catch. We've attempted to address PR25162 in LLVM's backend, but it feels pretty infeasible. MSVC and ICC both appear to avoid inlining such complex destructors. Long term, we want to fix this by making the inliner smart enough to know when it is inlining into a cleanup, so it can inline simple destructors (~unique_ptr and ~vector) while avoiding destructors containing try / catch. llvm-svn: 251576
* Move global classes into anonymous namespaces. NFC.Benjamin Kramer2015-10-281-2/+2
| | | | llvm-svn: 251528
* Unify the ObjC entrypoint caches.John McCall2015-10-211-5/+5
| | | | llvm-svn: 250918
* Roll-back r250822.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
* Add an error when calling a builtin that requires features that don'tEric Christopher2015-10-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | match the feature set of the function that they're being called from. This ensures that we can effectively diagnose some[1] code that would instead ICE in the backend with a failure to select message. Example: __m128d foo(__m128d a, __m128d b) { return __builtin_ia32_addsubps(b, a); } compiled for normal x86_64 via: clang -target x86_64-linux-gnu -c would fail to compile in the back end because the normal subtarget features for x86_64 only include sse2 and the builtin requires sse3. [1] We're still not erroring on: __m128i bar(__m128i const *p) { return _mm_lddqu_si128(p); } where we should fail and error on an always_inline function being inlined into a function that doesn't support the subtarget features required. llvm-svn: 250473
* [CodeGen] Remove dead code. NFC.Benjamin Kramer2015-10-151-6/+0
| | | | llvm-svn: 250418
* Don't emit exceptional stackrestore cleanups around inalloca functionsReid Kleckner2015-10-081-14/+1
| | | | | | | | The backend restores the stack pointer after recovering from an exception. This is similar to r245879, but it doesn't try to use the normal cleanup mechanism, so hopefully it won't cause the same breakage. llvm-svn: 249640
* Support __builtin_ms_va_list.Charles Davis2015-09-171-1/+7
| | | | | | | | | | | | | | | | | | Summary: This change adds support for `__builtin_ms_va_list`, a GCC extension for variadic `ms_abi` functions. The existing `__builtin_va_list` support is inadequate for this because `va_list` is defined differently in the Win64 ABI vs. the System V/AMD64 ABI. Depends on D1622. Reviewers: rsmith, rnk, rjmccall CC: cfe-commits Differential Revision: http://reviews.llvm.org/D1623 llvm-svn: 247941
* Generating assumption loads of vptr after ctor call (fixed)Piotr Padlewski2015-09-151-1/+2
| | | | | | | | | | | | | | | | | | Generating call assume(icmp %vtable, %global_vtable) after constructor call for devirtualization purposes. For more info go to: http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html Edit: Fixed version because of PR24479 and other bug caused in chrome. After this patch got reverted because of ScalarEvolution bug (D12719) Merged after John McCall big patch (Added Address). http://reviews.llvm.org/D11859 http://reviews.llvm.org/D12865 llvm-svn: 247646
* Record function attribute "stackrealign" instead of using backend optionAkira Hatanaka2015-09-111-2/+2
| | | | | | | | | | | | -force-align-stack. Also, make changes to the driver so that -mno-stack-realign is no longer an option exposed to the end-user that disallows stack realignment in the backend. Differential Revision: http://reviews.llvm.org/D11815 llvm-svn: 247451
* [MS ABI] Make member pointers return true for isIncompleteTypeDavid Majnemer2015-09-101-2/+2
| | | | | | | The type of a member pointer is incomplete if it has no inheritance model. This lets us reuse more general logic already embedded in clang. llvm-svn: 247346
* Revert "Generating assumption loads of vptr after ctor call (fixed)"Piotr Padlewski2015-09-101-2/+1
| | | | | | | | It seems that there is small bug, and we can't generate assume loads when some virtual functions have internal visibiliy This reverts commit 982bb7d966947812d216489b3c519c9825cacbf2. llvm-svn: 247332
* Don't crash when emitting a block under returns_nonnull.John McCall2015-09-101-2/+2
| | | | | | rdar://22071955 llvm-svn: 247228
* Generating assumption loads of vptr after ctor call (fixed)Piotr Padlewski2015-09-091-1/+2
| | | | | | | | | | | | | | | | | Generating call assume(icmp %vtable, %global_vtable) after constructor call for devirtualization purposes. For more info go to: http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html Edit: Fixed version because of PR24479. After this patch got reverted because of ScalarEvolution bug (D12719) Merged after John McCall big patch (Added Address). http://reviews.llvm.org/D11859 llvm-svn: 247199
* [MS ABI] Don't crash on references to pointers to members in argsDavid Majnemer2015-09-091-2/+2
| | | | | | | | | | | | | We know that a reference can always be dereferenced. However, we don't always know the number of bytes if the reference's pointee type is incomplete. This case was correctly handled but we didn't consider the case where the type is complete but we cannot calculate its size for ABI specific reasons. In this specific case, a member pointer's size is available only under certain conditions. This fixes PR24703. llvm-svn: 247188
* findDominatingStoreToReturn in CGCall.cpp didn't check if a candidate storeJakub Kuderski2015-09-081-11/+14
| | | | | | | | | | | | | | instruction used the ReturnValue as pointer operand or value operand. This led to wrong code gen - in later stages (load-store elision code) the found store and its operand would be erased, causing ReturnValue to become a <badref>. The patch adds a check that makes sure that ReturnValue is a pointer operand of store instruction. Regression test is also added. This fixes PR24386. Differential Revision: http://reviews.llvm.org/D12400 llvm-svn: 247003
* Compute and preserve alignment more faithfully in IR-generation.John McCall2015-09-081-323/+289
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce an Address type to bundle a pointer value with an alignment. Introduce APIs on CGBuilderTy to work with Address values. Change core APIs on CGF/CGM to traffic in Address where appropriate. Require alignments to be non-zero. Update a ton of code to compute and propagate alignment information. As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment helper function to CGF and made use of it in a number of places in the expression emitter. The end result is that we should now be significantly more correct when performing operations on objects that are locally known to be under-aligned. Since alignment is not reliably tracked in the type system, there are inherent limits to this, but at least we are no longer confused by standard operations like derived-to-base conversions and array-to-pointer decay. I've also fixed a large number of bugs where we were applying the complete-object alignment to a pointer instead of the non-virtual alignment, although most of these were hidden by the very conservative approach we took with member alignment. Also, because IRGen now reliably asserts on zero alignments, we should no longer be subject to an absurd but frustrating recurring bug where an incomplete type would report a zero alignment and then we'd naively do a alignmentAtOffset on it and emit code using an alignment equal to the largest power-of-two factor of the offset. We should also now be emitting much more aggressive alignment attributes in the presence of over-alignment. In particular, field access now uses alignmentAtOffset instead of min. Several times in this patch, I had to change the existing code-generation pattern in order to more effectively use the Address APIs. For the most part, this seems to be a strict improvement, like doing pointer arithmetic with GEPs instead of ptrtoint. That said, I've tried very hard to not change semantics, but it is likely that I've failed in a few places, for which I apologize. ABIArgInfo now always carries the assumed alignment of indirect and indirect byval arguments. In order to cut down on what was already a dauntingly large patch, I changed the code to never set align attributes in the IR on non-byval indirect arguments. That is, we still generate code which assumes that indirect arguments have the given alignment, but we don't express this information to the backend except where it's semantically required (i.e. on byvals). This is likely a minor regression for those targets that did provide this information, but it'll be trivial to add it back in a later patch. I partially punted on applying this work to CGBuiltin. Please do not add more uses of the CreateDefaultAligned{Load,Store} APIs; they will be going away eventually. llvm-svn: 246985
* Migrate the target attribute parsing code to returning an instanceEric Christopher2015-09-021-11/+11
| | | | | | | | every time it's called rather than attempting to cache the result. It's unlikely to be called frequently and the overhead of using it in the first place is already factored out. llvm-svn: 246706
* Migrate the target attribute parsing code into an extension off ofEric Christopher2015-09-021-29/+8
| | | | | | | | | | the main attribute and cache the results so we don't have to parse a single attribute more than once. This reapplies r246596 with a fix for an uninitialized class member, and a couple of cleanups and formatting changes. llvm-svn: 246610
OpenPOWER on IntegriCloud