Commit Graph

73 Commits

Author SHA1 Message Date
Mike Stump 0509d9635b Ensure we track all the stack depths for all break and continue points
correctly.  This should lay the ground work to throw the big switch
and start code gening break and continue in the presense of vlas.

llvm-svn: 64046
2009-02-07 23:02:10 +00:00
Mike Stump 56d2a15829 Format for 80-cols.
llvm-svn: 64030
2009-02-07 20:14:12 +00:00
Mike Stump dc0d6be7b9 Arrange to have the correct StackDepth for while statements.
llvm-svn: 64021
2009-02-07 18:08:12 +00:00
Mike Stump 1f8be1b9ac Fit into 80-col.
llvm-svn: 64020
2009-02-07 17:18:33 +00:00
Mike Stump 1d91dd98ad Fixup goto codegen in and around VLAs.
llvm-svn: 64014
2009-02-07 12:52:26 +00:00
Anders Carlsson 570c357ded If an input constraint refers to an output constraint, it should have the same constraint info as the output constraint. Fixes PR3417
llvm-svn: 63127
2009-01-27 20:38:24 +00:00
Chris Lattner 66c6562e24 silence a couple unused variable 'result' warnings.
llvm-svn: 62674
2009-01-21 07:35:26 +00:00
Anders Carlsson a92271d067 CG support for inline asm constraints with symbolic names. Fixes PR3345
llvm-svn: 62444
2009-01-18 02:06:20 +00:00
Anders Carlsson a79203be85 Add sema support for symbolic names in inline asm statements.
llvm-svn: 62441
2009-01-18 01:56:57 +00:00
Anders Carlsson 19aa04d270 Change TargetInfo::validateInputConstraint to take begin/end name iterators instead of the number of outputs. No functionality change.
llvm-svn: 62433
2009-01-17 23:36:15 +00:00
Anders Carlsson 00057e4e09 Handle multi-value inputs
llvm-svn: 62069
2009-01-12 02:22:13 +00:00
Anders Carlsson 431acd1129 More inline asm fixes
llvm-svn: 62049
2009-01-11 21:23:27 +00:00
Anders Carlsson a948c34b0b Handle readwrite constraints correctly
llvm-svn: 62043
2009-01-11 19:46:50 +00:00
Anders Carlsson da5f56939b Use a common function for emitting asm inputs and remove a FIXME
llvm-svn: 62041
2009-01-11 19:32:54 +00:00
Eli Friedman dea4193e8a Fix for PR3246: an empty clobber list is the empty string, not a null
string.

That said, we should probably try and track down the correct clobber 
lists for the targets that don't have them (PPC, ARM, and Sparc), 
so that we can generate correct code.

llvm-svn: 61298
2008-12-21 01:15:32 +00:00
Eli Friedman 5ad3c91b27 Extend the unsupported error to include break and continue, and fix a
warning by using an unsigned index.

llvm-svn: 61292
2008-12-20 23:18:29 +00:00
Anders Carlsson fbef9c208f Check the entire StackSaveValues stack for VLAs when dealing with goto and return statements. Noticed by Eli Friedman.
llvm-svn: 61289
2008-12-20 21:33:38 +00:00
Anders Carlsson 6200f0c533 Add some ErrorUnsupported calls and turn on VLA codegen again.
llvm-svn: 61283
2008-12-20 19:33:21 +00:00
Anders Carlsson 6b958f9634 Store the size of the EH stack inside each BreakContinue struct so we know when a break/continue won't cross a try block.
llvm-svn: 60998
2008-12-13 22:52:24 +00:00
Anders Carlsson 8a472c3151 Work in preparation for VLAs. Make sure to restore the stack if necessary (Saving the stack isn't implemented right now :)
llvm-svn: 60925
2008-12-12 05:52:00 +00:00
Anders Carlsson 59689ed764 Use Expr::Evaluate for case statements. Fixes PR2525
llvm-svn: 59881
2008-11-22 21:04:56 +00:00
Chris Lattner e132e2432a Start implementing support for @synchonized with the darwin ObjC API.
Patch by Fariborz!

llvm-svn: 59377
2008-11-15 21:26:17 +00:00
Daniel Dunbar df21c6e203 Supply finished flag to EmitBlock for common statements which use
landing pads.
 - Primarily a cleanliness issue instead of a performance issue (this
   eliminates all blocks w/o predecessors on 176.gcc/expr.c), but this
   also allows subsequent code to recognize it is unreachable and
   potentially avoid IRgen.

llvm-svn: 59211
2008-11-13 01:54:24 +00:00
Daniel Dunbar a612e79be4 Normalize many BasicBlock names.
- Use dotted notation for blocks related to a particular statement
   type.
 - Use .end for landing pads.

No functionality change in NDEBUG mode. :)

