summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Rename flags and options to match current naming: from -fdef-sized-delete to ↵Larisse Voufo2015-02-181-1/+1
| | | | | | -fdefine-sized-deallocation, and from DefaultSizedDelete to DefineSizedDeallocation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229597 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Update for LLVM API changeJustin Bogner2015-02-161-2/+4
| | | | | | Update for the API change in r229433 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229434 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a typo in r229291 causing buildbot failure.Larisse Voufo2015-02-151-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229295 91177308-0d34-0410-b5e6-96231b3b80d8
* More on fixing sized deallocation implementation logic: Fix PR21754.Larisse Voufo2015-02-151-5/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229291 91177308-0d34-0410-b5e6-96231b3b80d8
* Revise the implementation logic of sized deallocation: Do not automatically ↵Larisse Voufo2015-02-141-4/+4
| | | | | | | | generate weak definitions of the sized operator delete (in terms of unsized operator delete). Instead, provide the funcitonality via a new compiler flag, -fdef-sized-delete. The current implementation causes link-time ODR violations when the delete symbols are exported into the dynamic table. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229241 91177308-0d34-0410-b5e6-96231b3b80d8
* MS ABI: Records with fields with required aligmnet shouldn't be commonDavid Majnemer2015-02-031-3/+19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227954 91177308-0d34-0410-b5e6-96231b3b80d8
* When generating llvm.used, we may need an addrspacecast instead of a bitcast.Justin Holewinski2015-02-021-2/+2
| | | | | | | | | | | | | | | | | | Summary: This is especially important for targets that use multiple address spaces, and commonly place global variables in address spaces other than zero. Fixes PR22383 Test Plan: New test case added: llvm-used.cu Reviewers: jingyue Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7345 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227861 91177308-0d34-0410-b5e6-96231b3b80d8
* Emit DeferredDeclsToEmit in a DFS order.Rafael Espindola2015-01-221-14/+26
| | | | | | | | | | | | | | Currently we emit DeferredDeclsToEmit in reverse order. This patch changes that. The advantages of the change are that * The output order is a bit closer to the source order. The change to test/CodeGenCXX/pod-member-memcpys.cpp is a good example. * If we decide to deffer more, it will not cause as large changes in the estcases as it would without this patch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226751 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format function. NFC.Rafael Espindola2015-01-211-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226662 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: Compiler generated __declspec(uuid) objects should be COMDAT'dDavid Majnemer2015-01-211-0/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226628 91177308-0d34-0410-b5e6-96231b3b80d8
* Add comdat to string literal variables on COFF.Rafael Espindola2015-01-161-2/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226317 91177308-0d34-0410-b5e6-96231b3b80d8
* Use a trivial comdat for C++ tables.Rafael Espindola2015-01-151-1/+4
| | | | | | | | | This produces comdats for vtables, typeinfo, typeinfo names, and vtts. When combined with llvm not producing implicit comdats, not doing this would cause code bloat on ELF and link errors on COFF. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226227 91177308-0d34-0410-b5e6-96231b3b80d8
* Use a trivial comdat for inline ctor/dtor when not using C5/D5.Rafael Espindola2015-01-151-4/+9
| | | | | | | When combined with llvm not producing implicit comdats, not doing this would cause code bloat on ELF and link errors on COFF. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226211 91177308-0d34-0410-b5e6-96231b3b80d8
* [cleanup] Re-sort *all* #include lines with llvm/utils/sort_includes.pyChandler Carruth2015-01-141-1/+1
| | | | | | | | | | Sorry for the noise, I managed to miss a bunch of recent regressions of include orderings here. This should actually sort all the includes for Clang. Again, no functionality changed, this is just a mechanical cleanup that I try to run periodically to keep the #include lines as regular as possible across the project. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225979 91177308-0d34-0410-b5e6-96231b3b80d8
* [patch][pr19848] Produce explicit comdats in clang.Rafael Espindola2015-01-121-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | The llvm IR until recently had no support for comdats. This was a problem when targeting C++ on ELF/COFF as just using weak linkage would cause quite a bit of dead bits to remain on the executable (unless -ffunction-sections, -fdata-sections and --gc-sections were used). To fix the problem, llvm's codegen will just assume that any weak or linkonce that is not in an explicit comdat should be output in one with the same name as the global. This unfortunately breaks cases like pr19848 where a weak symbol is not xpected to be part of any comdat. Now that we have explicit comdats in the IR, we can finally get both cases right. This first patch just makes clang give explicit comdats to GlobalValues where t is allowed to. A followup patch to llvm will then stop implicitly producing comdats. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225705 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't emit implicit template instantiations eagerly (PR21718)Hans Wennborg2015-01-101-14/+32
| | | | | | | | | | | | | | Their linkage can change if they are later explicitly instantiated. We would previously emit such functions eagerly (as opposed to lazily on first use) if they have a 'dllexport' or 'used' attribute, and fail an assert when hitting the explicit instantiation. This is achieved by replacing the old CodeGenModule::MayDeferGeneration() method with two new ones: MustBeEmitted() and MayBeEmittedEagerly(). Differential Revision: http://reviews.llvm.org/D6674 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225570 91177308-0d34-0410-b5e6-96231b3b80d8
* PR21909: Don't try (and crash) to generate debug info for explicit ↵David Blaikie2014-12-161-1/+2
| | | | | | instantiations of explicit specializations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224394 91177308-0d34-0410-b5e6-96231b3b80d8
* Warn when attribute 'optnone' conflicts with attributes on aPaul Robinson2014-12-151-3/+4
| | | | | | | different declaration of the same function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224256 91177308-0d34-0410-b5e6-96231b3b80d8
* Instead of having -Os/-Oz add OptimizeForSize/MinSize first, and laterPaul Robinson2014-12-111-2/+5
| | | | | | | | | | | | having OptimizeNone remove them again, just don't add them in the first place if the function already has OptimizeNone. Note that MinSize can still appear due to attributes on different declarations; a future patch will address that. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224047 91177308-0d34-0410-b5e6-96231b3b80d8
* IR: Update clang for Metadata/Value split in r223802Duncan P. N. Exon Smith2014-12-091-23/+19
| | | | | | Match LLVM API changes from r223802. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223803 91177308-0d34-0410-b5e6-96231b3b80d8
* InstrProf: Use LLVM's -instrprof pass for profilingJustin Bogner2014-12-081-3/+0
| | | | | | | | The logic for lowering profiling counters has been moved to an LLVM pass. Emit the intrinsics rather than duplicating the whole pass in clang. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223683 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix invalid calling convention used for libcalls on ARM.Anton Korobeynikov2014-12-021-0/+16
| | | | | | | | | | | | | | | | | | ARM ABI specifies that all the libcalls use soft FP ABI (even hard FP binaries). These days clang emits _mulsc3 / _muldc3 calls with default (C) calling convention which would be translated into AAPCS_VFP LLVM calling and thus the result of complex multiplication will be bogus. Introduce a way for a target to specify explicitly calling convention for libcalls. Right now this is temporary correctness fix. Ultimately, we'll end with intrinsic for complex multiplication and all calling convention decisions for libcalls will be put into backend. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223123 91177308-0d34-0410-b5e6-96231b3b80d8
* Use nullptr to silence -Wsentinel when self-hosting on WindowsReid Kleckner2014-12-011-1/+1
| | | | | | | | | | | Richard rejected my Sema change to interpret an integer literal zero in a varargs context as a null pointer, so -Wsentinel sees an integer literal zero and fires off a warning. Only CodeGen currently knows that it promotes integer literal zeroes in this context to pointer size on Windows. I didn't want to teach -Wsentinel about that compatibility hack. Therefore, I'm migrating to C++11 nullptr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223079 91177308-0d34-0410-b5e6-96231b3b80d8
* Add missing 'break's, found by inspection. No functionality change; theRichard Smith2014-12-011-0/+2
| | | | | | | fallthrough happened to do the right thing in both cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223064 91177308-0d34-0410-b5e6-96231b3b80d8
* Correctly remove OptimizeForSize from functions marked OptimizeNone.Paul Robinson2014-11-241-10/+15
| | | | | | | | This allows using __attribute__((optnone)) and the -Os/-Oz options. Fixes PR21604. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222683 91177308-0d34-0410-b5e6-96231b3b80d8
* Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie2014-11-191-6/+6
| | | | | | pair<iterator, bool> as per the C++ standard's associative container concept. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222335 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format a recent commit I madeDavid Blaikie2014-11-191-4/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222317 91177308-0d34-0410-b5e6-96231b3b80d8
* Standardize on StringMap::insert, removing uses of StringMap::GetOrCreateValue.David Blaikie2014-11-191-15/+15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222306 91177308-0d34-0410-b5e6-96231b3b80d8
* Add PIC-level support to Clang.Justin Hibbits2014-11-181-0/+12
| | | | | | | | | | | | | | | | | | Summary: This distinguishes between -fpic and -fPIC now, with the additions in LLVM for PIC level support. Test Plan: No regressions Reviewers: echristo, rafael Reviewed By: rafael Subscribers: rnk, emaste, llvm-commits Differential Revision: http://reviews.llvm.org/D5400 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222227 91177308-0d34-0410-b5e6-96231b3b80d8
* [Objective-C++ IRGen] do not generate .cxx_construct Fariborz Jahanian2014-11-121-1/+15
| | | | | | | | for class that contains trivially-constructible struct ivar. rdar://18950072 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221823 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "IR: MDNode => Value: Update for LLVM API change in r221375"Duncan P. N. Exon Smith2014-11-111-1/+1
| | | | | | | | This reverts commit r221376. The API change was reverted in r221711. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221712 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Codegen for threadprivate variablesAlexey Bataev2014-11-111-0/+19
| | | | | | | | | | For all threadprivate variables which have constructor/destructor emit call to void __kmpc_threadprivate_register(ident_t * <Current Location>, void *<Original Global Addr>, kmpc_ctor <Constructor>, kmpc_cctor NULL, kmpc_dtor <Destructor>); In expressions all references to such variables are replaced by calls to void *__kmpc_threadprivate_cached(ident_t *<Current Location>, kmp_int32 <Current Thread Id>, void *<Original Global Addr>, size_t <Size of Data>, void ***<Pointer to autogenerated cache – array of private copies of threadprivate variable>); Test test/OpenMP/threadprivate_codegen.cpp checks that codegen is correct. Also it checks that codegen is correct after serialization/deserialization and one of passes verifies debug info. Differential Revision: http://reviews.llvm.org/D4002 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221663 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a SanitizerKind enum to LangOptions.Alexey Samsonov2014-11-071-6/+10
| | | | | | | | | | | | | | Use the bitmask to store the set of enabled sanitizers instead of a bitfield. On the negative side, it makes syntax for querying the set of enabled sanitizers a bit more clunky. On the positive side, we will be able to use SanitizerKind to eventually implement the new semantics for -fsanitize-recover= flag, that would allow us to make some sanitizers recoverable, and some non-recoverable. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221558 91177308-0d34-0410-b5e6-96231b3b80d8
* IR: MDNode => Value: Update for LLVM API change in r221375Duncan P. N. Exon Smith2014-11-051-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221376 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't dllimport inline functions when targeting MinGW (PR21366)Hans Wennborg2014-11-031-0/+8
| | | | | | | | | | | | It turns out that MinGW never dllimports of exports inline functions. This means that code compiled with Clang would fail to link with MinGW-compiled libraries since we might try to import functions that are not imported. To fix this, make Clang never dllimport inline functions when targeting MinGW. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221154 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: Virtual dtor thunks shouldn't have this marked as 'returned'David Majnemer2014-11-011-7/+7
| | | | | | | The ARM ABI virtual destructor thunks cannot be marked as 'returned' because they return undef. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221042 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan] Improve blacklisting of global variables.Alexey Samsonov2014-10-171-1/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | This commit changes the way we blacklist global variables in ASan. Now the global is excluded from instrumentation (either regular bounds checking, or initialization-order checking) if: 1) Global is explicitly blacklisted by its mangled name. This part is left unchanged. 2) SourceLocation of a global is in blacklisted source file. This changes the old behavior, where instead of looking at the SourceLocation of a variable we simply considered llvm::Module identifier. This was wrong, as identifier may not correspond to the file name, and we incorrectly disabled instrumentation for globals coming from #include'd files. 3) Global is blacklisted by type. Now we build the type of a global variable using Clang machinery (QualType::getAsString()), instead of llvm::StructType::getName(). After this commit, the active users of ASan blacklist files may have to revisit them (this is a backwards-incompatible change). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220097 91177308-0d34-0410-b5e6-96231b3b80d8
* SanitizerBlacklist: blacklist functions by their source location.Alexey Samsonov2014-10-171-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit changes the way we blacklist functions in ASan, TSan, MSan and UBSan. We used to treat function as "blacklisted" and turned off instrumentation in it in two cases: 1) Function is explicitly blacklisted by its mangled name. This part is not changed. 2) Function is located in llvm::Module, whose identifier is contained in the list of blacklisted sources. This is completely wrong, as llvm::Module may not correspond to the actual source file function is defined in. Also, function can be defined in a header, in which case user had to blacklist the .cpp file this header was #include'd into, not the header itself. Such functions could cause other problems - for instance, if the header was included in multiple source files, compiled separately and linked into a single executable, we could end up with both instrumented and non-instrumented version of the same function participating in the same link. After this change we will make blacklisting decision based on the SourceLocation of a function definition. If a function is not explicitly defined in the source file, (for example, the function is compiler-generated and responsible for initialization/destruction of a global variable), then it will be blacklisted if the corresponding global variable is defined in blacklisted source file, and will be instrumented otherwise. After this commit, the active users of blacklist files may have to revisit them. This is a backwards-incompatible change, but I don't think it's possible or makes sense to support the old incorrect behavior. I plan to make similar change for blacklisting GlobalVariables (which is ASan-specific). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219997 91177308-0d34-0410-b5e6-96231b3b80d8
* MS Compat: mark globals emitted in read-only sections constHans Wennborg2014-10-161-0/+7
| | | | | | | | | | | | | | | | | | | | They cannot be written to, so marking them const makes sense and may improve optimisation. As a side-effect, SectionInfos has to be moved from Sema to ASTContext. It also fixes this problem, that occurs when compiling ATL: warning LNK4254: section 'ATL' (C0000040) merged into '.rdata' (40000040) with different attributes The ATL headers are putting variables in a special section that's marked read-only. However, Clang currently can't model that read-onlyness in the IR. But, by making the variables const, the section does become read-only, and the linker warning is avoided. Differential Revision: http://reviews.llvm.org/D5812 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219960 91177308-0d34-0410-b5e6-96231b3b80d8
* CodeGen: Don't drop thread_local when emitting __thread aliasesDavid Majnemer2014-10-151-8/+16
| | | | | | | | | | | | CodeGen wouldn't mark the aliasee as thread_local if the aliasee was a tentative definition. Even if the definition was already emitted, it would never mark the alias as thread_local. This fixes PR21288. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219859 91177308-0d34-0410-b5e6-96231b3b80d8
* Move SanitizerBlacklist object from CodeGenModule to ASTContext.Alexey Samsonov2014-10-151-4/+2
| | | | | | | | | Soon we'll need to have access to blacklist before the CodeGen phase (see http://reviews.llvm.org/D5687), so parse and construct the blacklist earlier. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219857 91177308-0d34-0410-b5e6-96231b3b80d8
* Move -fsanitize-blacklist to LangOpts from CodeGenOpts. NFC.Alexey Samsonov2014-10-151-1/+1
| | | | | | | | | After http://reviews.llvm.org/D5687 is submitted, we will need SanitizerBlacklist before the CodeGen phase, so make it a LangOpt (as it will actually affect ABI / class layout). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219842 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix for bug http://llvm.org/PR17427.Alexey Bataev2014-10-091-2/+3
| | | | | | | | | Assertion failed: "Computed __func__ length differs from type!" Reworked PredefinedExpr representation with internal StringLiteral field for function declaration. Differential Revision: http://reviews.llvm.org/D5365 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219393 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid code duplication by calling setAliasAttributes in EmitAliasDefinition.Rafael Espindola2014-10-081-12/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219258 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix ctor/dtor aliases losing 'dllexport' (for Itanium ABI)Dario Domizioli2014-09-191-0/+10
| | | | | | | | | This patch makes sure that the dllexport attribute is transferred to the alias when such alias is created. It only affects the Itanium ABI because for the MSVC ABI a workaround is in place to not generate aliases of dllexport ctors/dtors. A new CodeGenModule function is provided, CodeGenModule::setAliasAttributes, to factor the code for transferring attributes to aliases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218159 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for putting constructors and destructos in explicit comdats.Rafael Espindola2014-09-161-0/+4
| | | | | | | | | | | | | | | | | | There are situations when clang knows that the C1 and C2 constructors or the D1 and D2 destructors are identical. We already optimize some of these cases, but cannot optimize it when the GlobalValue is weak_odr. The problem with weak_odr is that an old TU seeing the same code will have a C1 and a C2 comdat with the corresponding symbols. We cannot suddenly start putting the C2 symbol in the C1 comdat as we cannot guarantee that the linker will not pick a .o with only C1 in it. The solution implemented by GCC is to expand the ABI to have a comdat whose name uses a C5/D5 suffix and always has both symbols. That is what this patch implements. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217874 91177308-0d34-0410-b5e6-96231b3b80d8
* Move emitCXXStructor to CGCXXABI.Rafael Espindola2014-09-151-2/+2
| | | | | | A followup patch will address the code duplication. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217807 91177308-0d34-0410-b5e6-96231b3b80d8
* Create a emitCXXStructor function and make the existing emitCXXConstructor andRafael Espindola2014-09-151-2/+2
| | | | | | | | emitCXXDestructor static helpers. A next patch will make it a helper in CGCXXABI. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217804 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove a parameter that has been unused since r188481. No behavior change.Nico Weber2014-09-081-3/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217386 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a comment for something that confused me.Nico Weber2014-09-081-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217384 91177308-0d34-0410-b5e6-96231b3b80d8