summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGStmt.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add IsFinished arg to EmitBlock.Daniel Dunbar2008-11-131-1/+7
| | | | | | | | | | - Indicates that caller is done with the block and it can be dropped if it has no predecessors. Useful for callers who need to make landing pads but which may not be reached. No functionality change. llvm-svn: 59207
* For if blocks with no else, name the join block ifend instead of theDaniel Dunbar2008-11-131-6/+5
| | | | | | | | more confusing ifelse. Use dotted names for if blocks (if.then vs ifthen). llvm-svn: 59201
* IRgen improvements on unreachable code:Daniel Dunbar2008-11-121-36/+62
| | | | | | | | | | | | | | | | | | | | | | | - Split out "simple" statements which can easily handle IR generation when there is no insert point. These are generally statements which start by emitting a new block or are only containers for other statements. - This fixes a regression in emitting dummy blocks, notably for case statements. - This also fixes spurious emission of a number of debug stoppoint intrinsic instructions. Remove unneeded sw.body block, just clear the insertion point. Lift out CodeGenFunction::EmitStopPoint which calls into the CGDebugInfo class when generating debug info. Normalize definitions of Emit{Break,Continue}Stmt and usage of ErrorUnsupported. llvm-svn: 59118
* Move EmitBranchOnBoolExpr and ConstantFoldsToSimpleInteger toChris Lattner2008-11-121-92/+6
| | | | | | | | | | CodeGenFunction.cpp. Change VisitConditionalOperator to use constant fold instead of codegen'ing a constant conditional. Change ForStmt to use EmitBranchOnBoolExpr, this shrinks expr.c very slightly to 40239 lines. llvm-svn: 59113
* Make emission of 'if' conditions much more sophisticated when weChris Lattner2008-11-121-14/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | have a condition that is an &&/||. Before we used to compile things like this: int test() { if (x && y) foo(); else bar(); } into: %0 = load i32* @x ; <i32> [#uses=1] %1 = icmp ne i32 %0, 0 ; <i1> [#uses=1] br i1 %1, label %land_rhs, label %land_cont land_rhs: ; preds = %entry %2 = load i32* @y ; <i32> [#uses=1] %3 = icmp ne i32 %2, 0 ; <i1> [#uses=1] br label %land_cont land_cont: ; preds = %land_rhs, %entry %4 = phi i1 [ false, %entry ], [ %3, %land_rhs ] ; <i1> [#uses=1] br i1 %4, label %ifthen, label %ifelse ifthen: ; preds = %land_cont %call = call i32 (...)* @foo() ; <i32> [#uses=0] br label %ifend ifelse: ; preds = %land_cont %call1 = call i32 (...)* @bar() ; <i32> [#uses=0] br label %ifend ifend: ; preds = %ifelse, %ifthen Now we turn it into the much more svelte code: %0 = load i32* @x ; <i32> [#uses=1] %1 = icmp ne i32 %0, 0 ; <i1> [#uses=1] br i1 %1, label %land_lhs_true, label %ifelse land_lhs_true: ; preds = %entry %2 = load i32* @y ; <i32> [#uses=1] %3 = icmp ne i32 %2, 0 ; <i1> [#uses=1] br i1 %3, label %ifthen, label %ifelse ifthen: ; preds = %land_lhs_true %call = call i32 (...)* @foo() ; <i32> [#uses=0] br label %ifend ifelse: ; preds = %land_lhs_true, %entry %call1 = call i32 (...)* @bar() ; <i32> [#uses=0] br label %ifend ifend: ; preds = %ifelse, %ifthen Note the lack of a phi node. This shrinks the -O0 .ll file for 176.gcc/expr.c from 43176 to 40267 lines. llvm-svn: 59111
* Clean up some code to use isZero instead of calling getZExtValue.Chris Lattner2008-11-121-1/+1
| | | | llvm-svn: 59103
* Rework IRgen invariant w.r.t. current insert point.Daniel Dunbar2008-11-111-26/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - EmitStmt is no longer required to finish with a current insertion point defined (i.e. it does not need to make dummy blocks). Instead, it can clear the insertion point in the builder which indicates that the current insertion point is unreachable. - CodeGenFunction provides HaveInsertPoint and EnsureInsertPoint which respectively test if there is an insert point and ensure an insertion point exists (by making a dummy block). - Clearly mark functions in CodeGenFunction which can be called with no insertion point defined. Currently this is a limited set, and EmitStmt simply EnsureInsertPoint()s before emitting subsequent IR. Remove EmitDummyBlock, which is no longer needed. Clients who haven't already cleared the insertion point (typically via EmitBranch) can do so by hand. Remove isDummyBlock, which has effectively been renamed to HaveInsertPoint. The main thrust of this change is that we no longer have create dummy blocks just to destroy them a short time later in EmitBlock in the common case that there is no unreachable code following something like a goto. Additionally, this means that we are not using the hokey condition in isDummyBlock that a block without a name is a dummy block. Guess how well that works when we never emit block names! llvm-svn: 59089
* Change EmitBranch to always clear the insert point to clarify irgenDaniel Dunbar2008-11-111-1/+2
| | | | | | invariants. llvm-svn: 59085
* Add CodeGenFunction::EmitBranch.Daniel Dunbar2008-11-111-32/+28
| | | | | | | - Emits an unconditional branch, with extra logic to avoid generating spurious branches out of dummy blocks. llvm-svn: 59037
* short circuit && and || when possible. This substantially reducesChris Lattner2008-11-111-28/+0
| | | | | | | | the size of the -O0 output on some cases. For example, on expr.c from 176.gcc, it shrinks the .ll file from 43164 to 42835 lines, and removed references to two external symbols. llvm-svn: 59034
* Make codegen smart enough to not emit the dead side of an if whoseChris Lattner2008-11-111-5/+49
| | | | | | | condition is a constant. This shrinks -O0 codegen by quite a bit on some cases. llvm-svn: 59033
* Add CodeGenFunction::EmitDummyBlock for marking places where we makeDaniel Dunbar2008-11-111-6/+10
| | | | | | | "dummy" blocks (blocks just used to make sure we have a place to dump code to). llvm-svn: 59022
* Remove CodeGenFunction::StartBlock.Daniel Dunbar2008-11-111-4/+4
| | | | | | - Was confusing and only used in one small part of the code. llvm-svn: 59020
* Centralize basic block creation in CodeGenFunction::createBasicBlock.Daniel Dunbar2008-11-111-26/+26
| | | | | | - No functionality change. llvm-svn: 59017
* Support named operands in inline asm statements.Anders Carlsson2008-11-091-6/+51
| | | | llvm-svn: 58940
* Emit error unsupported when asm string conversion fails instead ofDaniel Dunbar2008-10-171-3/+13
| | | | | | assert. llvm-svn: 57721
* Change CGDebugInfo::setLocation to just ignore invalid locations. ThisDaniel Dunbar2008-10-171-8/+3
| | | | | | | | | simplifies clients. Also, add assert that RegionStack is empty when the CGDebugInfo is destroyed. llvm-svn: 57684
* silence release-assert warnings.Chris Lattner2008-10-121-4/+3
| | | | llvm-svn: 57392
* In EmitDeclStmt: use DeclStmt::const_decl_iterator instead of walking the ↵Ted Kremenek2008-10-061-3/+3
| | | | | | scoped decl chain. llvm-svn: 57192
* Emit error unsupported for break/continue/goto inside Obj-C exceptionDaniel Dunbar2008-10-021-2/+30
| | | | | | | handling blocks. - This has false positives, but at least prevents miscompiles. llvm-svn: 56958
* Add infrastructure for proper @finally support.Daniel Dunbar2008-09-301-0/+9
| | | | | | | | | | | | - Provides a basic primitive to jump to an arbitrary basic block, through the finally code. - Only used for return statements and rethrow currently. Still need to handle break, continue and goto. - Code still needs to be shuffled around to live elsewhere. llvm-svn: 56827
* Skip redundant if.Daniel Dunbar2008-09-281-5/+3
| | | | llvm-svn: 56762
* Refactor some CodeGen functionality: Daniel Dunbar2008-09-241-0/+15
| | | | | | | | | | - Add CodeGenFunction::{EmitReturnOfRValue, EmitIvarOffset} - Factor EmitLValueForIvar out of EmitObjCIvarRefLValue. No non-error functionality change (some unsupported errors are degraded to asserts for the time being). llvm-svn: 56543
* Make sure to store the exception in the catch parameter.Anders Carlsson2008-09-111-2/+2
| | | | llvm-svn: 56102
* Make sure to emit the catch parameter as well as the catch body.Anders Carlsson2008-09-111-2/+2
| | | | llvm-svn: 56101
* Use a unified return block.Daniel Dunbar2008-09-091-20/+12
| | | | | | | - For the time being this means our emitted code is somewhat worse, especially for aggregates. This will be fixed. llvm-svn: 56013
* Move handling of @try and @throw to the runtime class.Anders Carlsson2008-09-091-5/+5
| | | | llvm-svn: 55983
* Stub out CodeGenFunction::EmitObjCForCollectionStmt.Anders Carlsson2008-08-301-2/+2
| | | | | | Add CodeGenFunction::EmitMemSetToZero and make AggExprEmitter::EmitAggregateClear use it. llvm-svn: 55573
* Downgrade a number of FIXME asserts to ErrorUnsupported.Daniel Dunbar2008-08-291-3/+3
| | | | | | - Notably VLAs llvm-svn: 55544
* Implement Obj-C ivar references to aggregates.Daniel Dunbar2008-08-231-0/+19
| | | | | | | | | | | Implement Obj-C lvalue message sends (aggregate returns). Update several places to emit more precise ErrorUnsupported warnings for currently unimplemented Obj-C features (main missing chunks are property references, Obj-C exception handling, and the for ... in syntax). llvm-svn: 55234
* Change WarnUnsupported to ErrorUnsupported (in name and in practice).Daniel Dunbar2008-08-161-1/+1
| | | | | | | - We are beyond the point where this shows up often and when it does generating miscompiled files is bad. llvm-svn: 54836
* More #include cleaningDaniel Dunbar2008-08-111-4/+0
| | | | | | | | | | | - Kill unnecessary #includes in .cpp files. This is an automatic sweep so some things removed are actually used, but happen to be included by a previous header. I tried to get rid of the obvious examples and this was the easiest way to trim the #includes in one fell swoop. - We now return to regularly scheduled development. llvm-svn: 54632
* More #include cleaningDaniel Dunbar2008-08-111-1/+2
| | | | | | - Remove internal uses of AST.h llvm-svn: 54628
* Add CodeGen support for indirect goto.Daniel Dunbar2008-08-041-0/+20
| | | | | | | | | | - Follows emission scheme used by llvm-gcc, i.e. invent an id for each label whose address is taken and replace each indirect goto by a switch to each possible target. - Currently we emit a switch for each indirect goto instead of merging them as llvm-gcc does. llvm-svn: 54318
* implement codegen support for labels at the end of stmtexprs.Chris Lattner2008-07-261-5/+17
| | | | llvm-svn: 54100
* minor tidying, no functionality change.Chris Lattner2008-07-261-23/+12
| | | | llvm-svn: 54099
* Rework codegen of case rangesDaniel Dunbar2008-07-251-47/+49
| | | | | | | | | | | | | - Fix multiple issues with the way case ranges were emitted, see test cases details about the specific issues. - The root issue was not being careful about how basic blocks were emitted which led to them being chained together incorrectly, resulting in improper control flow. - Fixes <rdar://problem/6098585> llvm-svn: 54006
* Fix EmitCaseStmtRange to ignore empty rangesDaniel Dunbar2008-07-241-16/+14
| | | | | | | | | | - Also cleaned up emission slightly - Inspection of the code revealed several other bugs, however. Case ranges are not properly wired and can result in switch cases being dropped or even infinite loops. See: <rdar://problem/6098585> Completes: <rdar://problem/6094119> llvm-svn: 53975
* Basic support for volatile loads and stores. Stores the volatile Eli Friedman2008-06-131-1/+1
| | | | | | | | | | qualifier in the lvalue, and changes lvalue loads/stores to honor the volatile flag. Places which need some further attention are marked with FIXMEs. Patch by Cédric Venet. llvm-svn: 52264
* Generate subprogram debug info with -g.Sanjiv Gupta2008-05-251-9/+15
| | | | | | Also take care of freeing memory at the right places. llvm-svn: 51553
* Change uses of llvm::Type::isFirstClassType to use the newDan Gohman2008-05-221-5/+5
| | | | | | | | | | | | llvm::Type::isSingleValueType. Currently these two functions have the same behavior, but soon isFirstClassType will return true for struct and array types. Clang may some day want to use of isFirstClassType for some of these some day as an optimization, but it'll require some consideration. llvm-svn: 51446
* Make debugging information usable. This is barebones, but it makes -g Eli Friedman2008-05-221-15/+9
| | | | | | | | | | | | | | actually work (instead of crashing llc), and there's enough info emitted to get line number information in gdb. This should hopefully be helpful for debugging non-working programs. I got rid of the begin/endregion calls because the implementation wasn't working; someone who knows the debugging info a bit better might try to add it. I really have no clue how a compiler is supposed to emit them. This commit shouldn't have any effect without -g. llvm-svn: 51404
* Minor refactoring: compute the return value separately from emitting the Eli Friedman2008-05-221-8/+17
| | | | | | ret. llvm-svn: 51403
* Emit basic block for switch body; fixes PR2307.Eli Friedman2008-05-121-0/+3
| | | | llvm-svn: 50968
* Added -g command line options to clang for generating source level debug ↵Sanjiv Gupta2008-05-081-2/+30
| | | | | | information. This patch currently enables generation of line number debug information (stoppoints) and region begin/end debug information. The new files CGDebugInfo.h and CGDebugInfo.cpp implements the debug info manager class CGDebugInfo. llvm-svn: 50848
* tracking API changes arising from r49277Gabor Greif2008-04-061-19/+19
| | | | llvm-svn: 49279
* Since isComplexType() no longer returns true for _Complex integers, the codeChris Lattner2008-04-041-2/+2
| | | | | | generator needs to call isAnyComplexType(). This fixes PR1960. llvm-svn: 49220
* Add initial support for objc codegen for methods, ivars, and theChris Lattner2008-03-301-3/+0
| | | | | | etoile runtime, patch by David Chisnall! llvm-svn: 48969
* Make a major restructuring of the clang tree: introduce a top-levelChris Lattner2008-03-151-0/+776
lib dir and move all the libraries into it. This follows the main llvm tree, and allows the libraries to be built in parallel. The top level now enforces that all the libs are built before Driver, but we don't care what order the libs are built in. This speeds up parallel builds, particularly incremental ones. llvm-svn: 48402
OpenPOWER on IntegriCloud