Граф коммитов

50 Коммитов

Автор SHA1 Сообщение Дата
Daniel Dunbar 208ff5e8a0 Change CodeGenModule to only create ObjC runtime for ObjC files
- Changed CodeGenModule::getObjCRuntime to return reference.
 - Added CodeGenModule::hasObjCRuntime predicate.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54645 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 18:12:00 +00:00
Daniel Dunbar 6379a7a153 Add -fexceptions to Driver
- Maps to LangOptions.Exceptions
 - Currently always off, should autoselect based on language.

Update CodeGen to set unwind attribute on functions definitions based
       on LangOptions.Exceptions.
 - Still need to set attributes appropriately on calls.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54643 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 17:36:14 +00:00
Daniel Dunbar acc5f3e423 More #include cleaning
- 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54632 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 06:23:49 +00:00
Daniel Dunbar c4a1dea2dc More #include cleaning
- Drop {Decl.h,DeclObjC.h,IdentifierTable.h} from Expr.h
 - Moved Sema::getCurMethodDecl() out of line (dependent on
   ObjCMethodDecl via dyn_cast).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54629 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 05:35:13 +00:00
Daniel Dunbar c17a4d3b16 Add dummy Mac Objective-C runtime interface.
- Not currently accessible and completely non-functional.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54624 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-11 02:45:11 +00:00
Daniel Dunbar 1e04976fc2 Back out r54608 (inline string literals were getting an extra '\0')
temporarily, I assumed GetAddrForConstantString literal was being
  used consistently but it doesn't look like it is.

Factored out a CodeGenModule::getStringForStringLiteral which handles
  extracting a std::string for the bytes of a StringLiteral, padded to
  match the type.

Update EmitLValue to use getStringForStringLiteral, this was
  previously not padding strings correctly. Good thing we only emit
  strings in 4 different places!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54621 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-10 20:25:57 +00:00
Daniel Dunbar ec5c2a7646 Bug fix, inline string literals were getting an extra '\0'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54608 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-10 06:27:44 +00:00
Daniel Dunbar a735ad8be5 Implement GNU asm-label extension support in CodeGen. This fixes
scimark2 on Darwin.

 - Added Sema support for asm-label on variables, which I forgot before.

 - Update CodeGen to use GlobalDeclMap to determine if static Decls
   require emission (instead of LLVM module name lookup). Important
   since the Decl name and the LLVM module name can differ.

 - <rdar://problem/6116729>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54388 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-06 00:03:29 +00:00
Daniel Dunbar 3c827a79cb Change CodeGen of global decls to key off of the name (instead of
having multiple bindings from all the possible decls which
  conceptually map to the same global).

 - This eliminates CodeGen depending on the LLVM module for name
   lookup.

 - This also eliminates the need for ReplaceMapValuesWith (hurrah).

 - This handles lookups for FunctionDecls correctly in the presence of
   aliases, this was previously broken.

 - WIP: Can still clean up & unify variable and function emission.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54382 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-05 23:31:02 +00:00
Ted Kremenek 815c78fd9a Refactored driver logic for CodeGen into LLVMCodeGenWriter. This ASTConsumer layers on top of LLVMCodeGen (another existing ASTConsumer) to emit bitcode files to disk. This layering takes this logic out of clang.cpp and puts it directly into the ASTConsumer interface. The benefit is that now --emit-llvm works with both serialized ASTs and regular source files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54364 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-05 18:50:11 +00:00
Chris Lattner c63a1f276f Finally fix PR2189. This makes a fairly invasive but important change to
move getAsArrayType into ASTContext instead of being a method on type.
This is required because getAsArrayType(const AT), where AT is a typedef
for "int[10]" needs to return ArrayType(const int, 10).

Fixing this greatly simplifies getArrayDecayedType, which is a good sign.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54317 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-04 07:31:14 +00:00
Daniel Dunbar 6bfed7e411 Support constructor and destructor attributes in CodeGen
- There is an miscompilation issue remaining due to a poor
   interaction between the delayed emission of static functions and
   the emission of constructors, but that already existed prior to
   this change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54258 91177308-0d34-0410-b5e6-96231b3b80d8
2008-08-01 00:01:51 +00:00
Daniel Dunbar 9986eabd44 Change CodeGenModule GlobalDeclMap to directly reference globals
instead of mapping the decl to a bitcast of the global to the correct
type.
 
 - GetAddrOf{Function,GlobalVar} introduce the bitcast on every use now.

 - This solves a problem where a dangling pointer could be introduced
   by the RAUW done when replacing a forward or tentative
   definition. See testcase for more details.

 - Fixes <rdar://problem/6108358>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54211 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-30 16:32:24 +00:00
