summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* [ObjC] Emit a boxed expression as a compile-time constant if theAkira Hatanaka2019-03-082-3/+24
| | | | | | | | | | | | | | | | | | expression inside the parentheses is a valid UTF-8 string literal. Previously clang emitted an expression like @("abc") as a message send to stringWithUTF8String. This commit makes clang emit the boxed expression as a compile-time constant instead. This commit also has the effect of silencing the nullable-to-nonnull conversion warning clang started emitting after r317727, which originally motivated this commit (see https://oleb.net/2018/@keypath). rdar://problem/42684601 Differential Revision: https://reviews.llvm.org/D58729 llvm-svn: 355662
* Variable auto-init: split out small arraysJF Bastien2019-03-081-22/+38
| | | | | | | | | | | | | | | | | | Summary: Following up with r355181, initialize small arrays as well. LLVM stage2 shows a tiny size gain. <rdar://48523005> Reviewers: glider, pcc, kcc, rjmccall Subscribers: jkorous, dexonsmith, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58885 llvm-svn: 355660
* [OPENMP 5.0]Add initial support for 'allocate' directive.Alexey Bataev2019-03-075-1/+13
| | | | | | | Added parsing/sema analysis/serialization/deserialization support for 'allocate' directive. llvm-svn: 355614
* [PR40778] Preserve addr space in Derived to Base cast.Anastasia Stulova2019-03-071-1/+2
| | | | | | | | | The address space for the Base class pointer when up-casting from Derived should be taken from the Derived class pointer. Differential Revision: https://reviews.llvm.org/D53818 llvm-svn: 355606
* [CUDA][HIP][DebugInfo] Skip reference device functionMichael Liao2019-03-061-23/+29
| | | | | | | | | | | | | | | | Summary: - A device functions could be used as a non-type template parameter in a global/host function template. However, we should not try to retrieve that device function and reference it in the host-side debug info as it's only valid at device side. Subscribers: aprantl, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58992 llvm-svn: 355551
* AMDGPU: Fix the mapping of sub group sync scopeKonstantin Zhuravlyov2019-03-061-1/+1
| | | | | | | | Map memory_scope_sub_group to "wavefront" sync scope Differential Revision: https://reviews.llvm.org/D58847 llvm-svn: 355549
* Reland "[Remarks] Refactor remark diagnostic emission in a RemarkStreamer"Francis Visoiu Mistrih2019-03-061-2/+3
| | | | | | | | | | | | This allows us to store more info about where we're emitting the remarks without cluttering LLVMContext. This is needed for future support for the remark section. Differential Revision: https://reviews.llvm.org/D58996 Original llvm-svn: 355507 llvm-svn: 355514
* Revert "[Remarks] Refactor remark diagnostic emission in a RemarkStreamer"Francis Visoiu Mistrih2019-03-061-3/+2
| | | | | | | | This reverts commit 2e8c4997a2089f8228c843fd81b148d903472e02. Breaks bots. llvm-svn: 355511
* [Remarks] Refactor remark diagnostic emission in a RemarkStreamerFrancis Visoiu Mistrih2019-03-061-2/+3
| | | | | | | | | | This allows us to store more info about where we're emitting the remarks without cluttering LLVMContext. This is needed for future support for the remark section. Differential Revision: https://reviews.llvm.org/D58996 llvm-svn: 355507
* Inline asm constraints: allow ICE-like pointers for the "n" constraint (PR40890)Hans Wennborg2019-03-061-2/+9
| | | | | | | | | | | | Apparently GCC allows this, and there's code relying on it (see bug). The idea is to allow expression that would have been allowed if they were cast to int. So I based the code on how such a cast would be done (the CK_PointerToIntegral case in IntExprEvaluator::VisitCastExpr()). Differential Revision: https://reviews.llvm.org/D58821 llvm-svn: 355491
* [Fixed Point Arithmetic] Fixed Point and Integer ConversionsLeonard Chan2019-03-065-21/+62
| | | | | | | | | This patch includes the necessary code for converting between a fixed point type and integer. This also includes constant expression evaluation for conversions with these types. Differential Revision: https://reviews.llvm.org/D56900 llvm-svn: 355462
* [OPENMP]Target region: emit const firstprivates as globals with constantAlexey Bataev2019-03-055-9/+98
| | | | | | | | | | | | memory. If the variable with the constant non-scalar type is firstprivatized in the target region, the local copy is created with the data copying. Instead, we allocate the copy in the constant memory and avoid extra copying in the outlined target regions. This global copy is used in the target regions without loss of the performance. llvm-svn: 355418
* [PGO] Clang part of change for context-sensitive PGO (part1)Rong Xu2019-03-041-12/+65
| | | | | | | | | | Part 1 of CSPGO change in Clang. This includes changes in clang options and calls to llvm PassManager. Tests will be committed in part2. This change needs the PassManager change in llvm. Differential Revision: https://reviews.llvm.org/D54176 llvm-svn: 355331
* [PGO] Use the explicit parameter in ProfileSummary API. NFCRong Xu2019-03-011-1/+4
| | | | | | | Use the explicit parameter in setProfileSummary() and getSummary(). This is a follow-up of r355131. llvm-svn: 355209
* [Driver] Allow enum SanitizerOrdinal to represent more than 64 different ↵Pierre Gousseau2019-03-011-7/+4
| | | | | | | | | | | | | | | sanitizer checks, NFC. enum SanitizerOrdinal has reached maximum capacity, this change extends the capacity to 128 sanitizer checks. This can eventually allow us to add gcc 8's options "-fsanitize=pointer-substract" and "-fsanitize=pointer-compare". This is a recommit of r354873 but with a fix for unqualified lookup error in lldb cmake build bot. Fixes: https://llvm.org/PR39425 Differential Revision: https://reviews.llvm.org/D57914 llvm-svn: 355190
* CodeGen: Fix PR40605 by splitting constant struct initializersAlexander Potapenko2019-03-011-0/+30
| | | | | | | | | | | | | | When emitting initializers for local structures for code built with -ftrivial-auto-var-init, replace constant structures with sequences of stores. This appears to greatly help removing dead initialization stores to those locals that are later overwritten by other data. This also removes a lot of .rodata constants (see PR40605), replacing most of them with immediate values (for Linux kernel the .rodata size is reduced by ~1.9%) llvm-svn: 355181
* Fix file headers. NFCFangrui Song2019-03-011-1/+1
| | | | llvm-svn: 355176
* [CodeGen] Fix calling llvm.var.annotation outside of a basic block.Volodymyr Sapsai2019-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | When we have an annotated local variable after a function returns, we generate IR that fails verification with the error > Instruction referencing instruction not embedded in a basic block! And it means that bitcast referencing alloca doesn't have a parent basic block. Fix by checking if we are at an unreachable point and skip emitting annotations. This approach is similar to the way we emit variable initializer and debug info. rdar://problem/46200420 Reviewers: rjmccall Reviewed By: rjmccall Subscribers: aprantl, jkorous, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D58147 llvm-svn: 355166
* [CodeGen] Fix some broken IR generated by -fsanitize=unsigned-integer-overflowErik Pilkington2019-02-281-6/+6
| | | | | | | | | | | | | | I think the author of the function assumed that `GetInsertBlock()` wouldn't change from where `atomicPHI` was created, but this isn't true when `-fsanitize=unsigned-integer-overflow` is enabled (we generate an overflow/continuation label). Fix by keeping track of the block we want to return to to complete the cmpxchg loop. rdar://48406558 Differential revision: https://reviews.llvm.org/D58744 llvm-svn: 355054
* [OPENMP]Delay emission of the error for unsupported types.Alexey Bataev2019-02-271-0/+46
| | | | | | | If the type is unsupported on the device side, it still must be emitted, but we should emit errors for operations with such types. llvm-svn: 355027
* Avoid needlessly copying a block to the heap when a block literalAkira Hatanaka2019-02-271-1/+18
| | | | | | | | | | | | initializes a local auto variable or is assigned to a local auto variable that is declared in the scope that introduced the block literal. rdar://problem/13289333 https://reviews.llvm.org/D58514 llvm-svn: 355012
* [HIP] change kernel stub nameYaxun Liu2019-02-272-2/+12
| | | | | | | | | | Add .stub to kernel stub function name so that it is different from kernel name in device code. This is necessary to let debugger find correct symbol for kernel. Differential Revision: https://reviews.llvm.org/D58518 llvm-svn: 354948
* [MS] Don't emit coverage for deleting dtorsReid Kleckner2019-02-261-3/+3
| | | | | | | | | | | | | | | | | | | Summary: The MS C++ ABI has no constructor variants, but it has destructor variants, so we should move the deleting destructor variant check outside the check for "does the ABI have constructor variants". Fixes PR37561, so basic code coverage works on Windows with C++. Reviewers: vsk Subscribers: jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58691 llvm-svn: 354924
* [AMDGPU] Allow using integral non-type template parametersMichael Liao2019-02-261-4/+16
| | | | | | | | | | | | | | | | | | | Summary: - Allow using integral non-type template parameters in the following attributes __attribute__((amdgpu_flat_work_group_size(<min>, <max>))) __attribute__((amdgpu_waves_per_eu(<min>[, <max>]))) Reviewers: kzhuravl, yaxunl Subscribers: jvesely, wdng, nhaehnle, dstuttard, tpr, t-tye, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58623 llvm-svn: 354909
* revert r354873 as this breaks lldb builds.Pierre Gousseau2019-02-261-4/+7
| | | | llvm-svn: 354875
* [Driver] Allow enum SanitizerOrdinal to represent more than 64 different ↵Pierre Gousseau2019-02-261-7/+4
| | | | | | | | | | | | | sanitizer checks, NFC. enum SanitizerOrdinal has reached maximum capacity, this change extends the capacity to 128 sanitizer checks. This can eventually allow us to add gcc 8's options "-fsanitize=pointer-substract" and "-fsanitize=pointer-compare". Fixes: https://llvm.org/PR39425 Differential Revision: https://reviews.llvm.org/D57914 llvm-svn: 354873
* CodeGen: Explicitly initialize structure padding in the ↵Alexander Potapenko2019-02-261-11/+110
| | | | | | | | | | | | | | | -ftrivial-auto-var-init mode When generating initializers for local structures in the -ftrivial-auto-var-init mode, explicitly wipe the padding bytes with either 0x00 or 0xAA. This will allow us to automatically handle the padding when splitting the initialization stores (see https://reviews.llvm.org/D57898). Reviewed at https://reviews.llvm.org/D58188 llvm-svn: 354861
* [CGDebugInfo] Set NonTrivial DIFlag to a c++ record if it's not trivialAaron Smith2019-02-261-0/+2
| | | | | | This goes with https://reviews.llvm.org/D44406 llvm-svn: 354843
* [CodeGenObjC] Fix a nullptr dyn_castErik Pilkington2019-02-251-2/+3
| | | | | | | | | | ObjCMessageExpr::getInstanceReceiver returns nullptr if the receiver is 'super'. Make this check more strict, since we don't care about messages to super here. rdar://48247290 llvm-svn: 354826
* Fix accidentally used hard tabs. NFCKristina Brooks2019-02-241-1/+1
| | | | | | | Big sorry. This undoes the indentation mess I made in r354751. llvm-svn: 354752
* Wrap code for builtin_assume_aligned at 80 col.NFCKristina Brooks2019-02-241-1/+2
| | | | | | | Minor style fix to avoid going over 80 cols in handling of case for Builtin::BI__builtin_assume_aligned. NFC. llvm-svn: 354751
* Enable coroutines under -std=c++2a.Richard Smith2019-02-231-1/+1
| | | | llvm-svn: 354736
* CodeGen: use COMDAT for block copy/destroy helpersSaleem Abdulrasool2019-02-221-0/+4
| | | | | | | | | | | SVN r339438 added support to deduplicate the helpers by using a consistent naming scheme and using LinkOnceODR semantics. This works on ELF by means of weak linking semantics, and entirely does not work on PE/COFF where you end up with multiply defined strong symbols, which is a strong error on PE/COFF. Assign the functions a COMDAT group so that they can be uniqued by the linker. This fixes the use of blocks in CoreFoundation on Windows. llvm-svn: 354678
* revert r354615: [HIP] change kernel stub nameYaxun Liu2019-02-221-6/+0
| | | | | | | | It caused regressions. Differential Revision: https://reviews.llvm.org/D58518 llvm-svn: 354651
* [Fixed Point Arithmetic] Fixed Point ComparisonsLeonard Chan2019-02-211-12/+34
| | | | | | | | | This patch implements fixed point comparisons with other fixed point types and integers. This also provides constant expression evaluation for them. Differential Revision: https://reviews.llvm.org/D57219 llvm-svn: 354621
* [HIP] change kernel stub nameYaxun Liu2019-02-211-0/+6
| | | | | | | | | | Add .stub to kernel stub function name so that it is different from kernel name in device code. This is necessary to let debugger find correct symbol for kernel Differential Revision: https://reviews.llvm.org/D58518 llvm-svn: 354615
* [CodeGen] Fix string literal address space casting.Michael Liao2019-02-211-2/+4
| | | | | | | | | | | | | | | | Summary: - If a string literal is reused directly, need to add necessary address space casting if the target requires that. Reviewers: yaxunl Subscribers: jvesely, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58509 llvm-svn: 354610
* [OpenCL] Simplify LLVM IR generated for OpenCL blocksAndrew Savonichev2019-02-213-48/+63
| | | | | | | | | | | | | | | | | | | Summary: Emit direct call of block invoke functions when possible, i.e. in case the block is not passed as a function argument. Also doing some refactoring of `CodeGenFunction::EmitBlockCallExpr()` Reviewers: Anastasia, yaxunl, svenvh Reviewed By: Anastasia Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58388 llvm-svn: 354568
* [OPENMP][NVPTX]Use faster teams reduction algorithm.Alexey Bataev2019-02-202-114/+613
| | | | | | | A faster way to reduce the values in teams reductions was found, the codegen is updated to use this faster algorithm and new runtime functions. llvm-svn: 354479
* [NewPM] Add other sanitizers at O0Leonard Chan2019-02-201-0/+8
| | | | | | | | This allows for MSan and TSan to be used without optimizations required. Differential Revision: https://reviews.llvm.org/D58424 llvm-svn: 354431
* [OpenCL] Change type of block pointer for OpenCLAlexey Bader2019-02-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: For some reason OpenCL blocks in LLVM IR are represented as function pointers. These pointers do not point to any real function and never get called. Actually they point to some structure, which in turn contains pointer to the real block invoke function. This patch changes represntation of OpenCL blocks in LLVM IR from function pointers to pointers to `%struct.__block_literal_generic`. Such representation allows to avoid unnecessary bitcasts and simplifies further processing (e.g. translation to SPIR-V ) of the module for targets which do not support function pointers. Patch by: Alexey Sotkin. Reviewers: Anastasia, yaxunl, svenvh Reviewed By: Anastasia Subscribers: alexbatashev, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58277 llvm-svn: 354337
* Relax assertion to account for private framework modules, too.Adrian Prantl2019-02-151-2/+2
| | | | | | rdar://problem/48116069 llvm-svn: 354165
* Variable auto-init of blocks capturing self after init bugfixJF Bastien2019-02-151-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Blocks that capture themselves (and escape) after initialization currently codegen wrong because this: bool capturedByInit = Init && emission.IsEscapingByRef && isCapturedBy(D, Init); Address Loc = capturedByInit ? emission.Addr : emission.getObjectAddress(*this); Already adjusts Loc from thr alloca to a GEP. This code: if (emission.IsEscapingByRef) Loc = emitBlockByrefAddress(Loc, &D, /*follow=*/false); Was trying to do the same adjustment, and a GEP on a GEP (returning an int) triggers an assertion. <rdar://problem/47943027> Reviewers: ahatanak Subscribers: jkorous, dexonsmith, cfe-commits, rjmccall Tags: #clang Differential Revision: https://reviews.llvm.org/D58218 llvm-svn: 354147
* PR40642: Fix determination of whether the final statement of a statementRichard Smith2019-02-151-8/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | expression is a discarded-value expression. Summary: We used to get this wrong in three ways: 1) During parsing, an expression-statement followed by the }) ending a statement expression was always treated as producing the value of the statement expression. That's wrong for ({ if (1) expr; }) 2) During template instantiation, various kinds of statement (most statements not appearing directly in a compound-statement) were not treated as discarded-value expressions, resulting in missing volatile loads (etc). 3) In all contexts, an expression-statement with attributes was not treated as producing the value of the statement expression, eg ({ [[attr]] expr; }). Also fix incorrect enforcement of OpenMP rule that directives can "only be placed in the program at a position where ignoring or deleting the directive would result in a program with correct syntax". In particular, a label (be it goto, case, or default) should not affect whether directives are permitted. Reviewers: aaron.ballman, rjmccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57984 llvm-svn: 354090
* [CodeGenObjC] Emit [[X alloc] init] as objc_alloc_init(X) when availableErik Pilkington2019-02-143-0/+49
| | | | | | | | | | | This provides a code size win on the caller side, since the init message send is done in the runtime function. rdar://44987038 Differential revision: https://reviews.llvm.org/D57936 llvm-svn: 354056
* [CUDA][HIP] Use device side kernel and variable names when registering themYaxun Liu2019-02-143-17/+57
| | | | | | | | | | | | | | | | | | __hipRegisterFunction and __hipRegisterVar need to accept device side kernel and variable names so that HIP runtime can associate kernel stub functions in host code with kernel symbols in fat binaries, and associate shadow variables in host code with device variables in fat binaries. Currently, clang assumes kernel functions and device variables have the same name as the kernel stub functions and shadow variables. However, when host is compiled in windows with MSVC C++ ABI and device is compiled with Itanium C++ ABI (e.g. AMDGPU), kernels and device symbols in fat binary are mangled differently than host. This patch gets the device side kernel and variable name by mangling them in the mangle context of aux target. Differential Revision: https://reviews.llvm.org/D58163 llvm-svn: 354004
* Fix for asan botsLeonard Chan2019-02-141-9/+12
| | | | llvm-svn: 353999
* [NewPM] Second attempt at porting ASanLeonard Chan2019-02-131-3/+43
| | | | | | | | | | | | | | | | | | | | This is the second attempt to port ASan to new PM after D52739. This takes the initialization requried by ASan from the Module by moving it into a separate class with it's own analysis that the new PM ASan can use. Changes: - Split AddressSanitizer into 2 passes: 1 for the instrumentation on the function, and 1 for the pass itself which creates an instance of the first during it's run. The same is done for AddressSanitizerModule. - Add new PM AddressSanitizer and AddressSanitizerModule. - Add legacy and new PM analyses for reading data needed to initialize ASan with. - Removed DominatorTree dependency from ASan since it was unused. - Move GlobalsMetadata and ShadowMapping out of anonymous namespace since the new PM analysis holds these 2 classes and will need to expose them. Differential Revision: https://reviews.llvm.org/D56470 llvm-svn: 353985
* [WebAssembly] Bulk memory intrinsics and builtinsThomas Lively2019-02-131-0/+24
| | | | | | | | | | | | | | | | Summary: implements llvm intrinsics and clang intrinsics for memory.init and data.drop. Reviewers: aheejin Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57736 llvm-svn: 353983
* Re-enable the test disabled in r353836 and hopefully make it pass in gcc buildsNico Weber2019-02-131-3/+4
| | | | | | | | | Argument evaluation order is different between gcc and clang, so pull out the Builder calls to make the generated IR independent of the host compiler's argument evaluation order. Thanks to rnk for reminding me of this clang/gcc difference. llvm-svn: 353969
OpenPOWER on IntegriCloud