summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* When a function or variable somehow depends on a type or declarationDouglas Gregor2010-02-031-31/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that is in an anonymous namespace, give that function or variable internal linkage. This change models an oddity of the C++ standard, where names declared in an anonymous namespace have external linkage but, because anonymous namespace are really "uniquely-named" namespaces, the names cannot be referenced from other translation units. That means that they have external linkage for semantic analysis, but the only sensible implementation for code generation is to give them internal linkage. We now model this notion via the UniqueExternalLinkage linkage type. There are several changes here: - Extended NamedDecl::getLinkage() to produce UniqueExternalLinkage when the declaration is in an anonymous namespace. - Added Type::getLinkage() to determine the linkage of a type, which is defined as the minimum linkage of the types (when we're dealing with a compound type that is not a struct/class/union). - Extended NamedDecl::getLinkage() to consider the linkage of the template arguments and template parameters of function template specializations and class template specializations. - Taught code generation to rely on NamedDecl::getLinkage() when determining the linkage of variables and functions, also considering the linkage of the types of those variables and functions (C++ only). Map UniqueExternalLinkage to internal linkage, taking out the explicit checks for isInAnonymousNamespace(). This fixes much of PR5792, which, as discovered by Anders Carlsson, is actually the reason behind the pass-manager assertion that causes the majority of clang-on-clang regression test failures. With this fix, Clang-built-Clang+LLVM passes 88% of its regression tests (up from 67%). The specific numbers are: LLVM: Expected Passes : 4006 Expected Failures : 32 Unsupported Tests : 40 Unexpected Failures: 736 Clang: Expected Passes : 1903 Expected Failures : 14 Unexpected Failures: 75 Overall: Expected Passes : 5909 Expected Failures : 46 Unsupported Tests : 40 Unexpected Failures: 811 Still to do: - Improve testing - Check whether we should allow the presence of types with InternalLinkage (in addition to UniqueExternalLinkage) given variables/functions internal linkage in C++, as mentioned in PR5792. - Determine how expensive the getLinkage() calls are in practice; consider caching the result in NamedDecl. - Assess the feasibility of Chris's idea in comment #1 of PR5792. llvm-svn: 95216
* Don't explicitly force utf strings into the __TEXT,__ustringChris Lattner2010-02-011-4/+0
| | | | | | | | | | by setting the section of the generated global. This is an optimization done by the code generator, and the code being removed didn't handle the case when the string contained an embedded nul (which the code generator does correctly handle). This is rdar://7589850 llvm-svn: 95003
* In C++, an initializer on a variable doesn't necessarily mean it's the ↵Sebastian Redl2010-02-011-1/+1
| | | | | | definition. With that in mind, rename getDefinition to getAnyInitializer (to distinguish it from getInit) and reimplement it in terms of isThisDeclarationADefinition. Update all code to use this new function. llvm-svn: 94999
* Change the return type of ASTContext::getDeclAlignInBytes() to CharUnits and,Ken Dyck2010-01-271-1/+1
| | | | | | | now that the "InBytes" part of the name is implied by the return type, rename it to getDeclAlign(). llvm-svn: 94681
* Use CharUnits for alignment of UTF16 string in GetAddrOfConstantCFString().Ken Dyck2010-01-261-2/+2
| | | | llvm-svn: 94564
* Use the right definition when emitting a global variable. Fixes PR5564.Anders Carlsson2010-01-261-3/+5
| | | | llvm-svn: 94555
* Introduce CodeGenModule::GetTargetTypeStoreSize() to calculate the store sizeKen Dyck2010-01-261-0/+6
| | | | | | of LLVM types in character units. llvm-svn: 94542
* If a global variable has an initializer with side effects, it can never be ↵Anders Carlsson2010-01-261-3/+2
| | | | | | deferred (even if it's in an anonymous namespace). llvm-svn: 94525
* Created __builtin___NSStringMakeConstantString() builtin, which generates ↵David Chisnall2010-01-231-0/+9
| | | | | | constant Objective-C strings. llvm-svn: 94274
* Generalize target weirdness handling having proper layering in mind:Anton Korobeynikov2010-01-101-2/+6
| | | | | | | | | 1. Add helper class for sema checks for target attributes 2. Add helper class for codegen of target attributes As a proof-of-concept - implement msp430's 'interrupt' attribute. llvm-svn: 93118
* revert r92749, which is just dead code.Chris Lattner2010-01-091-10/+0
| | | | llvm-svn: 93074
* Fix for PR5967: Make const-marking for LLVM globals correct for cases requiringEli Friedman2010-01-081-5/+5
| | | | | | | run-time initialization, and emit run-time initializers aggresively to avoid ordering issues with deferred globals. llvm-svn: 92976
* Fix linkage for RTTI names by re-using the logic for computing theDouglas Gregor2010-01-061-24/+21
| | | | | | | | linkage of vtables. Before this, we were emitting RTTI names for template instantiations with strong external linkage rather than with weak ODR linkage. llvm-svn: 92857
* Fix marking of virtual members for nested classes whose first non-pure ↵Douglas Gregor2010-01-061-0/+54
| | | | | | virtual function has a body inlined in the class llvm-svn: 92855
* Improve key-function computation for templates. In particular:Douglas Gregor2010-01-051-1/+2
| | | | | | | | | | | | | | | | - All classes can have a key function; templates don't change that. non-template classes when computing the key function. - We always mark all of the virtual member functions of class template instantiations. - The vtable for an instantiation of a class template has weak linkage. We could probably use available_externally linkage for vtables of classes instantiated by explicit instantiation declarations (extern templates), but GCC doesn't do this and I'm not 100% that the ABI permits it. llvm-svn: 92753
* Add code to skip the emission of available externally functions at -O0. WIP.Mike Stump2010-01-051-0/+10
| | | | llvm-svn: 92749
* strength reduce this call away.Chris Lattner2009-12-291-1/+2
| | | | llvm-svn: 92253
* this form of SetDebugLocation is about to go away, add some #includes thatChris Lattner2009-12-281-3/+2
| | | | | | are about to not come in implicitly. llvm-svn: 92228
* Some small improvements to dead code elimination; helps a bit onEli Friedman2009-12-251-1/+1
| | | | | | LLVM-Code-Symbols test. llvm-svn: 92152
* Un-namespace-qualify llvm_unreachable. It's a macro, so the qualification gaveJeffrey Yasskin2009-12-121-1/+1
| | | | | | no extra safety anyway. llvm-svn: 91207
* Fix for PR5714: make sure globals that will be modified aren't marked const.Eli Friedman2009-12-111-5/+13
| | | | llvm-svn: 91156
* Random string-related cleanups.Benjamin Kramer2009-12-111-3/+2
| | | | llvm-svn: 91119
* Make sure that explicitly instantiated functions get the right linkage.Anders Carlsson2009-12-101-3/+12
| | | | llvm-svn: 91069
* Fix for PR5709: use the computed type of the declaration instead of theEli Friedman2009-12-091-6/+1
| | | | | | | type of the builtin when generating the function declaration for a builtin library call. llvm-svn: 90936
* Misc key function fixes.Eli Friedman2009-12-081-0/+10
| | | | llvm-svn: 90831
* A bunch more thunk fixes from misc testing.Eli Friedman2009-12-071-1/+7
| | | | | | (Yes, I do intend to commit some tests for this.) llvm-svn: 90818
* Work-in-progess rewrite of thunks: move thunk generation outside of vtableEli Friedman2009-12-061-1/+6
| | | | | | | generation, and make sure we generate thunks when the function is defined rather than when the vtable is defined. llvm-svn: 90722
* Add rudimentary support for member pointers to CGDebugInfo.Anders Carlsson2009-12-061-1/+1
| | | | llvm-svn: 90711
* Don't emit explicit specializations of static member variable declarations.Anders Carlsson2009-12-041-5/+11
| | | | llvm-svn: 90624
* Have ASTRecordLayout keep track of the key function, in preparation of ↵Anders Carlsson2009-11-301-12/+4
| | | | | | fixing a synthetic ctor/dtor bug. llvm-svn: 90168
* Don't try to generate common globals for C++ files, instead of depending on ↵Daniel Dunbar2009-11-301-1/+1
| | | | | | the FE to set NoCommon, and simplify CodeGenOptions initialization. llvm-svn: 90119
* Simplify and fix up the handling of implicit constructors, copy assignmentEli Friedman2009-11-261-130/+7
| | | | | | | | operators, and destructors. Avoids generating declarations/definitions of trivial constructors/destructors, and makes sure the trivial copy assignment operator is generated when necessary. llvm-svn: 89943
* Use new getLinkage() method to correctly compute whether a variable hasEli Friedman2009-11-261-4/+3
| | | | | | internal linkage. Fixes PR5433. llvm-svn: 89931
* Ignore constructor member templates in CodeGenModule::EmitTopLevelDecl.Anders Carlsson2009-11-241-0/+4
| | | | llvm-svn: 89737
* Mangler: Lift shouldMangleDeclName predicate out of CXXNameMangler::mangle.Daniel Dunbar2009-11-211-7/+2
| | | | | | | | - Sometimes we have to mangle things we wouldn't normally (e.g., because they appear in a template expression). - This also tidies up the predicate to be more obvious what is getting mangled. llvm-svn: 89555
* IRgen: Switch the C++ mangler interfaces to take the SmallVector to write into,Daniel Dunbar2009-11-211-2/+1
| | | | | | | instead of requiring clients to make a raw_svector_ostream, which is just an implementation detail. llvm-svn: 89548
* Sink free mangle* methods into MangleContext.Daniel Dunbar2009-11-211-1/+1
| | | | llvm-svn: 89547
* Added rudimentary C++0x attribute support.Alexis Hunt2009-11-211-2/+6
| | | | | | | | | | | | | | The following attributes are currently supported in C++0x attribute lists (and in GNU ones as well): - align() - semantics believed to be conformant to n3000, except for redeclarations and what entities it may apply to - final - semantics believed to be conformant to CWG issue 817's proposed wording, except for redeclarations - noreturn - semantics believed to be conformant to n3000, except for redeclarations - carries_dependency - currently ignored (this is an optimization hint) llvm-svn: 89543
* Fixup key function calculations.Mike Stump2009-11-201-1/+3
| | | | llvm-svn: 89412
* Improve instantiation control for rtti data and allow key functions toMike Stump2009-11-191-0/+10
| | | | | | instantiate a class. WIP. llvm-svn: 89289
* Skip over shadow using decls during codegen.John McCall2009-11-171-0/+1
| | | | llvm-svn: 89079
* The ssp and sspreq function attributes should only be applied to function ↵Anders Carlsson2009-11-161-0/+5
| | | | | | definitions, not declarations or calls. llvm-svn: 88915
* Make GetAddrOfConstantStringFromLiteral return a constant of the correct type.Eli Friedman2009-11-161-1/+8
| | | | | | | This doesn't have any visible effects at the moment because normally the implicit cast code forces the type to the expected type. llvm-svn: 88896
* Move CompileOptions -> CodeGenOptions, and sink it into the CodeGen library.Chandler Carruth2009-11-121-5/+5
| | | | | | This resolves the layering violation where CodeGen depended on Frontend. llvm-svn: 86998
* Rearrange function to avoid recursive use-after-free.Eli Friedman2009-11-091-17/+18
| | | | llvm-svn: 86516
* add missing #includeChris Lattner2009-11-071-0/+1
| | | | llvm-svn: 86368
* Added support for static variables which requireFariborz Jahanian2009-11-051-4/+9
| | | | | | initialization before main. Fixes pr5396. llvm-svn: 86145
* Implement proper linkage for explicit instantiation declarations ofDouglas Gregor2009-10-271-14/+14
| | | | | | | | | | | | | | | | | | | | | inlined functions. For example, given template<typename T> class string { unsigned Len; public: unsigned size() const { return Len; } }; extern template class string<char>; we now give the instantiation of string<char>::size available_externally linkage (if it is ever instantiated!), as permitted by the C++0x standard. llvm-svn: 85340
* Introduce FunctionDecl::isInlined() to tell whether a function shouldDouglas Gregor2009-10-271-2/+2
| | | | | | be inlined. llvm-svn: 85307
* Rename FunctionDecl::isInline/setInline toDouglas Gregor2009-10-271-2/+2
| | | | | | FunctionDecl::isInlineSpecified/setInlineSpecified. llvm-svn: 85305
OpenPOWER on IntegriCloud