Commit Graph

4619 Commits

Author SHA1 Message Date
Chris Lattner 35d3ac5e9e Make skipping of vardecls more precise: it's ok to skip a decl if the entire
compound stmt containing the decl is skipped.

llvm-svn: 126639
2011-02-28 07:22:44 +00:00
Chris Lattner 62208c395a make switch constant folding a bit stronger, handling a missed case.
llvm-svn: 126638
2011-02-28 07:16:14 +00:00
Anders Carlsson e96ab55b28 Add a -fcxx-exceptions flag to the frontend, which can be used to enable
C++ exceptions, even when exceptions have been turned off using -fno-exceptions.
Make the -fobjc-exceptions flag do the same thing, but for Objective-C exceptions.

C++ and Objective-C exceptions can also be disabled using -fno-cxx-excptions and
-fno-objc-exceptions.

llvm-svn: 126630
2011-02-28 02:27:16 +00:00
Chris Lattner dc2cc67e57 remove a bogus assertion, add a comment.
llvm-svn: 126603
2011-02-28 01:06:02 +00:00
Chris Lattner 0709542628 make switch condition constant folding much more aggressive, handling
compound statements and break statements.  This implements enough to 
handle PR9322 and rdar://6970405.

llvm-svn: 126602
2011-02-28 01:02:29 +00:00
Chris Lattner 30db828ce7 fix my containsBreak predicate.
llvm-svn: 126600
2011-02-28 00:42:31 +00:00
Anders Carlsson 6dc07d4e56 Get rid of the areExceptionsEnabled() getter from LangOptions.
llvm-svn: 126598
2011-02-28 00:33:03 +00:00
Chris Lattner 0725a8b653 First tiny step to implementing PR9322: build infrastructure for only emitting the
live case of a switch statement when switching on a constant.  This is terribly
limited, but enough to handle the trivial example included.  Before we would 
emit:

define void @test1(i32 %i) nounwind {
entry:
  %i.addr = alloca i32, align 4
  store i32 %i, i32* %i.addr, align 4
  switch i32 1, label %sw.epilog [
    i32 1, label %sw.bb
  ]

sw.bb:                                            ; preds = %entry
  %tmp = load i32* %i.addr, align 4
  %inc = add nsw i32 %tmp, 1
  store i32 %inc, i32* %i.addr, align 4
  br label %sw.epilog

sw.epilog:                                        ; preds = %sw.bb, %entry
  switch i32 0, label %sw.epilog3 [
    i32 1, label %sw.bb1
  ]

sw.bb1:                                           ; preds = %sw.epilog
  %tmp2 = load i32* %i.addr, align 4
  %add = add nsw i32 %tmp2, 2
  store i32 %add, i32* %i.addr, align 4
  br label %sw.epilog3

sw.epilog3:                                       ; preds = %sw.bb1, %sw.epilog
  ret void
}

now we emit:

define void @test1(i32 %i) nounwind {
entry:
  %i.addr = alloca i32, align 4
  store i32 %i, i32* %i.addr, align 4
  %tmp = load i32* %i.addr, align 4
  %inc = add nsw i32 %tmp, 1
  store i32 %inc, i32* %i.addr, align 4
  ret void
}

This improves -O0 compile time (less IR to generate and shove through the code 
generator) and the clever linux kernel people found a way to fail to build if we 
don't do this optimization.  This step isn't enough to handle the kernel case
though.

llvm-svn: 126597
2011-02-28 00:22:07 +00:00
Chris Lattner 29911cc2f5 Add some helper methods that will be used in my next patch.
llvm-svn: 126596
2011-02-28 00:18:40 +00:00
Chris Lattner 41c6ab538a Change the interface to ConstantFoldsToSimpleInteger to not encode
a bool + success into one tri-state integer, simplifying things.

llvm-svn: 126592
2011-02-27 23:02:32 +00:00
John McCall c57994467b Don't assume that whoever is asking for a message send is going
to give us a non-null return slot.

llvm-svn: 126544
2011-02-26 09:48:59 +00:00
John McCall 71309be80a Zero-initialize the struct-return slot of an Objective-C message
send before making the call.  Fixes rdar://problem/7854674

llvm-svn: 126543
2011-02-26 09:12:15 +00:00
John McCall 8a3c55567e A much-delayed response to Ken Dyck's review: make this somewhat more
char-width agnostic.

llvm-svn: 126542
2011-02-26 08:41:59 +00:00
John McCall 53fcbd2718 Pretty up the emission of field l-values and use volatile and TBAA when
loading references as part of that.  Use 'char' TBAA when accessing
(immediate!) fields of a may_alias struct;  fixes PR9307.

