summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGStmt.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Change PGO instrumentation to compute counts in a separate AST traversal.Bob Wilson2014-02-171-104/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we made one traversal of the AST prior to codegen to assign counters to the ASTs and then propagated the count values during codegen. This patch now adds a separate AST traversal prior to codegen for the -fprofile-instr-use option to propagate the count values. The counts are then saved in a map from which they can be retrieved during codegen. This new approach has several advantages: 1. It gets rid of a lot of extra PGO-related code that had previously been added to codegen. 2. It fixes a serious bug. My original implementation (which was mailed to the list but never committed) used 3 counters for every loop. Justin improved it to move 2 of those counters into the less-frequently executed breaks and continues, but that turned out to produce wrong count values in some cases. The solution requires visiting a loop body before the condition so that the count for the condition properly includes the break and continue counts. Changing codegen to visit a loop body first would be a fairly invasive change, but with a separate AST traversal, it is easy to control the order of traversal. I've added a testcase (provided by Justin) to make sure this works correctly. 3. It improves the instrumentation overhead, reducing the number of counters for a loop from 3 to 1. We no longer need dedicated counters for breaks and continues, since we can just use the propagated count values when visiting breaks and continues. To make this work, I needed to make a change to the way we count case statements, going back to my original approach of not including the fall-through in the counter values. This was necessary because there isn't always an AST node that can be used to record the fall-through count. Now case statements are handled the same as default statements, with the fall-through paths branching over the counter increments. While I was at it, I also went back to using this approach for do-loops -- omitting the fall-through count into the loop body simplifies some of the calculations and make them behave the same as other loops. Whenever we start using this instrumentation for coverage, we'll need to add the fall-through counts into the counter values. llvm-svn: 201528
* Some nitpicky comment fixes for "i.e." and "e.g." abbreviations.Bob Wilson2014-02-171-1/+1
| | | | llvm-svn: 201527
* [ms-cxxabi] Use x86_cdeclmethodcc for __cdecl methods on win32Reid Kleckner2014-01-311-2/+2
| | | | | | | | | | | | | | | | | | | This fixes PR15768, where the sret parameter and the 'this' parameter are in the wrong order. Instance methods compiled by MSVC never return records in registers, they always return indirectly through an sret pointer. That sret pointer always comes after the 'this' parameter, for both __cdecl and __thiscall methods. Unfortunately, the same is true for other calling conventions, so we'll have to change the overall approach here relatively soon. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D2664 llvm-svn: 200587
* Fix to PR8880 (clang dies processing a for loop)Serge Pavlov2014-01-231-12/+12
| | | | | | | | | | | | | | | | | | | | | | | Due to statement expressions supported as GCC extension, it is possible to put 'break' or 'continue' into a loop/switch statement but outside its body, for example: for ( ; ({ if (first) { first = 0; continue; } 0; }); ) This code is rejected by GCC if compiled in C mode but is accepted in C++ code. GCC bug 44715 tracks this discrepancy. Clang used code generation that differs from GCC in both modes: only statement of the third expression of 'for' behaves as if it was inside loop body. This change makes code generation more close to GCC, considering 'break' or 'continue' statement in condition and increment expressions of a loop as it was inside the loop body. It also adds error for the cases when 'break'/'continue' appear outside loop due to this syntax. If code generation differ from GCC, warning is issued. Differential Revision: http://llvm-reviews.chandlerc.com/D2518 llvm-svn: 199897
* Revert "CodeGen: Simplify CodeGenFunction::EmitCaseStmt"Justin Bogner2014-01-211-0/+24
| | | | | | | | | I misunderstood the discussion on this. The complexity here is justified by the malloc overhead it saves. This reverts commit r199302. llvm-svn: 199700
* CodeGen: Simplify CodeGenFunction::EmitCaseStmtJustin Bogner2014-01-151-24/+0
| | | | | | | | | | | | | Way back in r129652 we tried to avoid emitting an empty block at -O0 for switch cases that did nothing but break. This led to a poor debugging experience as reported in PR9796, so we disabled the optimization for -O0 but left it in for higher optimization levels in r154420. Since the whole point of this was to improve -O0, it's silly to keep the complexity at all. llvm-svn: 199302
* CodeGen: Clarify a comment about PGO in case statement rangesJustin Bogner2014-01-131-3/+4
| | | | llvm-svn: 199140
* CodeGen: Rename adjustFallThroughCount -> adjustForControlFlowJustin Bogner2014-01-131-6/+6
| | | | | | | | adjustFallThroughCount isn't a good name, and the documentation was even worse. This commit attempts to clarify what it's for and when to use it. llvm-svn: 199139
* CodeGen: Introduce CodeGenPGO::setCurrentRegionUnreachableJustin Bogner2014-01-131-8/+8
| | | | | | | | There are a number of places where we do PGO.setCurrentRegionCount(0) directly after an unconditional branch. Give this operation a name so that it's clearer why we're doing this. llvm-svn: 199138
* CodeGen: Remove a superfluous setCurrentRegionCountJustin Bogner2014-01-131-1/+0
| | | | | | | | This call looks like it was an artifact of an earlier change, and doesn't actually make sense. We begin a new region immediately anyway, so it was mostly harmless. llvm-svn: 199137
* CodeGen: Remove some unnecessary bracesJustin Bogner2014-01-131-2/+1
| | | | llvm-svn: 199136
* PR12208: Under -fno-elide-constructors, don't forget to actually copy an NRVORichard Smith2014-01-111-1/+2
| | | | | | | variable to the return slot. Patch by David Wiberg, with test case alterations by me. llvm-svn: 198991
* Revert "Debug info: Ensure that the last stop point in a function is still ↵Adrian Prantl2014-01-071-1/+1
| | | | | | | | within" This reverts commit r198461. llvm-svn: 198714
* Revert "Debug info: Implement a cleaner version of r198461. For symmetry with"Adrian Prantl2014-01-071-1/+1
| | | | | | This reverts commit 198699 so we can get a cleaner patch. llvm-svn: 198713
* Debug info: Implement a cleaner version of r198461. For symmetry withAdrian Prantl2014-01-071-1/+1
| | | | | | | | | C and C++ don't emit an extra lexical scope for the compound statement that is the body of an Objective-C method. rdar://problem/15010825 llvm-svn: 198699
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-071-1/+1
| | | | | | | encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. llvm-svn: 198686
* CodeGen: Initial instrumentation based PGO implementationJustin Bogner2014-01-061-28/+199
| | | | llvm-svn: 198640
* Debug info: Ensure that the last stop point in a function is still withinAdrian Prantl2014-01-031-1/+1
| | | | | | | | | the lexical block formed by the compound statement that is the function body. rdar://problem/15010825 llvm-svn: 198461
* Correct hyphenations in comments and assert messagesAlp Toker2013-12-051-1/+1
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities in nearby lines. llvm-svn: 196466
* Revert r193994 and part of r193995Justin Bogner2013-11-221-2/+4
| | | | | | | | | | | | | Not long ago I made the CodeGen of for loops simplify the condition at -O0 in the same way we do for if and conditionals. Unfortunately this ties how loops and simple conditions work together too tightly, which makes features such as instrumentation based PGO awkward. Ultimately, we should find a more general way to simplify the logic in a given condition, but for now we'll just avoid using EmitBranchOnBool for loops, like we already do for while and do loops. llvm-svn: 195438
* CodeGen: WhitespaceJustin Bogner2013-11-221-3/+3
| | | | llvm-svn: 195437
* CodeGen: Use EmitBranchOnBool when generating For and CXXForRangeJustin Bogner2013-11-041-5/+2
| | | | | | | | | | | | | A while ago EmitForStmt was changed to explicitly evaluate the condition expression and create a branch instead of using EmitBranchOnBool, so that the condition expression could be used for some cleanup logic. The cleanup stuff has since been reorganized, and this is no longer necessary. In EmitCXXForRange, the evaluated condition was never used for anything else. The logic was presumably modeled on EmitForStmt. llvm-svn: 193994
* CodeGen: Move an initialization away from an unrelated commentJustin Bogner2013-11-041-1/+1
| | | | | | | | An initialization somehow found its way in between a comment and the block of code the comment is about. Moving the initialization makes this less confusing. llvm-svn: 193993
* Thread a SourceLocation into the EmitCheck for "load_invalid_value". This occursNick Lewycky2013-10-021-8/+11
| | | | | | when scalars are loaded / undergo lvalue-to-rvalue conversion. llvm-svn: 191808
* Emit an error when attempting to generate IR for SEH __tryReid Kleckner2013-09-161-1/+2
| | | | | | | Currently we silently omit the code in the try and finally bodies, which is pretty bad. This way we fail loudly. llvm-svn: 190809
* OpenMP: Data-sharing attributes analysis and clause 'shared' (fixed test ↵Alexey Bataev2013-09-061-2/+4
| | | | | | threadprivate_messages.cpp) llvm-svn: 190183
* Revert "OpenMP: Data-sharing attributes analysis and clause 'shared'"Rafael Espindola2013-09-031-4/+2
| | | | | | | | This reverts commit r189795. threadprivate_messages.cpp is faling on windows. llvm-svn: 189811
* OpenMP: Data-sharing attributes analysis and clause 'shared'Alexey Bataev2013-09-031-2/+4
| | | | llvm-svn: 189795
* Simplify/clean up debug info suppression in CodeGenFunctionDavid Blaikie2013-08-261-3/+0
| | | | | | | | | | CodeGenFunction is run on only one function - a new object is made for each new function. I would add an assertion/flag to this effect, but there's an exception: ObjC properties involve emitting helper functions that are all emitted by the same CodeGenFunction object, so such a check is not possible/correct. llvm-svn: 189277
* OpenMP: basic support for #pragma omp parallelAlexey Bataev2013-07-191-0/+1
| | | | llvm-svn: 186647
* Use a LexicalScope here since it is one and it will encapsulateEric Christopher2013-07-101-12/+2
| | | | | | the two sets of debug scope and cleanup scope. llvm-svn: 186030
* Remove an ugly hack that was meant to eliminate the breakpoint ambiguityAdrian Prantl2013-06-181-4/+1
| | | | | | | | | | | | | | between a block assignment and the entry of the block function. In reality this wouldn't work anyway because blocks are predominantly created on-the-fly inside of an ObjC method invocation. The proper fix for the ambiguity is to use -gcolumn-info to differentiate the breakpoints. This is expected to break some block-related darwin-gdb tests. rdar://problem/14039866 llvm-svn: 184157
* Simplify: we don't need any special-case lifetime extension when initializingRichard Smith2013-06-121-1/+1
| | | | | | | declarations of reference type; they're handled by the general case handling of MaterializeTemporaryExpr. llvm-svn: 183875
* Make sure we don't emit invalid IR for StmtExprs with complex cleanups.Eli Friedman2013-06-101-10/+21
| | | | | | Fixes <rdar://problem/14074868>. llvm-svn: 183699
* Debug info: An if condition now creates a lexical scope of its own.Adrian Prantl2013-06-081-0/+10
| | | | | | | | | Two variables with the same name declared in two if conditions in the same scope are no longer coalesced into one. rdar://problem/14024005 llvm-svn: 183597
* Diagnose malformed x86 inline asm using 'y' constraint.Tim Northover2013-06-071-3/+12
| | | | | | | | X86's 'y' inline assembly constraint represents an MMX register, this change prevents Clang from hitting an assertion when passed an incompatible type to deal with. llvm-svn: 183467
* CodeGen for CapturedStmtsBen Langmuir2013-05-091-3/+92
| | | | | | | | | | | | | | | | | EmitCapturedStmt creates a captured struct containing all of the captured variables, and then emits a call to the outlined function. This is similar in principle to EmitBlockLiteral. GenerateCapturedFunction actually produces the outlined function. It is based on GenerateBlockFunction, but is much simpler. The function type is determined by the parameters that are in the CapturedDecl. Some changes have been added to this patch that were reviewed as part of the serialization patch and moving the parameters to the captured decl. Differential Revision: http://llvm-reviews.chandlerc.com/D640 llvm-svn: 181536
* The style guide prefers preincrement expressions :-)Adrian Prantl2013-05-071-2/+2
| | | | llvm-svn: 181373
* remove commented out code.Adrian Prantl2013-05-071-2/+1
| | | | llvm-svn: 181372
* Reapply r180982 with repaired logic and an additional testcase.Adrian Prantl2013-05-031-3/+4
| | | | | | | | | | | | | | Un-break the gdb buildbot. - Use the debug location of the return expression for the cleanup code if the return expression is trivially evaluatable, regardless of the number of stop points in the function. - Ensure that any EH code in the cleanup still gets the line number of the closing } of the lexical scope. - Added a testcase with EH in the cleanup. rdar://problem/13442648 llvm-svn: 181056
* Revert "Attempt to un-break the gdb buildbot."Adrian Prantl2013-05-031-4/+3
| | | | | | This reverts commit 180982. llvm-svn: 180990
* Attempt to un-break the gdb buildbot.Adrian Prantl2013-05-031-3/+4
| | | | | | | | | | | | | - Use the debug location of the return expression for the cleanup code if the return expression is trivially evaluatable, regardless of the number of stop points in the function. - Ensure that any EH code in the cleanup still gets the line number of the closing } of the lexical scope. - Added a testcase with EH in the cleanup. rdar://problem/13442648 llvm-svn: 180982
* Move parsing of identifiers in MS-style inline assembly intoJohn McCall2013-05-031-4/+8
| | | | | | | | | | | | | | | | | | | | | the actual parser and support arbitrary id-expressions. We're actually basically set up to do arbitrary expressions here if we wanted to. Assembly operands permit things like A::x to be written regardless of language mode, which forces us to embellish the evaluation context logic somewhat. The logic here under template instantiation is incorrect; we need to preserve the fact that an expression was unevaluated. Of course, template instantiation in general is fishy here because we have no way of delaying semantic analysis in the MC parser. It's all just fishy. I've also fixed the serialization of MS asm statements. This commit depends on an LLVM commit. llvm-svn: 180976
* Ensure that the line table for functions with cleanups is sequential.Adrian Prantl2013-05-021-0/+6
| | | | | | | | | | | | | | | | If there is cleanup code, the cleanup code gets the debug location of the closing '}'. The subsequent ret IR-instruction does not get a debug location. The return _expression_ will get the debug location of the return statement. If the function contains only a single, simple return statement, the cleanup code may become the first breakpoint in the function. In this case we set the debug location for the cleanup code to the location of the return statement. rdar://problem/13442648 llvm-svn: 180932
* Standardize accesses to the TargetInfo in IR-gen.John McCall2013-04-161-10/+12
| | | | | | Patch by Stephen Lin! llvm-svn: 179638
* Implement CapturedStmt ASTTareq A. Siraj2013-04-161-1/+7
| | | | | | | | | | | | | | | CapturedStmt can be used to implement generic function outlining as described in http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-January/027540.html. CapturedStmt is not exposed to the C api. Serialization and template support are pending. Author: Wei Pan <wei.pan@intel.com> Differential Revision: http://llvm-reviews.chandlerc.com/D370 llvm-svn: 179615
* Remove useGlobalsForAutomaticVariables.Rafael Espindola2013-03-261-2/+1
| | | | | | It is unused since pic support went away. llvm-svn: 178055
* Make clang to mark static stack allocations with lifetime markers to enable ↵Nadav Rotem2013-03-231-4/+30
| | | | | | | | | a more aggressive stack coloring. Patch by John McCall with help by Shuxin Yang. rdar://13115369 llvm-svn: 177819
* Change hasAggregateLLVMType, which conflates complex andJohn McCall2013-03-071-13/+25
| | | | | | | | | | | | | | | aggregate types in a profoundly wrong way that has to be worked around in every call site, to getEvaluationKind, which classifies and distinguishes between all of these cases. Also, normalize the API for loading and storing complexes. I'm working on a larger patch and wanted to pull these changes out, but it would have be annoying to detangle them from each other. llvm-svn: 176656
* LLVM API changes.Peter Collingbourne2013-03-021-2/+1
| | | | llvm-svn: 176398
OpenPOWER on IntegriCloud