Daniel Dunbar bd012ff1fa Rework codegen emission of globals
- No (intended) functionality change.

 - Primary purpose is to clearly separate (lazy) construction of
   globals that are a forward declaration or tentative definition from
   those that are the final definition.

 - Lazy construction is now encapsulated in
   GetAddrOf{Function,GlobalVar} while final definitions are
   constructed in EmitGlobal{Function,Var}Definition.
 
 - External interface for dealing with globals is now limited to
   EmitGlobal and GetAddrOf{Function,GlobalVar}.

 - Also updated helper functions dealing with statics, annotations,
   and ctors to be private.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54179 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-29 23:18:29 +00:00
Daniel Dunbar 58a7a265cf Fix codegen of chained declarations
- Killed useless CodeGenModule::EmitGlobalVarDeclarator, instead just
   recurse on any ScopedDecl.
 - Fix for <rdar://problem/6093838>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54162 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-29 17:47:36 +00:00
Chris Lattner 780f329cb0 move two more lists of protocols over to use ObjCList<ObjCProtocolDecl>,
simplifying code along the way and fixing a problem and memory leak or two.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53876 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-21 21:32:27 +00:00
Chris Lattner 3db6cae19c introduce a new ObjCList templated class and start moving
various objc lists over to it.  First up, the protocol list 
on ObjCInterfaceDecl.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53856 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-21 18:19:38 +00:00
Chris Lattner a4210076fc refactor more objc codegen interfaces to pass around selectors so
we don't push strings into LLVM IR and then have to read them back out.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52765 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 05:08:00 +00:00
Chris Lattner fba6763967 indenting and other minor things.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52764 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 04:52:29 +00:00
Chris Lattner dce1406f1c give CreateObjCRuntime a full CGM so it can get whatever state it needs,
instead of passing in just a couple random things it currently 
happens to use.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52756 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 04:19:03 +00:00
Nuno Lopes d4cbda6292 implement the alias attirbute (in both Sema and Codegen)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52092 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-08 15:45:52 +00:00
Sanjiv Gupta 686226b538 Emit debug information for global and static variables when -g is specified.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51993 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-05 08:59:10 +00:00
Eli Friedman c134fcb0d7 For setting attributes, don't assume there are ParamVarDecls available,
because trying to access non-existent ParamVarDecls can crash. 
Testcase from the original source for PR2414.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51960 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-04 19:41:28 +00:00
Eli Friedman ff4a2d9e2c First cut at setting attributes for functions and calls; this puts us
much closer to passing the gcc struct layout tests.

It might be possible to refactor this a bit, but I'm not sure there's 
actually enough common code for that to be useful.

To get the calling convention completely correct, a bit of 
platform-specific code is necessary even for x86-Linux. On x86-Linux, the
alignment of function parameters is extremely strange; as far as I can tell,
it's always 4 except for SSE vectors or structs containing SSE vectors.  I'm 
continuing to investigate this.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51839 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-01 15:54:49 +00:00
Anton Korobeynikov 20ff3108fc Support for code generation of Objective-C top-level language constructs.
Implemented by David Chisnall!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51835 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-01 14:13:53 +00:00
Eli Friedman cd5f4aaf0c PR1893: Fix up the type of tentative definitions of incomplete array
types so that they end up the correct size.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51787 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-30 20:39:54 +00:00
Eli Friedman 77ba708819 Allow the type of a global to be different from the type of its
associated declaration. This is a prerequisite to handling
general union initializations; for example, an array of unions involving 
pointers has to be turned into a struct because the elements can have 
incompatible types.

I refactored the code a bit to make it more readable; now, the logic for 
definitions is all in EmitGlobalVarInit.

The second parameter for GetAddrOfGlobalVar is now dead; I'll remove it 
separately.

By itself, this patch should not cause any visible changes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51783 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-30 19:50:47 +00:00
Eli Friedman 109603de14 Always check that the definition of a function has the correct type.
This fixes a crash on the included testcase (found in NetHack).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51767 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-30 11:13:18 +00:00
Eli Friedman 08d7802a40 Add CodeGen support for alignment on globals, both for unusual natural
alignment and alignment attributes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51676 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-29 11:10:27 +00:00
Eli Friedman a07b76419a Tentative declarations are supposed to have common linkage, not weak.
This change makes clang generate the same thing as llvm-gcc.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51674 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-29 11:03:17 +00:00
Eli Friedman a1d642db81 The cache is working again; re-enable it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51587 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-27 08:43:22 +00:00
Eli Friedman 6f7e2eee91 Add a more reliable check for whether a static declaration has already
been used.  In preparation for the fix to PR2360, but also a minor bug 
in its own right.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51583 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-27 04:58:01 +00:00
Eli Friedman 0c99509927 Emit memmove, not memcpy, for structure copies; this is unfortunately
required for correctness in cases of copying a struct to itself or to 
an overlapping struct (itself for cases like *a = *a, and overlapping 
is possible with unions).