llvm-svn: 126540
2011-02-26 08:07:02 +00:00
John McCall 1b93f1ba9f Tame an assert; the scope depth of a jump destination does not
necessarily enclose the innermost normal cleanup depth, because
the top of the jump scope stack might be an EH cleanup or EH scope.
Fixes PR9303.

llvm-svn: 126472
2011-02-25 04:19:13 +00:00
Rafael Espindola eb4fd01f7a Use private linkage to avoid symbol conflicts in corner cases like the one
in PR9301.

llvm-svn: 126422
2011-02-24 20:31:44 +00:00
David Chisnall 8aab5de75c Fix type mismatch between property function that CGObjCGNU was returning and the one CGObjC was calling. Fixes bug r9294.
llvm-svn: 126312
2011-02-23 14:05:31 +00:00
John McCall 147d021b75 Emit the structure layout of the block literal parameter to a block
invocation function into the debug info.  Rather than faking up a class,
which is tricky because of the custom layout we do, we just emit a struct
directly from the layout information we've already got.

Also, don't emit an unnecessarily parameter alloca for this "variable".

llvm-svn: 126255
2011-02-22 22:38:33 +00:00
Devang Patel b6ed369e77 A constructor call should force class's debug info even if -flimit-debug-info is enabled.
llvm-svn: 126246
2011-02-22 20:55:26 +00:00
Devang Patel d7185b755d Use LLVM coding standard.
llvm-svn: 126232
2011-02-22 18:56:36 +00:00
John McCall 9e2e22f5c6 Establish the iteration variable of an ObjC for-in loop before
emitting the collection expression.  Fixes some really, really broken
code.

llvm-svn: 126193
2011-02-22 07:16:58 +00:00
John McCall c533cb7008 Reorganize the emission of local variables.
llvm-svn: 126189
2011-02-22 06:44:22 +00:00
NAKAMURA Takumi f8a6e802f9 lib/CodeGen/TargetInfo.cpp: On Win64, arg i128 should be emitted as INDIRECT.
mingw-w64's i128 tweak should be done with x86_64-mingw32.

llvm-svn: 126186
2011-02-22 03:56:57 +00:00
David Chisnall 055f064756 The instance size of a metaclass should be the size of a class. This is not, in fact, 0, even for very small classes. (GNU runtime)
llvm-svn: 126161
2011-02-21 23:47:40 +00:00
John McCall e9dab636df Bind references to opaque r-values correctly. Add a few test cases
for ?: on record types.

llvm-svn: 126113
2011-02-21 05:25:38 +00:00
Richard Smith 30482bc786 Implement the C++0x deduced 'auto' feature.
This fixes PR 8738, 9060 and 9132.

llvm-svn: 126069
2011-02-20 03:19:35 +00:00
Anders Carlsson 08ce5ed1b1 Add a LangOptions::areExceptionsEnabled and start using it.
llvm-svn: 126062
2011-02-20 00:20:27 +00:00
Peter Collingbourne 8f5cf74c77 Re-instate r125819 and r125820 with no functionality change
llvm-svn: 126060
2011-02-19 23:03:58 +00:00
Douglas Gregor d66828daf6 In addition to in-class member functions marked with the "used"
attribute, we also care about those with the "constructor"
attribute. Fixes PR6521.

llvm-svn: 126055
2011-02-19 21:54:50 +00:00
Rafael Espindola a6d2bff0c5 Revert 125820 and 125819 to fix PR9266.
llvm-svn: 126050
2011-02-19 21:39:31 +00:00
John McCall 8377967543 Warn about code that uses variables and functions with internal linkage
without defining them.  This should be an error, but I'm paranoid about
"uses" that end up not actually requiring a definition.  I'll revisit later.

Also, teach IR generation to not set internal linkage on variable
declarations, just for safety's sake.  Doing so produces an invalid module
if the variable is not ultimately defined.

Also, fix several places in the test suite where we were using internal
functions without definitions.

llvm-svn: 126016
2011-02-19 02:53:41 +00:00
Devang Patel 2d6390d47b Start using enums from DIBuilder.
llvm-svn: 125990
2011-02-18 23:29:22 +00:00
Chris Lattner fa222dfbed If -fno-builtin is passed, tell TargetLibraryInfo to
turn off all builtin optimizations.

llvm-svn: 125979
2011-02-18 22:34:47 +00:00
Chris Lattner d98cec5ca2 install a TargetLibraryInfo configured with the appropriate
target triple.  This would be a decent place to add -fno-builtin
info for example.

llvm-svn: 125971
2011-02-18 22:20:38 +00:00
Fariborz Jahanian 302a3d4e4d Objective-c armv7 API for atomic properties of
scalar types. // rdar://7761305

