summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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 llvm-svn: 225570
* PR21909: Don't try (and crash) to generate debug info for explicit ↵David Blaikie2014-12-161-1/+2
| | | | | | instantiations of explicit specializations. llvm-svn: 224394
* Warn when attribute 'optnone' conflicts with attributes on aPaul Robinson2014-12-151-3/+4
| | | | | | different declaration of the same function. llvm-svn: 224256
* 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. llvm-svn: 224047
* IR: Update clang for Metadata/Value split in r223802Duncan P. N. Exon Smith2014-12-091-23/+19
| | | | | | Match LLVM API changes from r223802. llvm-svn: 223803
* 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. llvm-svn: 223683
* 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. llvm-svn: 223123
* 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. llvm-svn: 223079
* 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. llvm-svn: 223064
* 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. llvm-svn: 222683
* 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. llvm-svn: 222335
* clang-format a recent commit I madeDavid Blaikie2014-11-191-4/+4
| | | | llvm-svn: 222317
* Standardize on StringMap::insert, removing uses of StringMap::GetOrCreateValue.David Blaikie2014-11-191-15/+15
| | | | llvm-svn: 222306
* 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 llvm-svn: 222227
* [Objective-C++ IRGen] do not generate .cxx_construct Fariborz Jahanian2014-11-121-1/+15
| | | | | | | for class that contains trivially-constructible struct ivar. rdar://18950072 llvm-svn: 221823
* 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. llvm-svn: 221712
* [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 llvm-svn: 221663
* 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. llvm-svn: 221558
* IR: MDNode => Value: Update for LLVM API change in r221375Duncan P. N. Exon Smith2014-11-051-1/+1
| | | | llvm-svn: 221376
* 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. llvm-svn: 221154
* 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. llvm-svn: 221042
* [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). llvm-svn: 220097
* 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). llvm-svn: 219997
* 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 llvm-svn: 219960
* 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. llvm-svn: 219859
* 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. llvm-svn: 219857
* 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). llvm-svn: 219842
* 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 llvm-svn: 219393
* Avoid code duplication by calling setAliasAttributes in EmitAliasDefinition.Rafael Espindola2014-10-081-12/+3
| | | | llvm-svn: 219258
* 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. llvm-svn: 218159
* 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. llvm-svn: 217874
* Move emitCXXStructor to CGCXXABI.Rafael Espindola2014-09-151-2/+2
| | | | | | A followup patch will address the code duplication. llvm-svn: 217807
* 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. llvm-svn: 217804
* Remove a parameter that has been unused since r188481. No behavior change.Nico Weber2014-09-081-3/+2
| | | | llvm-svn: 217386
* Add a comment for something that confused me.Nico Weber2014-09-081-0/+1
| | | | llvm-svn: 217384
* Better codegen support for DLL attributes being dropped after the first ↵Hans Wennborg2014-08-291-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | declaration (PR20792) For the following code: __declspec(dllimport) int f(int x); int user(int x) { return f(x); } int f(int x) { return 1; } Clang will drop the dllimport attribute in the AST, but CodeGen would have already put it on the LLVM::Function, and that would never get updated. (The same thing happens for global variables.) This makes Clang check dropped DLL attribute case each time the LLVM object is referenced. This isn't perfect, because we will still get it wrong if the function is never referenced by codegen after the attribute is dropped, but this handles the common cases and makes us not fail in the verifier. llvm-svn: 216699
* Add a cc1 "dump-coverage-mapping" for testing coverage mapping.Alex Lorenz2014-08-081-1/+11
| | | | | | Differential Revision: http://reviews.llvm.org/D4799 llvm-svn: 215258
* MS ABI: Aligned tentative definitions don't have CommonLinkageDavid Majnemer2014-08-051-2/+10
| | | | | | | int __declspec(align(16)) foo; is a tentative definition but the storage for that variable should not have CommonLinkage. llvm-svn: 214828
* Add coverage mapping generation.Alex Lorenz2014-08-041-1/+88
| | | | | | | | | | This patch adds the '-fcoverage-mapping' option which allows clang to generate the coverage mapping information that can be used to provide code coverage analysis using the execution counts obtained from the instrumentation based profiling (-fprofile-instr-generate). llvm-svn: 214752
* In the case of mangling collisions, make an attempt to note both definitionsRichard Smith2014-08-021-6/+8
| | | | | | involved. llvm-svn: 214606
* Actually fix problem with modules buildbot this time.Richard Smith2014-08-011-1/+1
| | | | llvm-svn: 214579
* [Sanitizer] Introduce SanitizerMetadata class.Alexey Samsonov2014-08-011-69/+4
| | | | | | | | | | | | | | It is responsible for generating metadata consumed by sanitizer instrumentation passes in the backend. Move several methods from CodeGenModule to SanitizerMetadata. For now the class is stateless, but soon it won't be the case. Instead of creating globals providing source-level information to ASan, we will create metadata nodes/strings which will be turned into actual global variables in the backend (if needed). No functionality change. llvm-svn: 214564
* Re-commit r214547 with tests fixed. Hopefully all the bots will be happy now.Richard Smith2014-08-011-3/+10
| | | | | | | | | Original message: Fix iterator invalidation issues that are breaking my modules buildbot's bootstrap. llvm-svn: 214555
* Revert r214547 due to test breakage.Richard Smith2014-08-011-10/+3
| | | | llvm-svn: 214549
* Fix iterator invalidation issues that are breaking my modules buildbot's ↵Richard Smith2014-08-011-3/+10
| | | | | | bootstrap. llvm-svn: 214547
* [modules] Remove IRGen special case for emitting implicit special members ifRichard Smith2014-08-011-13/+5
| | | | | | | | | | | they're somehow missing a body. Looks like this was left behind when the loop was generalized, and it's not been problematic before because without modules, a used, implicit special member function declaration must be a definition. This was resulting in us trying to emit a constructor declaration rather than a definition, and producing a constructor missing its member initializers. llvm-svn: 214473
* PR20473: Don't "deduplicate" string literals with the same value but differentRichard Smith2014-07-291-31/+12
| | | | | | | lengths! In passing, simplify string literal deduplication by relying on LLVM to deduplicate the underlying constant values. llvm-svn: 214222
* Make sure globals created by UBSan are not instrumented by ASan.Alexey Samsonov2014-07-181-2/+9
| | | | | | | | | | | | | | | | | | | | | | Summary: This change adds description of globals created by UBSan instrumentation (UBSan handlers, type descriptors, filenames) to llvm.asan.globals metadata, effectively "blacklisting" them. This can dramatically decrease the data section in binaries built with UBSan+ASan, as UBSan tends to create a lot of handlers, and ASan instrumentation increases the global size to at least 64 bytes. Test Plan: clang regression test suite Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits, byoungyoung, kcc Differential Revision: http://reviews.llvm.org/D4575 llvm-svn: 213392
* MS compatibility: always emit dllexported in-class initialized static data ↵Hans Wennborg2014-07-171-27/+4
| | | | | | | | | | | | | | members (PR20140) This makes us emit dllexported in-class initialized static data members (which are treated as definitions in MSVC), even when they're not referenced. It also makes their special linkage reflected in the GVA linkage instead of getting massaged in CodeGen. Differential Revision: http://reviews.llvm.org/D4563 llvm-svn: 213304
* [ASan] Collect unmangled names of global variables in Clang to print them in ↵Alexey Samsonov2014-07-121-14/+28
| | | | | | | | | | | | | | | | | error reports. Currently ASan instrumentation pass creates a string with global name for each instrumented global (to include global names in the error report). Global name is already mangled at this point, and we may not be able to demangle it at runtime (e.g. there is no __cxa_demangle on Android). Instead, create a string with fully qualified global name in Clang, and pass it to ASan instrumentation pass in llvm.asan.globals metadata. If there is no metadata for some global, ASan will use the original algorithm. This fixes https://code.google.com/p/address-sanitizer/issues/detail?id=264. llvm-svn: 212872
OpenPOWER on IntegriCloud