Hopefully, this won't end up being a perf issue; LLVM *should* be able 
to optimize memmove to memcpy in a lot of cases, and for small copies 
the generated code *should* be mostly comparable. (In reality, LLVM 
is currently horrible at optimizing memmove, but that's a bug, not a 
fundamental issue.)

gcc currently generates wrong code; that's 
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32667.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51566 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-26 12:59:39 +00:00
Dan Gohman 4f8d123e3e Move getAccessedFieldNo out of lib/AST/Expr.cpp into
lib/CodeGen/CGExpr.cpp and to change include/clang/AST/Attr.h to
use its own enum for visibility types instead of using
llvm::GlobalValue::VisibilityTypes. These changes eliminate
dependencies in the AST library on LLVM's VMCore library.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51398 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-22 00:50:06 +00:00
Eli Friedman be14c5c6e2 Disable the function address cache; this doesn't have any ill effects,
as far as I can tell, and it fixes code like test/CodeGen/functions.c.

(Whatever performance effect it might have, crashing on a 
construct like this isn't really acceptable; I've run into this 
multiple times.)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51312 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-20 09:21:07 +00:00
Sanjiv Gupta e8b9f5b8ea Added -g command line options to clang for generating source level debug 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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50848 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-08 08:54:20 +00:00
Chris Lattner a212c56e9b Simplify FunctionDecl::AddRedeclaration a bit by using std::swap.
Fix 'swapping' of attributes to not insert null values into the 
DeclAttrs map.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50612 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-04 02:29:49 +00:00
Chris Lattner 8fabd78f19 if a decl is both 'static' and weak or static and inline, its linkage
type should be internal, not weak/linkonce.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50611 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-04 01:44:26 +00:00
Chris Lattner a1945fa74d Verify the whole module after codegen to catch silly IR bugs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50485 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-30 16:05:42 +00:00
Chris Lattner 5827754da1 remove the 'unused static' diagnostic from codegen. This should be
reimplemented in Sema someday.  This is tracked in PR2236.  Until then
disabling it removes some bogus diagnostics (see 2236).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50263 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-25 15:47:13 +00:00
Nate Begeman 1a1d92ac5e Fix PR2236
Add test
Implement feedback from Chris re: PR1998


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50001 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-20 20:38:08 +00:00
Nate Begeman 4c13b7a397 Only generate code for static functions and global variables that are actually used.
Warn about unused static functions and variables.
This fixes PR1998.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49987 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-20 06:29:50 +00:00
Nate Begeman 8bd4afeb87 Generate code for annotation attributes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49951 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-19 04:17:09 +00:00
Nate Begeman 532485cc6c Add support to module codegen for adding and emitting annotations
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49944 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-18 23:43:57 +00:00
Steve Naroff 248a753f6b Remove FileVarDecl and BlockVarDecl. They are replaced by VarDecl::isBlockVarDecl() and VarDecl::isFileVarDecl().
This is a fairly mechanical/large change. As a result, I avoided making any changes/simplifications that weren't directly related. I did break two Analysis tests. I also have a couple FIXME's in UninitializedValues.cpp. Ted, can you take a look? If the bug isn't obvious, I am happy to dig in and fix it (since I broke it).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49748 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-15 22:42:06 +00:00
Gabor Greif 984d0b414b tracking API changes arising from r49277
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49279 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-06 20:42:52 +00:00
Chris Lattner ce5605ecf7 some cleanups on top of David's patch. There are still two
remaining open issues I've communicated to him:

1) self can be assigned to, and his patch didn't handle it correctly.
2) CollectObjCIvarTypes is N^2 (because each subclass reprocesses
   all parent class ivars) and flattens classes.  If A derives from B, 
   and both have an int, I'd expect to get { {i32}, i32}, not { i32, i32}.

David, please review.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48970 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-30 23:25:33 +00:00
Chris Lattner 391d77a263 Add initial support for objc codegen for methods, ivars, and the
etoile runtime, patch by David Chisnall!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48969 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-30 23:03:07 +00:00
Chris Lattner 572cf09ae8 simplify code by using the variadic StructType::get method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48535 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-19 05:24:56 +00:00
Chris Lattner bda0b626e7 Make a major restructuring of the clang tree: introduce a top-level
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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48402 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-15 23:59:48 +00:00