llvm-svn: 125946
2011-02-18 19:15:13 +00:00
John McCall a9a2e8a58d The flags we're supposed to write into a byref struct are *not* the
_Block_object_* flags;  it's just BLOCK_HAS_COPY_DISPOSE or not.

Also, we don't need to chase forwarding pointers prior to calling
_Block_object_dispose;  _Block_object_dispose in fact already does
this.

rdar://problem/9006315

llvm-svn: 125823
2011-02-18 02:58:31 +00:00
Peter Collingbourne 14a552b2d7 Move CompilerInstance::LLVMContext and LLVMContext ownership to CodeGenAction
This removes the final dependency edge from any lib outside of CodeGen
to core.  As a result we can, and do, trim the dependency on core
from libclang, PrintFunctionNames, the unit tests and c-index-test.
While at it, review and trim other unneeded dependencies.

llvm-svn: 125820
2011-02-18 02:25:12 +00:00
Peter Collingbourne 3ae6caaf1b Move TargetInfo::adjustInlineAsmType to TargetCodeGenInfo
llvm-svn: 125819
2011-02-18 02:24:56 +00:00
Chris Lattner 43e7f31f11 implement basic support for __label__. I wouldn't be shocked if there are
bugs from other clients that don't expect to see a LabelDecl in a DeclStmt,
but if so they should be easy to fix.

This implements most of PR3429 and rdar://8287027

llvm-svn: 125817
2011-02-18 02:08:43 +00:00
Chris Lattner fb59c7c7d8 improve support for big endian targets, fixing PR8171, patch
by Heikki Kultala!

llvm-svn: 125784
2011-02-17 22:09:58 +00:00
John McCall e6be5e1c0d Remove the "conditional save" hashtables from IR generation.
llvm-svn: 125761
2011-02-17 19:02:56 +00:00
John McCall c07a0c7e48 Change the representation of GNU ?: expressions to use a different expression
class and to bind the shared value using OpaqueValueExpr.  This fixes an
unnoticed problem with deserialization of these expressions where the
deserialized form would lose the vital pointer-equality trait;  or rather,
it fixes it because this patch also does the right thing for deserializing
OVEs.

Change OVEs to not be a "temporary object" in the sense that copy elision is
permitted.

This new representation is not totally unawkward to work with, but I think
that's really part and parcel with the semantics we're modelling here.  In
particular, it's much easier to fix things like the copy elision bug and to
make the CFG look right.

I've tried to update the analyzer to deal with this in at least some          
obvious cases, and I think we get a much better CFG out, but the printing
of OpaqueValueExprs probably needs some work.

llvm-svn: 125744
2011-02-17 10:25:35 +00:00
NAKAMURA Takumi 31ea2f14bc Triple::MinGW64 is deprecated and removed. We can use Triple::MinGW32 instead.
No one uses *-mingw64. mingw-w64 is represented as {i686|x86_64}-w64-mingw32.

llvm-svn: 125742
2011-02-17 08:51:38 +00:00
NAKAMURA Takumi 029d74b264 Fix whitespace.
llvm-svn: 125741
2011-02-17 08:50:50 +00:00
Chris Lattner c8e630e4db Step #1/N of implementing support for __label__: split labels into
LabelDecl and LabelStmt.  There is a 1-1 correspondence between the
two, but this simplifies a bunch of code by itself.  This is because
labels are the only place where we previously had references to random
other statements, causing grief for AST serialization and other stuff.

This does cause one regression (attr(unused) doesn't silence unused
label warnings) which I'll address next.

This does fix some minor bugs:
1. "The only valid attribute " diagnostic was capitalized.
2. Various diagnostics printed as ''labelname'' instead of 'labelname'
3. This reduces duplication of label checking between functions and blocks.

Review appreciated, particularly for the cindex and template bits.

llvm-svn: 125733
2011-02-17 07:39:24 +00:00
Nick Lewycky 8d2226208d Ensure that the NRVO flag has some block to insert into. Fixes PR9178!
llvm-svn: 125694
2011-02-16 23:59:08 +00:00
Devang Patel 1728c232d5 If preprocessed token introduced empty filename then use main translation unit's filename for debug info entries.
llvm-svn: 125672
2011-02-16 18:40:36 +00:00
John McCall b5011ab8f9 Remove this FIXME; clear up an unused variable; style.
llvm-svn: 125662
2011-02-16 08:39:19 +00:00
John McCall 1bf5846abf Save a copy expression for non-trivial copy constructions of catch variables.
llvm-svn: 125661
2011-02-16 08:02:54 +00:00
Devang Patel 25468059e5 Simplify test to check an aggregate argument that has non trivial constructor or destructor.
This patch rewrites r125142.

llvm-svn: 125632
2011-02-16 01:11:51 +00:00