llvm-svn: 59210
2008-11-13 01:38:36 +00:00
Daniel Dunbar fcac22eac1 Add IsFinished arg to EmitBlock.
- 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
2008-11-13 01:24:05 +00:00
Daniel Dunbar f75c823e5c For if blocks with no else, name the join block ifend instead of the
more confusing ifelse.

Use dotted names for if blocks (if.then vs ifthen).

llvm-svn: 59201
2008-11-13 00:47:57 +00:00
Daniel Dunbar 5fc2871820 IRgen improvements on unreachable code:
- 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
2008-11-12 08:21:33 +00:00
Chris Lattner cd439299b0 Move EmitBranchOnBoolExpr and ConstantFoldsToSimpleInteger to
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
2008-11-12 08:04:58 +00:00
Chris Lattner b7a9e16486 Make emission of 'if' conditions much more sophisticated when we
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
2008-11-12 07:46:33 +00:00
Chris Lattner 4ad31fcc43 Clean up some code to use isZero instead of calling getZExtValue.
llvm-svn: 59103
2008-11-12 04:54:14 +00:00
Daniel Dunbar 5c7e3935f1 Rework IRgen invariant w.r.t. current insert point.
- 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
2008-11-11 23:11:34 +00:00
Daniel Dunbar ab197ebb1a Change EmitBranch to always clear the insert point to clarify irgen
invariants.

llvm-svn: 59085
2008-11-11 22:06:59 +00:00
Daniel Dunbar c56e67644f Add CodeGenFunction::EmitBranch.
- Emits an unconditional branch, with extra logic to avoid generating
   spurious branches out of dummy blocks.

llvm-svn: 59037
2008-11-11 09:41:28 +00:00
Chris Lattner 5b1964b5f9 short circuit && and || when possible. This substantially reduces
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
2008-11-11 07:41:27 +00:00
Chris Lattner aaaa199ad1 Make codegen smart enough to not emit the dead side of an if whose
condition is a constant.  This shrinks -O0 codegen by quite a bit
on some cases.

llvm-svn: 59033
2008-11-11 07:24:28 +00:00
Daniel Dunbar 29ac59f25c Add CodeGenFunction::EmitDummyBlock for marking places where we make
"dummy" blocks (blocks just used to make sure we have a place to dump
code to).

llvm-svn: 59022
2008-11-11 04:34:23 +00:00
Daniel Dunbar 05e629aec6 Remove CodeGenFunction::StartBlock.
- Was confusing and only used in one small part of the code.

llvm-svn: 59020
2008-11-11 04:12:31 +00:00
Daniel Dunbar 75283ff38a Centralize basic block creation in CodeGenFunction::createBasicBlock.
- No functionality change.

llvm-svn: 59017
2008-11-11 02:29:29 +00:00
Anders Carlsson 3442f82c2f Support named operands in inline asm statements.
llvm-svn: 58940
2008-11-09 18:54:14 +00:00
Daniel Dunbar 1e75408d89 Emit error unsupported when asm string conversion fails instead of
assert.

llvm-svn: 57721
2008-10-17 20:58:01 +00:00
Daniel Dunbar b9fd902fdc Change CGDebugInfo::setLocation to just ignore invalid locations. This
simplifies clients.

Also, add assert that RegionStack is empty when the CGDebugInfo is
destroyed.

llvm-svn: 57684
2008-10-17 16:15:48 +00:00
Chris Lattner 5d3e26a4f6 silence release-assert warnings.
llvm-svn: 57392
2008-10-12 00:31:50 +00:00
Ted Kremenek 704a2505db In EmitDeclStmt: use DeclStmt::const_decl_iterator instead of walking the scoped decl chain.
llvm-svn: 57192
2008-10-06 18:42:27 +00:00
Daniel Dunbar e23f28f8a5 Emit error unsupported for break/continue/goto inside Obj-C exception
handling blocks.
 - This has false positives, but at least prevents miscompiles.

llvm-svn: 56958
2008-10-02 18:02:06 +00:00
Daniel Dunbar 2efd538f61 Add infrastructure for proper @finally support.
- 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
2008-09-30 01:06:03 +00:00
Daniel Dunbar a2d3570fc9 Skip redundant if.
llvm-svn: 56762
2008-09-28 00:19:22 +00:00
Daniel Dunbar 1c64e5d12f Refactor some CodeGen functionality:
- 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
2008-09-24 04:00:38 +00:00
Anders Carlsson 9396a89899 Make sure to store the exception in the catch parameter.
llvm-svn: 56102
2008-09-11 09:15:33 +00:00
Anders Carlsson b5130d8588 Make sure to emit the catch parameter as well as the catch body.
llvm-svn: 56101
2008-09-11 08:21:54 +00:00
Daniel Dunbar 54bb1933b1 Use a unified return block.
- For the time being this means our emitted code is somewhat worse,
   especially for aggregates. This will be fixed.

llvm-svn: 56013
2008-09-09 21:00:17 +00:00