- Outside the "if", to ensure that we destroy the condition variable
at the end of the "if" statement rather than at the end of the
block containing the "if" statement.
- Inside the "then" and "else" branches, so that we emit then- or
else-local cleanups at the end of the corresponding block when the
block is not a compound statement.
To make adding these new cleanup scopes easier (and since
switch/do/while will all need the same treatment), added the
CleanupScope RAII object to introduce a new cleanup scope and make
sure it gets cleaned up.
llvm-svn: 89773
rather than burying it in a CXXConditionDeclExpr (that occassionally
hides behind implicit conversions). Similar changes for
switch, while, and do-while will follow, then the removal of
CXXConditionDeclExpr. This commit is the canary.
llvm-svn: 89717
using the new LLVM support for this. This is temporarily hiding
behind horrible and ugly #ifdefs until the time when the optimizer
is stable (hopefully a week or so). Until then, lets make it "opt in" :)
llvm-svn: 85446
1. CGF now has fewer bytes of state (one pointer instead of a vector).
2. The generated code is determinstic, instead of getting labels in
'map order' based on pointer addresses.
3. Clang now emits one 'indirect goto switch' for each function, instead
of one for each indirect goto. This fixes an M*N = N^2 IR size issue
when there are lots of address-taken labels and lots of indirect gotos.
4. This also makes the default cause do something useful, reducing the
size of the jump table needed (by one).
llvm-svn: 83952
expressions.
- This generally catches the important case of noreturn functions.
- With the last two changes, we are down to 152 unreachable blocks emitted on
403.gcc, vs the 1805 we started with.
llvm-svn: 76364
- Emit variable declarations as "simple", we want to avoid forcing the creation
of a dummy basic block, but still need to make the variable available for
later use.
- With that, we can now skip IRgen for other unreachable statements (which
don't define a label).
- Anders, I added two fixmes on calls to EmitVLASize, can you check them?
llvm-svn: 76361
function calls. For a program like this:
#include <stdio.h>
static __inline__ __attribute__((always_inline))
int bar(int x) { return 4; }
int main() {
int X = bar(4);
printf("%d\n", X);
}
clang was not outputing any debug info for the body of main(). This is
because the backend is getting confused by the region_start/end that clang
is emitting for block scopes. For now, just disable these (matching llvm-gcc),
this stuff is in progress of rework anyway.
llvm-svn: 70889
- <rdar://problem/6732143> Crash when generating @synchronize for
zero-cost exception
- Thanks to Anders for helping track down the problem.
llvm-svn: 68186
really horrible extensions that are disabled by default but that can
be accepted by -fheinous-gnu-extensions (but which always emit a
warning when enabled).
As our first instance of this, implement PR3788/PR3794, which allows
non-lvalues in inline asms in contexts where lvalues are required. bleh.
llvm-svn: 66910
done in sema, and is reflected by the existing PR3258. In the meantime,
fix PR3682 by disabling a bogus assertion (which doesn't account for +
operands).
llvm-svn: 66533
asm. This allows us to properly handle the case when an optimizer duplicates
the asm, such as here:
void bar() {
int i;
for (i = 0; i < 3; ++i)
asm("foo %=" : : "r"(0));
}
we now produce:
_bar:
xorl %eax, %eax
## InlineAsm Start
foo 0
## InlineAsm End
## InlineAsm Start
foo 1
## InlineAsm End
## InlineAsm Start
foo 2
## InlineAsm End
ret
instead of:
_bar:
xorl %eax, %eax
## InlineAsm Start
foo 1
## InlineAsm End
## InlineAsm Start
foo 1
## InlineAsm End
## InlineAsm Start
foo 1
## InlineAsm End
ret
This also fixes a fixme by eliminating a static.
llvm-svn: 66528
it in the stack trace, giving us stuff like:
Stack dump:
0. Program arguments: clang t.c -emit-llvm
1. <eof> parser at end of file
2. t.c:1:5: LLVM IR generation of declaration 'a'
3. t.c:1:9: LLVM IR generation of compound statement ('{}')
4. t.c:2:3: LLVM IR generation of compound statement ('{}')
Abort
llvm-svn: 66154
If people could beat on it and let me know if there are any new
semantics required by newer language standards or DRs or any little
details I goofed on, I'd be happy to fix any issues found.
llvm-svn: 64079
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
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
- 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
- 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
- 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
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
- 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
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
- 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
- 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
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
- 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
- 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
- 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
- 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
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
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
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
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