summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
AgeCommit message (Collapse)Author
2015-01-10Don't emit implicit template instantiations eagerly (PR21718)Hans Wennborg
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
2014-12-16PR21909: Don't try (and crash) to generate debug info for explicit ↵David Blaikie
instantiations of explicit specializations. llvm-svn: 224394
2014-12-15Warn when attribute 'optnone' conflicts with attributes on aPaul Robinson
different declaration of the same function. llvm-svn: 224256
2014-12-11Instead of having -Os/-Oz add OptimizeForSize/MinSize first, and laterPaul Robinson
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
2014-12-09IR: Update clang for Metadata/Value split in r223802Duncan P. N. Exon Smith
Match LLVM API changes from r223802. llvm-svn: 223803
2014-12-08InstrProf: Use LLVM's -instrprof pass for profilingJustin Bogner
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
2014-12-02Fix invalid calling convention used for libcalls on ARM.Anton Korobeynikov
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
2014-12-01Use nullptr to silence -Wsentinel when self-hosting on WindowsReid Kleckner
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
2014-12-01Add missing 'break's, found by inspection. No functionality change; theRichard Smith
fallthrough happened to do the right thing in both cases. llvm-svn: 223064
2014-11-24Correctly remove OptimizeForSize from functions marked OptimizeNone.Paul Robinson
This allows using __attribute__((optnone)) and the -Os/-Oz options. Fixes PR21604. llvm-svn: 222683
2014-11-19Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie
pair<iterator, bool> as per the C++ standard's associative container concept. llvm-svn: 222335
2014-11-19clang-format a recent commit I madeDavid Blaikie
llvm-svn: 222317
2014-11-19Standardize on StringMap::insert, removing uses of StringMap::GetOrCreateValue.David Blaikie
llvm-svn: 222306
2014-11-18Add PIC-level support to Clang.Justin Hibbits
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
2014-11-12[Objective-C++ IRGen] do not generate .cxx_construct Fariborz Jahanian
for class that contains trivially-constructible struct ivar. rdar://18950072 llvm-svn: 221823
2014-11-11Revert "IR: MDNode => Value: Update for LLVM API change in r221375"Duncan P. N. Exon Smith
This reverts commit r221376. The API change was reverted in r221711. llvm-svn: 221712
2014-11-11[OPENMP] Codegen for threadprivate variablesAlexey Bataev
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
2014-11-07Introduce a SanitizerKind enum to LangOptions.Alexey Samsonov
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
2014-11-05IR: MDNode => Value: Update for LLVM API change in r221375Duncan P. N. Exon Smith
llvm-svn: 221376
2014-11-03Don't dllimport inline functions when targeting MinGW (PR21366)Hans Wennborg
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
2014-11-01CodeGen: Virtual dtor thunks shouldn't have this marked as 'returned'David Majnemer
The ARM ABI virtual destructor thunks cannot be marked as 'returned' because they return undef. llvm-svn: 221042
2014-10-17[ASan] Improve blacklisting of global variables.Alexey Samsonov
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
2014-10-17SanitizerBlacklist: blacklist functions by their source location.Alexey Samsonov
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
2014-10-16MS Compat: mark globals emitted in read-only sections constHans Wennborg
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
2014-10-15CodeGen: Don't drop thread_local when emitting __thread aliasesDavid Majnemer
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
2014-10-15Move SanitizerBlacklist object from CodeGenModule to ASTContext.Alexey Samsonov
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
2014-10-15Move -fsanitize-blacklist to LangOpts from CodeGenOpts. NFC.Alexey Samsonov
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
2014-10-09Fix for bug http://llvm.org/PR17427.Alexey Bataev
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
2014-10-08Avoid code duplication by calling setAliasAttributes in EmitAliasDefinition.Rafael Espindola
llvm-svn: 219258
2014-09-19Fix ctor/dtor aliases losing 'dllexport' (for Itanium ABI)Dario Domizioli
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
2014-09-16Add support for putting constructors and destructos in explicit comdats.Rafael Espindola
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
2014-09-15Move emitCXXStructor to CGCXXABI.Rafael Espindola
A followup patch will address the code duplication. llvm-svn: 217807
2014-09-15Create a emitCXXStructor function and make the existing emitCXXConstructor andRafael Espindola
emitCXXDestructor static helpers. A next patch will make it a helper in CGCXXABI. llvm-svn: 217804
2014-09-08Remove a parameter that has been unused since r188481. No behavior change.Nico Weber
llvm-svn: 217386
2014-09-08Add a comment for something that confused me.Nico Weber
llvm-svn: 217384
2014-08-29Better codegen support for DLL attributes being dropped after the first ↵Hans Wennborg
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
2014-08-08Add a cc1 "dump-coverage-mapping" for testing coverage mapping.Alex Lorenz
Differential Revision: http://reviews.llvm.org/D4799 llvm-svn: 215258
2014-08-05MS ABI: Aligned tentative definitions don't have CommonLinkageDavid Majnemer
int __declspec(align(16)) foo; is a tentative definition but the storage for that variable should not have CommonLinkage. llvm-svn: 214828
2014-08-04Add coverage mapping generation.Alex Lorenz
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
2014-08-02In the case of mangling collisions, make an attempt to note both definitionsRichard Smith
involved. llvm-svn: 214606
2014-08-01Actually fix problem with modules buildbot this time.Richard Smith
llvm-svn: 214579
2014-08-01[Sanitizer] Introduce SanitizerMetadata class.Alexey Samsonov
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
2014-08-01Re-commit r214547 with tests fixed. Hopefully all the bots will be happy now.Richard Smith
Original message: Fix iterator invalidation issues that are breaking my modules buildbot's bootstrap. llvm-svn: 214555
2014-08-01Revert r214547 due to test breakage.Richard Smith
llvm-svn: 214549
2014-08-01Fix iterator invalidation issues that are breaking my modules buildbot's ↵Richard Smith
bootstrap. llvm-svn: 214547
2014-08-01[modules] Remove IRGen special case for emitting implicit special members ifRichard Smith
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
2014-07-29PR20473: Don't "deduplicate" string literals with the same value but differentRichard Smith
lengths! In passing, simplify string literal deduplication by relying on LLVM to deduplicate the underlying constant values. llvm-svn: 214222
2014-07-18Make sure globals created by UBSan are not instrumented by ASan.Alexey Samsonov
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
2014-07-17MS compatibility: always emit dllexported in-class initialized static data ↵Hans Wennborg
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
2014-07-12[ASan] Collect unmangled names of global variables in Clang to print them in ↵Alexey Samsonov
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