summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGStmt.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [OpenMP] Initial implementation of parse and sema for composite pragma ↵Carlo Bertolli2016-06-241-0/+4
| | | | | | | | | | | | | | | 'distribute parallel for' http://reviews.llvm.org/D21564 This patch is an initial implementation for #distribute parallel for. The main differences that affect other pragmas are: The implementation of 'distribute parallel for' requires blocking of the associated loop, where blocks are "distributed" to different teams and iterations within each block are scheduled to parallel threads within each team. To implement blocking, sema creates two additional worksharing directive fields that are used to pass the team assigned block lower and upper bounds through the outlined function resulting from 'parallel'. In this way, scheduling for 'for' to threads can use those bounds. As a consequence of blocking, the stride of 'distribute' is not 1 but it is equal to the blocking size. This is returned by the runtime and sema prepares a DistIncrExpr variable to hold that value. As a consequence of blocking, the global upper bound (EnsureUpperBound) expression of the 'for' is not the original loop upper bound (e.g. in for(i = 0 ; i < N; i++) this is 'N') but it is the team-assigned block upper bound. Sema creates a new expression holding the calculation of the actual upper bound for 'for' as UB = min(UB, PrevUB), where UB is the loop upper bound, and PrevUB is the team-assigned block upper bound. llvm-svn: 273705
* Implement p0292r2 (constexpr if), a likely C++1z feature.Richard Smith2016-06-231-2/+3
| | | | llvm-svn: 273602
* Revert accidential "[MSVC] Late parsing of in-class defined member functions ↵Alexey Bataev2016-06-151-1/+0
| | | | | | | | in template" This reverts commit 0253605771b8bd9d414aba74fe2742c730d6fd1a. llvm-svn: 272776
* [MSVC] Late parsing of in-class defined member functions in templateAlexey Bataev2016-06-151-0/+1
| | | | | | | | | | | | | | | | | | | classes. MSVC actively uses unqualified lookup in dependent bases, lookup at the instantiation point (non-dependent names may be resolved on things declared later) etc. and all this stuff is the main cause of incompatibility between clang and MSVC. Clang tries to emulate MSVC behavior but it may fail in many cases. clang could store lexed tokens for member functions definitions within ClassTemplateDecl for later parsing during template instantiation. It will allow resolving many possible issues with lookup in dependent base classes and removing many already existing MSVC-specific hacks/workarounds from the clang code. llvm-svn: 272774
* [CUDA] Conservatively mark inline asm as convergent.Justin Lebar2016-05-311-0/+8
| | | | | | | | | | | | | | Summary: This is particularly important because a some convergent CUDA intrinsics (e.g. __shfl_down) are implemented in terms of inline asm. Reviewers: tra Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20836 llvm-svn: 271336
* [OpenMP] Parsing and sema support for target update directiveSamuel Antao2016-05-261-0/+3
| | | | | | | | | | | | | | | Summary: This patch is to add parsing and sema support for `target update` directive. Support for the `to` and `from` clauses will be added by a different patch. This patch also adds support for other clauses that are already implemented upstream and apply to `target update`, e.g. `device` and `if`. This patch is based on the original post by Kelvin Li. Reviewers: hfinkel, carlo.bertolli, kkwli0, arpith-jacob, ABataev Subscribers: caomhin, cfe-commits Differential Revision: http://reviews.llvm.org/D15944 llvm-svn: 270878
* Add a loop's debug location to its llvm.loop metadataHal Finkel2016-05-251-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Getting accurate locations for loops is important, because those locations are used by the frontend to generate optimization remarks. Currently, optimization remarks for loops often appear on the wrong line, often the first line of the loop body instead of the loop itself. This is confusing because that line might itself be another loop, or might be somewhere else completely if the body was an inlined function call. This happens because of the way we find the loop's starting location. First, we look for a preheader, and if we find one, and its terminator has a debug location, then we use that. Otherwise, we look for a location on an instruction in the loop header. The fallback heuristic is not bad, but will almost always find the beginning of the body, and not the loop statement itself. The preheader location search often fails because there's often not a preheader, and even when there is a preheader, depending on how it was formed, it sometimes carries the location of some preceeding code. I don't see any good theoretical way to fix this problem. On the other hand, this seems like a straightforward solution: Put the debug location in the loop's llvm.loop metadata. When emitting debug information, this commit causes us to add the debug location as an operand to each loop's llvm.loop metadata. Thus, we now generate this metadata for all loops (not just loops with optimization hints) when we're otherwise generating debug information. The remark test case changes depend on the companion LLVM commit r270771. llvm-svn: 270772
* reduce indentation; NFCISanjay Patel2016-04-191-10/+7
| | | | llvm-svn: 266765
* P0184R0: Allow types of 'begin' and 'end' expressions in range-based for ↵Richard Smith2016-03-201-1/+2
| | | | | | loops to differ. llvm-svn: 263895
* Preserve ExtParameterInfos into CGFunctionInfo.John McCall2016-03-111-2/+1
| | | | | | | | | As part of this, make the function-arrangement interfaces a little simpler and more semantic. NFC. llvm-svn: 263191
* [PGO] cc1 option name change for profile instrumentationRong Xu2016-02-041-2/+2
| | | | | | | | | | | | This patch changes cc1 option -fprofile-instr-generate to an enum option -fprofile-instrument={clang|none}. It also changes cc1 options -fprofile-instr-generate= to -fprofile-instrument-path=. The driver level option -fprofile-instr-generate and -fprofile-instr-generate= remain intact. This change will pave the way to integrate new PGO instrumentation in IR level. Review: http://reviews.llvm.org/D16730 llvm-svn: 259811
* [OpenMP] Parsing + sema for target parallel for directive.Arpith Chacko Jacob2016-02-031-0/+3
| | | | | | | | | | | Summary: This patch adds parsing + sema for the target parallel for directive along with testcases. Reviewers: ABataev Differential Revision: http://reviews.llvm.org/D16759 llvm-svn: 259654
* Fix strange indent.Nico Weber2016-01-281-2/+2
| | | | llvm-svn: 259063
* [OpenMP] Parsing + sema for target parallel directive.Arpith Chacko Jacob2016-01-261-0/+3
| | | | | | | | | | | | | Summary: This patch adds parsing + sema for the target parallel directive and its clauses along with testcases. Reviewers: ABataev Differential Revision: http://reviews.llvm.org/D16553 Rebased to current trunk and updated test cases. llvm-svn: 258832
* [OpenMP] Parsing + sema for "target exit data" directive.Samuel Antao2016-01-191-0/+3
| | | | | | Patch by Arpith Jacob. Thanks! llvm-svn: 258177
* [OpenMP] Parsing + sema for "target enter data" directive.Samuel Antao2016-01-191-0/+3
| | | | | | Patch by Arpith Jacob. Thanks! llvm-svn: 258165
* [Microsoft][C++] Clang doesn't support a use of "this" pointer inside inline asmMichael Zuckerman2015-12-151-1/+2
| | | | | | | | | | | | | | | | | | | | | Clang doesn’t support a use of “this” pointer inside inline asm. When I tried to compile a class or a struct (see example) with an inline asm that contains "this" pointer. Clang returns with an error. This patch fixes that. error: expected unqualified-id For example: ''' struct A { void f() { __asm mov eax, this // error: expected unqualified-id } }; ''' Differential Revision: http://reviews.llvm.org/D15115 llvm-svn: 255645
* Add parse and sema of OpenMP distribute directive with all clauses except ↵Carlo Bertolli2015-12-141-0/+3
| | | | | | dist_schedule llvm-svn: 255498
* Mark MS inline ASM 'nodplicate' it it has labels (PR23715)Hans Wennborg2015-12-101-0/+9
| | | | | | | | Duplicating it can lead to labels being defined twice. Differential revision: http://reviews.llvm.org/D15399 llvm-svn: 255201
* PR25416: Improve performance of processing inline assembly consisting of manyRichard Smith2015-12-101-3/+5
| | | | | | | | | | implicitly-concatenated string literals. When looking for the start of a token in the inline assembly, start from the end of the previous token, not the start of the entire string. Patch by Yunlian Jiang! llvm-svn: 255198
* Revert r255001, "Add parse and sema for OpenMP distribute directive and all ↵NAKAMURA Takumi2015-12-091-3/+0
| | | | | | | | its clauses excluding dist_schedule." It causes memory leak. Some tests in test/OpenMP would fail. llvm-svn: 255094
* Add parse and sema for OpenMP distribute directive and all its clauses ↵Carlo Bertolli2015-12-081-0/+3
| | | | | | excluding dist_schedule. llvm-svn: 255001
* [PGO] Instrument only base constructors and destructors.Serge Pavlov2015-12-061-1/+1
| | | | | | | | | | | | | | | | Constructors and destructors may be represented by several functions in IR. Only base structors correspond to source code, others are small pieces of code and eventually call the base variant. In this case instrumentation of non-base structors has little sense, this fix remove it. Now profile data of a declaration corresponds to exactly one function in IR, it agrees with the current logic of the profile data loading. This change fixes PR24996. Differential Revision: http://reviews.llvm.org/D15158 llvm-svn: 254876
* [OPENMP 4.5] Parsing/sema support for 'omp taskloop simd' directive.Alexey Bataev2015-12-031-0/+3
| | | | | | OpenMP 4.5 adds directive 'taskloop simd'. Patch adds parsing/sema analysis for 'taskloop simd' directive and its clauses. llvm-svn: 254597
* [OPENMP 4.5] Parsing/sema analysis for 'taskloop' directive.Alexey Bataev2015-12-011-0/+3
| | | | | | Adds initial parsing and semantic analysis for 'taskloop' directive. llvm-svn: 254367
* CodeGen: Remove implicit ilist iterator conversions, NFCDuncan P. N. Exon Smith2015-11-061-3/+4
| | | | | | | Make ilist iterator conversions explicit in clangCodeGen. Eventually I'll remove them everywhere. llvm-svn: 252358
* [coroutines] Creation of promise object, lookup of operator co_await, buildingRichard Smith2015-10-271-0/+4
| | | | | | of await_* calls, and AST representation for same. llvm-svn: 251387
* Use ArrayRef and MutableArrayRef instead of a pointer and size. NFCCraig Topper2015-10-211-5/+2
| | | | llvm-svn: 250876
* convert builtin_unpredictable on a switch into metadata for LLVMSanjay Patel2015-09-091-0/+19
| | | | llvm-svn: 247203
* Compute and preserve alignment more faithfully in IR-generation.John McCall2015-09-081-26/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Use CGLoopInfo to emit metadata for loop hint pragmas.Tyler Nowicki2015-07-271-114/+8
| | | | | | | | When ‘#pragma clang loop vectorize(assume_safety)’ was specified on a loop other loop hints were lost. The problem is that CGLoopInfo attaches metadata differently than EmitCondBrHints in CGStmt. For do-loops CGLoopInfo attaches metadata to the br in the body block and for while and for loops, the inc block. EmitCondBrHints on the other hand always attaches data to the br in the cond block. When specifying assume_safety CGLoopInfo emits an empty llvm.loop metadata shadowing the metadata in the cond block. Loop transformations like rotate and unswitch would then eliminate the cond block and its non-empty metadata. This patch unifies both approaches for adding metadata and modifies the existing safety tests to include non-assume_safety loop hints. llvm-svn: 243315
* Commit for http://reviews.llvm.org/D10765Michael Wong2015-07-211-0/+3
| | | | | | | for OpenMP 4 target data directive parsing and sema. This commit is on behalf of Kelvin Li. llvm-svn: 242785
* Fix alignment issues in Clang.James Y Knight2015-07-171-2/+2
| | | | | | | | | | | | | | | | | Some const-correctness changes snuck in here too, since they were in the area of code I was modifying. This seems to make Clang actually work without Bus Error on 32bit-sparc. Follow-up patches will factor out a trailing-object helper class, to make classes using the idiom of appending objects to other objects easier to understand, and to ensure (with static_assert) that required alignment guarantees continue to hold. Differential Revision: http://reviews.llvm.org/D10272 llvm-svn: 242554
* [inlineasm] Attach readonly and readnone to inline-asm instructions.Akira Hatanaka2015-07-101-1/+25
| | | | | | | | | | | | | | Previously, clang/llvm treated inline-asm instructions conservatively, choosing not to eliminate the instructions or hoisting them out of a loop even when it was safe to do so. This commit makes changes to attach a readonly or readnone attribute to an inline-asm instruction, which enables passes such as LICM and EarlyCSE to move or optimize away the instruction. rdar://problem/11358192 Differential Revision: http://reviews.llvm.org/D10546 llvm-svn: 241930
* [OPENMP 4.0] Initial support for 'omp cancel' construct.Alexey Bataev2015-07-021-0/+3
| | | | | | Implemented parsing/sema analysis + (de)serialization. llvm-svn: 241253
* [OPENMP 4.0] Initial support for 'omp cancellation point' construct.Alexey Bataev2015-07-011-0/+3
| | | | | | Add parsing and sema analysis for 'omp cancellation point' directive. llvm-svn: 241145
* Proper changing/restoring for CapturedStmtInfo, NFC.Alexey Bataev2015-06-241-1/+1
| | | | | | Added special RAII class for proper values changing/restoring in CodeGenFunction::CapturedStmtInfo. llvm-svn: 240517
* [OPENMP] Support for '#pragma omp taskgroup' directive.Alexey Bataev2015-06-181-0/+3
| | | | | | | | | | | | | Added parsing, sema analysis and codegen for '#pragma omp taskgroup' directive (OpenMP 4.0). The code for directive is generated the following way: #pragma omp taskgroup <body> void __kmpc_taskgroup(<loc>, thread_id); <body> void __kmpc_end_taskgroup(<loc>, thread_id); llvm-svn: 240011
* [CodeGen] Don't evaluate immediate inlineasm arguments using isICE().Ahmed Bougacha2015-06-131-1/+1
| | | | | | | | | | | Instead, just EvaluateAsInt(). Follow-up to r239549: rsmith points out that isICE() is expensive; seems like it's not the right concept anyway, as it fails on `static const' in C, and will actually trigger the assert below on: test/Sema/inline-asm-validate-x86.c llvm-svn: 239651
* Add assume_safety option for pragma loop vectorize and interleave.Tyler Nowicki2015-06-111-4/+4
| | | | | | | | Specifying #pragma clang loop vectorize(assume_safety) on a loop adds the mem.parallel_loop_access metadata to each load/store operation in the loop. This metadata tells loop access analysis (LAA) to skip memory dependency checking. llvm-svn: 239572
* [CodeGen] Emit Constants for immediate inlineasm arguments.Ahmed Bougacha2015-06-111-0/+10
| | | | | | | | | | | | | | | | | For inline assembly immediate constraints, we currently always use EmitScalarExpr, instead of directly emitting the constant. When the overflow sanitizer is enabled, this generates overflow intrinsics instead of constants. Instead, emit a constant for constraints that either require an immediate (e.g. 'I' on X86), or only accepts constants (immediate or symbolic; i.e., don't accept registers or memory). Fixes PR19763. Differential Revision: http://reviews.llvm.org/D10255 llvm-svn: 239549
* InstrProf: Cede ownership of createProfileWeights to CGFJustin Bogner2015-05-021-8/+8
| | | | | | | | The fact that PGO has a say in how these branch weights are determined isn't interesting to most of CodeGen, so it makes more sense for this API to be accessible via CodeGenFunction rather than CodeGenPGO. llvm-svn: 236380
* InstrProf: Stop using RegionCounter outside of CodeGenPGO (NFC)Justin Bogner2015-04-231-48/+34
| | | | | | | | | The RegionCounter type does a lot of legwork, but most of it is only meaningful within the implementation of CodeGenPGO. The uses elsewhere in CodeGen generally just want to increment or read counters, so do that directly. llvm-svn: 235664
* Reland r234613 (and follow-ups 234614, 234616, 234618)Reid Kleckner2015-04-141-0/+6
| | | | | | | The frameescape intrinsic cannot be inlined, so I fixed the inliner in r234937. This should address PR23216. llvm-svn: 234942
* Revert r234613 (and follow-ups 234614, 234616, 234618), it caused PR23216.Nico Weber2015-04-131-6/+0
| | | | llvm-svn: 234789
* Revert r234786, it contained a bunch of stuff I did not mean to commit.Nico Weber2015-04-131-0/+6
| | | | llvm-svn: 234787
* Revert r234613 (and follow-ups 234614, 234616, 234618), it caused PR23216.Nico Weber2015-04-131-6/+0
| | | | llvm-svn: 234786
* [SEH] Re-land r234532, but use internal linkage for all SEH helpersReid Kleckner2015-04-101-0/+6
| | | | | | | | | | Even though these symbols are in a comdat group, the Microsoft linker really wants them to have internal linkage. I'm planning to tweak the mangling in a follow-up change. This is a straight revert with a 1-line fix. llvm-svn: 234613
* Revert r234532 for a bit, it very likely caused http://crbug.com/475768Nico Weber2015-04-101-6/+0
| | | | llvm-svn: 234563
* [SEH] Outline finally blocks using the new variable capture supportReid Kleckner2015-04-091-0/+6
| | | | | | | | | | | | | | | WinEHPrepare was going to have to pattern match the control flow merge and split that the old lowering used, and that wasn't really feasible. Now we can teach WinEHPrepare to pattern match this, which is much simpler: %fp = call i8* @llvm.frameaddress(i32 0) call void @func(iN [01], i8* %fp) This prototype happens to match the prototype used by the Win64 SEH personality function, so this is really simple. llvm-svn: 234532
OpenPOWER on IntegriCloud