summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* [Coverage] Don't emit mappings for functions in dependent contexts (fixes ↵Vedant Kumar2017-04-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | PR32679) The coverage implementation marks functions which won't be emitted as 'deferred', so that it can emit empty coverage regions for them later (once their linkages are known). Functions in dependent contexts are an exception: if there isn't a full instantiation of a function, it shouldn't be marked 'deferred'. We've been breaking that rule without much consequence because we just ended up with useless, extra, empty coverage mappings. With PR32679, this behavior finally caused a crash, because clang marked a partial template specialization as 'deferred', causing the MS mangler to choke in its delayed-template-parsing mode: error: cannot mangle this template type parameter type yet (http://bugs.llvm.org/show_bug.cgi?id=32679) Fix this by checking if a decl's context is a dependent context before marking it 'deferred'. Based on a patch by Adam Folwarczny! Differential Revision: https://reviews.llvm.org/D32144 llvm-svn: 300723
* Prefer addAttr(Attribute::AttrKind) over the AttributeList overloadReid Kleckner2017-04-192-17/+7
| | | | | | | | This should simplify the call sites, which typically want to tweak one attribute at a time. It should also avoid creating ephemeral AttributeLists that live forever. llvm-svn: 300718
* [CodeGen] Use APInt::lshrInPlace instead of APInt::lshr. NFCCraig Topper2017-04-191-3/+3
| | | | llvm-svn: 300658
* Use less temporary AttributeLists NFCReid Kleckner2017-04-185-51/+33
| | | | llvm-svn: 300628
* Debug Info: Remove special-casing of indirect function argument handling.Adrian Prantl2017-04-181-28/+11
| | | | | | | | | | | | LLVM has changed the semantics of dbg.declare for describing function arguments. After this patch a dbg.declare always takes the *address* of a variable as the first argument, even if the argument is not an alloca. https://bugs.llvm.org/show_bug.cgi?id=32382 rdar://problem/31205000 llvm-svn: 300523
* [ubsan] Skip null checks if they are constant-folded awayVedant Kumar2017-04-171-9/+17
| | | | | | | | | | | | | | | | | | | | | The IR builder can constant-fold null checks if the pointer operand points to a constant. If the "is-non-null" check is folded away to "true", don't emit the null check + branch. Testing: check-clang, check-ubsan. This slightly reduces the amount of null checks we emit when compiling X86ISelLowering.cpp. Here are the numbers from patched/unpatched clangs based on r300371. ------------------------------------- | Setup | # of null checks | ------------------------------------- | unpatched, -O0 | 25251 | | patched, -O0 | 23925 | (-5.3%) ------------------------------------- llvm-svn: 300509
* [ubsan] Skip null checks on pointers to the start of an allocaVedant Kumar2017-04-171-1/+11
| | | | | | | | | | | | | | | | | | | | Pointers to the start of an alloca are non-null, so we don't need to emit runtime null checks for them. Testing: check-clang, check-ubsan. This significantly reduces the amount of null checks we emit when compiling X86ISelLowering.cpp. Here are the numbers from patched / unpatched clangs based on r300371. ------------------------------------- | Setup | # of null checks | ------------------------------------- | unpatched, -O0 | 45439 | | patched, -O0 | 25251 | (-44.4%) ------------------------------------- llvm-svn: 300508
* CodeGen: Let byval parameter use alloca address spaceYaxun Liu2017-04-171-2/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D32133 llvm-svn: 300487
* CodeGen: Let lifetime intrinsic use alloca address spaceYaxun Liu2017-04-173-4/+12
| | | | | | Differential Revision: https://reviews.llvm.org/D31717 llvm-svn: 300485
* [ObjC] Mark loads from __NSArray0 and __NSDictionary0 as invariant.load.Akira Hatanaka2017-04-171-4/+6
| | | | | | | | Also, simplify code by calling MakeNaturalAlignAddrLValue. This is a follow-up to r300396. llvm-svn: 300454
* [ObjC] Use empty Objective-C collection literal constants whenAkira Hatanaka2017-04-151-2/+14
| | | | | | | | | | | | | available. Original patch by Douglas Gregor with minor modifications. This recommits r300389, which broke bots because there have been API changes since the original patch was written. rdar://problem/20689633 llvm-svn: 300396
* Revert "[ObjC] Use empty Objective-C collection literal constants when"Akira Hatanaka2017-04-151-14/+2
| | | | | | | This reverts commit r300389. There were mistakes in the changes I made to CodeGen. llvm-svn: 300391
* [ObjC] Use empty Objective-C collection literal constants whenAkira Hatanaka2017-04-151-2/+14
| | | | | | | | | | available. Original patch by Douglas Gregor with minor modifications. rdar://problem/20689633 llvm-svn: 300389
* [Coverage] Use the new getInstrProfSectionName API (NFC)Vedant Kumar2017-04-151-1/+3
| | | | llvm-svn: 300382
* [ubsan] Don't check alignment if the alignment is 1Vedant Kumar2017-04-141-1/+1
| | | | | | | | | | | | | | If a pointer is 1-byte aligned, there's no use in checking its alignment. Somewhat surprisingly, ubsan can spend a significant amount of time doing just that! This loosely depends on D30283. Testing: check-clang, check-ubsan, and a stage2 ubsan build. Differential Revision: https://reviews.llvm.org/D30285 llvm-svn: 300371
* [ubsan] Reduce alignment checking of C++ object pointersVedant Kumar2017-04-144-16/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch teaches ubsan to insert an alignment check for the 'this' pointer at the start of each method/lambda. This allows clang to emit significantly fewer alignment checks overall, because if 'this' is aligned, so are its fields. This is essentially the same thing r295515 does, but for the alignment check instead of the null check. One difference is that we keep the alignment checks on member expressions where the base is a DeclRefExpr. There's an opportunity to diagnose unaligned accesses in this situation (as pointed out by Eli, see PR32630). Testing: check-clang, check-ubsan, and a stage2 ubsan build. Along with the patch from D30285, this roughly halves the amount of alignment checks we emit when compiling X86FastISel.cpp. Here are the numbers from patched/unpatched clangs based on r298160. ------------------------------------------ | Setup | # of alignment checks | ------------------------------------------ | unpatched, -O0 | 24326 | | patched, -O0 | 12717 | (-47.7%) ------------------------------------------ Differential Revision: https://reviews.llvm.org/D30283 llvm-svn: 300370
* [ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt ↵Kuba Mracek2017-04-142-9/+8
| | | | | | | | | | [take 2] CodeGenFunction::EmitObjCForCollectionStmt currently emits lifetime markers for the loop variable in an inconsistent way: lifetime.start is emitted before the loop is entered, but lifetime.end is emitted inside the loop. AddressSanitizer uses these markers to track out-of-scope accesses to local variables, and we get false positives in Obj-C foreach loops (in the 2nd iteration of the loop). This patch keeps the loop variable alive for the whole loop by extending ForScope and registering the cleanup function inside EmitAutoVarAlloca. Differential Revision: https://reviews.llvm.org/D32029 llvm-svn: 300340
* Fix use after free errorXinliang David Li2017-04-141-1/+1
| | | | llvm-svn: 300304
* Remove unused function /nfcXinliang David Li2017-04-141-4/+0
| | | | llvm-svn: 300301
* Revert r300287.Kuba Mracek2017-04-141-2/+5
| | | | llvm-svn: 300290
* [ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmtKuba Mracek2017-04-141-5/+2
| | | | | | | | CodeGenFunction::EmitObjCForCollectionStmt currently emits lifetime markers for the loop variable in an inconsistent way: lifetime.start is emitted before the loop is entered, but lifetime.end is emitted inside the loop. AddressSanitizer uses these markers to track out-of-scope accesses to local variables, and we get false positives in Obj-C foreach loops (in the 2nd iteration of the loop). The markers of the loop variable need to be either both inside the loop (so that we poison and unpoison the variable in each iteration), or both outside. This patch implements the "both inside" approach. Differential Revision: https://reviews.llvm.org/D32029 llvm-svn: 300287
* [Profile] PE binary coverage bug fixXinliang David Li2017-04-131-1/+1
| | | | | | | | PR/32584 Differential Revision: https://reviews.llvm.org/D32023 llvm-svn: 300279
* [IR] Make getParamAttributes take argument numbers, not ArgNo+1Reid Kleckner2017-04-131-1/+1
| | | | | | | | | | | | Add hasParamAttribute() and use it instead of hasAttribute(ArgNo+1, Kind) everywhere. The fact that the AttributeList index for an argument is ArgNo+1 should be a hidden implementation detail. NFC llvm-svn: 300272
* [IR] Take func, ret, and arg attrs separately in AttributeList::getReid Kleckner2017-04-131-12/+8
| | | | | | | | | | | | | This seems like a much more natural API, based on Derek Schuff's comments on r300015. It further hides the implementation detail of AttributeList that function attributes come last and appear at index ~0U, which is easy for the user to screw up. git diff says it saves code as well: 97 insertions(+), 137 deletions(-) This also makes it easier to change the implementation, which I want to do next. llvm-svn: 300153
* Update Clang for an API change to LLVM's switch case iterator (it is nowChandler Carruth2017-04-121-1/+1
| | | | | | | an actual iterator and so we need to look through it to the case handle). llvm-svn: 300035
* [IR] Add AttributeSet to hide AttributeSetNode* again, NFCReid Kleckner2017-04-121-1/+1
| | | | | | | | | | | | | | | | | Summary: For now, it just wraps AttributeSetNode*. Eventually, it will hold AvailableAttrs as an inline bitset, and adding and removing enum attributes will be super cheap. This sinks AttributeSetNode back down to lib/IR/AttributeImpl.h. Reviewers: pete, chandlerc Subscribers: llvm-commits, jfb Differential Revision: https://reviews.llvm.org/D31940 llvm-svn: 300014
* Modular Codegen: Support homing debug info for types in modular objectsDavid Blaikie2017-04-113-2/+18
| | | | | | | | | Matching the function-homing support for modular codegen. Any type implicitly (implicit template specializations) or explicitly defined in a module is attached to that module's object file and omitted elsewhere (only a declaration used if necessary for references). llvm-svn: 299987
* Reland "[IR] Make AttributeSetNode public, avoid temporary AttributeList copies"Reid Kleckner2017-04-101-10/+4
| | | | | | | | | | | | | | | | | | | | | | | | | This re-lands r299875. I introduced a bug in Clang code responsible for replacing K&R, no prototype declarations with a real function definition with a prototype. The bug was here: // Collect any return attributes from the call. - if (oldAttrs.hasAttributes(llvm::AttributeList::ReturnIndex)) - newAttrs.push_back(llvm::AttributeList::get(newFn->getContext(), - oldAttrs.getRetAttributes())); + newAttrs.push_back(oldAttrs.getRetAttributes()); Previously getRetAttributes() carried AttributeList::ReturnIndex in its AttributeList. Now that we return the AttributeSetNode* directly, it no longer carries that index, and we call this overload with a single node: AttributeList::get(LLVMContext&, ArrayRef<AttributeSetNode*>) That aborted with an assertion on x86_32 targets. I added an explicit triple to the test and added CHECKs to help find issues like this in the future sooner. llvm-svn: 299899
* Update for AllocaInst construction changesMatt Arsenault2017-04-102-3/+6
| | | | llvm-svn: 299889
* Update for lifetime intrinsic signature changeMatt Arsenault2017-04-101-4/+6
| | | | llvm-svn: 299877
* [OPENMP] Fix for PR32333: Crash in call of outlined Function.Alexey Bataev2017-04-101-6/+12
| | | | | | | | | If the type of the captured variable is a pointer(s) to variably modified type, this type was not processed correctly. Need to drill into the type, find the innermost variably modified array type and convert it to canonical parameter type. llvm-svn: 299868
* [cfi] Emit __cfi_check stub in the frontend.Evgeniy Stepanov2017-04-073-1/+24
| | | | | | | | | Previously __cfi_check was created in LTO optimization pipeline, which means LLD has no way of knowing about the existence of this symbol without rescanning the LTO output object. As a result, LLD fails to export __cfi_check, even when given --export-dynamic-symbol flag. llvm-svn: 299806
* Implement _interlockedbittestandset as a builtinHans Wennborg2017-04-071-3/+21
| | | | | | | | | It's used by MS headers in VS 2017 without including intrin.h, so we can't implement it in the header anymore. Differential Revision: https://reviews.llvm.org/D31736 llvm-svn: 299782
* [AMDGPU] Translate reqd_work_group_size into amdgpu_flat_work_group_sizeStanislav Mekhanoshin2017-04-061-3/+8
| | | | | | | | | | | | | These two attributes specify the same info in a different way. AMGPU BE only checks the latter as a target specific attribute as opposed to language specific reqd_work_group_size. This change produces amdgpu_flat_work_group_size out of reqd_work_group_size if specified. Differential Revision: https://reviews.llvm.org/D31728 llvm-svn: 299678
* [coroutines] Add coro.end handlingGor Nishanov2017-04-051-0/+41
| | | | | | | | | | | | | | | | | | Summary: For WinEH, We add a funclet bundle to a coro.end call, so that CoroSplit in LLVM can replace it with cleanup ret and cut the rest out. For landing pad, we add a branch to resume block if coro.end returns true. LLVM Part: https://reviews.llvm.org/D25445 Reviewers: majnemer Reviewed By: majnemer Subscribers: EricWF, cfe-commits, rsmith, mehdi_amini Differential Revision: https://reviews.llvm.org/D25444 llvm-svn: 299510
* Set FMF for -ffp-contract=fastAdam Nemet2017-04-041-4/+24
| | | | | | | | | | | | | | With this, FMF(contract) becomes an alternative way to express the request to contract. These are currently only propagated for FMul, FAdd and FSub. The rest will be added as more FMFs are hooked up for this. This is toward fixing PR25721. Differential Revision: https://reviews.llvm.org/D31168 llvm-svn: 299469
* Preserve vec3 type.Jin-Gu Kang2017-04-042-43/+53
| | | | | | | | | | | | | | Summary: Preserve vec3 type with CodeGen option. Reviewers: Anastasia, bruno Reviewed By: Anastasia Subscribers: bruno, ahatanak, cfe-commits Differential Revision: https://reviews.llvm.org/D30810 llvm-svn: 299445
* [X86][Clang] Converting __mm{|256|512}_movm_epi{8|16|32|64} LLVMIR call into ↵Michael Zuckerman2017-04-041-0/+22
| | | | | | | | | | | | generic intrinsics. This patch is a part two of two reviews, one for the clang and the other for LLVM. In this patch, I covered the clang side, by introducing the intrinsic to the front end. This is done by creating a generic replacement. Differential Revision: https://reviews.llvm.org/D31394a llvm-svn: 299431
* [TargetInfo] Use llvm::alignOf() instead of rewriting it. NFCI.Davide Italiano2017-04-031-2/+2
| | | | llvm-svn: 299364
* [Driver] Don't crash on invalid values of -mrelocation-model=.Davide Italiano2017-04-011-1/+2
| | | | | | | This is handled in a similar way we handle invalid -mcode-model. PR: 31840 llvm-svn: 299315
* [ObjC++] Use the correct EH personality in GNU modeBenjamin Kramer2017-04-011-2/+2
| | | | | | | | | Previously, it would just always use the ObjC DWARF personality, even with SjLj or SEH exceptions. Patch by Jonathan Schleifer, test case by me. llvm-svn: 299306
* [coroutines] Add cleanup for compiler injected objects/allocations in ↵Gor Nishanov2017-04-011-14/+34
| | | | | | | | | | | | | | | | | | coroutine body Summary: * Use pushCleanup to emit freeing coroutine memory on normal and EH exits. * Surround emitted code with CodeGenFunction::RunCleanupsScope. Reviewers: rsmith, rnk, EricWF Reviewed By: rnk Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31460 llvm-svn: 299281
* [ThinLTO] Handle -emit-llvm* in ThinLTO backendsTeresa Johnson2017-03-311-1/+22
| | | | | | | | | | | | | | Summary: Use PreCodeGenModuleHook to invoke the correct writer when emitting LLVM IR, returning false to skip codegen from within thinBackend. Reviewers: pcc, mehdi_amini Subscribers: Prazek, cfe-commits Differential Revision: https://reviews.llvm.org/D31534 llvm-svn: 299274
* [OpenCL] Do not generate "kernel_arg_type_qual" metadata for non-pointer argsEgor Churaev2017-03-311-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: "kernel_arg_type_qual" metadata should contain const/volatile/restrict tags only for pointer types to match the corresponding requirement of the OpenCL specification. OpenCL 2.0 spec 5.9.3 Kernel Object Queries: CL_KERNEL_ARG_TYPE_VOLATILE is returned if the argument is a pointer and the referenced type is declared with the volatile qualifier. [...] Similarly, CL_KERNEL_ARG_TYPE_CONST is returned if the argument is a pointer and the referenced type is declared with the restrict or const qualifier. [...] CL_KERNEL_ARG_TYPE_RESTRICT will be returned if the pointer type is marked restrict. Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: bader, yaxunl Differential Revision: https://reviews.llvm.org/D31321 llvm-svn: 299192
* [msan] Turn off lifetime markers even when use after scope checking is on.Benjamin Kramer2017-03-311-4/+4
| | | | | | | | | Since r299174 use after scope checking is on by default. Even though msan doesn't check for use after scope it gets confused by the lifetime markers emitted for it, making unit tests fail. This is covered by ninja check-msan. llvm-svn: 299191
* [ThinLTO] Set up lto::Config properly for codegen in ThinLTO backendsTeresa Johnson2017-03-311-125/+153
| | | | | | | | | | | | | | | | Summary: This involved refactoring out pieces of EmitAssemblyHelper::CreateTargetMachine for use in runThinLTOBackend. Subsumes D31114. Reviewers: mehdi_amini, pcc Subscribers: Prazek, cfe-commits Differential Revision: https://reviews.llvm.org/D31508 llvm-svn: 299152
* Clang changes for alloc_align attribute Erich Keane2017-03-302-0/+10
| | | | | | | | GCC has the alloc_align attribute, which is similar to assume_aligned, except the attribute's parameter is the index of the integer parameter that needs aligning to. Differential Revision: https://reviews.llvm.org/D29599 llvm-svn: 299117
* Spelling mistakes in comments. NFCI. (PR27635)Simon Pilgrim2017-03-308-9/+9
| | | | llvm-svn: 299083
* Move NumRegParameters Module Flag. NFCI.Nirav Dave2017-03-301-6/+5
| | | | llvm-svn: 299079
* [XRay] Add -fxray-{always,never}-instrument= flags to clangDean Michael Berris2017-03-303-3/+35
| | | | | | | | | | | | | | | | | | | | | | Summary: The -fxray-always-instrument= and -fxray-never-instrument= flags take filenames that are used to imbue the XRay instrumentation attributes using a whitelist mechanism (similar to the sanitizer special cases list). We use the same syntax and semantics as the sanitizer blacklists files in the implementation. As implemented, we respect the attributes that are already defined in the source file (i.e. those that have the [[clang::xray_{always,never}_instrument]] attributes) before applying the always/never instrument lists. Reviewers: rsmith, chandlerc Subscribers: jfb, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D30388 llvm-svn: 299041
OpenPOWER on IntegriCloud