aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
AgeCommit message (Collapse)AuthorFilesLines
2014-01-21Use private linkage for utf-16 objc strings too.Rafael Espindola1-9/+2
llvm-svn: 199709
2014-01-21Now that r199688 avoids the real issue, use private linkage for objc strings.Rafael Espindola1-5/+2
llvm-svn: 199705
2014-01-20Give explicit sections for string constants used in NSStrings.Rafael Espindola1-0/+5
Without them they can be merged with non unnamed_addr constants during LTO. The resulting constant is not unnamed_addr and goes in a different section, which causes ld64 to crash. A testcase that would crash before: * file1.mm: void g(id notification) { [notification valueForKey:@"name"]; } * file2.cpp: extern const char js_name_str[] = "name"; * file3.cpp extern bool JS_GetProperty(const char *name); extern const char js_name_str[]; bool js_ReportUncaughtException() { JS_GetProperty(js_name_str); } run clang file1.mm -o file1.o -c -w -emit-llvm clang file2.cpp -o file2.o -c -w -emit-llvm clang file3.cpp -o file3.o -c -w ld -dylib -o XUL file1.o file2.o file3.o -undefined dynamic_lookup. llvm-svn: 199688
2014-01-20Simplify further.Rafael Espindola1-7/+5
Thanks to David Blaikie for the push. llvm-svn: 199685
2014-01-20Remove virtual methods that were added in 2009 and still had 1 implementation.Rafael Espindola1-7/+9
llvm-svn: 199665
2014-01-14Update CodeGen to use DLL storage class for dllimport/dllexportNico Rieck1-9/+17
With the old linkage types removed, set the linkage to external for both dllimport and dllexport to reflect what's currently supported. llvm-svn: 199220
2014-01-07Remove unused include.Rafael Espindola1-1/+0
llvm-svn: 198692
2014-01-07Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth1-1/+1
encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. llvm-svn: 198686
2014-01-06CodeGen: Initial instrumentation based PGO implementationJustin Bogner1-1/+10
llvm-svn: 198640
2013-12-28Tidy up CGCXXABI creationAlp Toker1-5/+4
'create' functions conventionally return a pointer, not a reference. Also use an OwningPtr to get replace the delete of a reference member. No functional change. llvm-svn: 198126
2013-12-19Switched code from using hasAttr followed by getAttr to simply call getAttr ↵Aaron Ballman1-2/+1
directly and check the resulting value. No functional changes intended. llvm-svn: 197652
2013-12-19Replacing calls to getAttr with calls to hasAttr for clarity. No functional ↵Aaron Ballman1-4/+4
change intended -- this only replaces Boolean uses of getAttr. llvm-svn: 197648
2013-12-17ASTContext: Refactor implicit record creationAlp Toker1-16/+2
Tidy up built-in record creation to reduce code duplication. Continuation of r197336. llvm-svn: 197452
2013-12-11[ms-cxxabi] Fix linkage of dtor thunks for anonymous classesReid Kleckner1-6/+8
We were mistakengly giving linkonce_odr linkage instead of internal linkage to the deleting and complete destructor thunks for classes in anonymous namespaces. Fixes PR17273. llvm-svn: 197060
2013-12-09Save another call to GetAddrOfFunction.Rafael Espindola1-6/+8
Thread an optional GV down to EmitGlobalFunctionDefinition so that it can avoid the lookup when we already know the corresponding llvm global value. llvm-svn: 196789
2013-12-09When we decide to output a deferred decl, remember the llvm GlobalValue.Rafael Espindola1-23/+24
We can reuse it to avoid a DenseMap+StringMap lookup to find if it was already emitted or not. This fixes a 2010 TODO. llvm-svn: 196785
2013-12-09Avoid adding some decls to DeferredDeclsToEmit.Rafael Espindola1-57/+66
Before this patch GetOrCreateLLVMFunction would add a decl to DeferredDeclsToEmit even when it was being called by the function trying to emit that decl. llvm-svn: 196753
2013-12-08GlobalAlias::isDeclaration is always false. Remove dead code.Rafael Espindola1-5/+0
llvm-svn: 196727
2013-12-02Debug Info: Move the constant for Debug Info Version from Dwarf.h to Metadata.h.Manman Ren1-1/+1
Suggested by Eric. Paired commit with r196144. llvm-svn: 196145
2013-12-02Expand comments for Debug Info Version.Manman Ren1-1/+4
llvm-svn: 196143
2013-11-23[CodeGen] If there is a function definition with duplicate mangled name, ↵Argyrios Kyrtzidis1-0/+4
emit an error instead of asserting. rdar://15522601 & http://llvm.org/PR18031 llvm-svn: 195556
2013-11-22Debug Info: add a "Debug Info Version" module flag to output the current debugManman Ren1-0/+5
info version number. Will error out when modules have different version numbers. llvm-svn: 195495
2013-11-21[-cxx-abi microsoft] Emit linkonce_odr definitions for declarations of ↵Hans Wennborg1-0/+15
static data members with inline initializers (PR17689) This makes Clang emit a linkonce_odr definition for 'val' in the code below, to be compatible with MSVC-compiled code: struct Foo { static const int val = 1; }; Differential Revision: http://llvm-reviews.chandlerc.com/D2233 llvm-svn: 195283
2013-11-15Fix test failures after addrspacecast added.Matt Arsenault1-4/+8
Bitcasts between address spaces are no longer allowed. llvm-svn: 194765
2013-11-14[OpenCL] Make sure we put string literals in the constant address space.Joey Gouly1-4/+9
llvm-svn: 194717
2013-11-12Keep the old function order in CodeGenModule::applyReplacements.Rafael Espindola1-2/+16
The original decls are created when used. The replacements are created at the end of the TU in reverse order. This makes the original order far better for testing. This is particularly important since the replacement logic could be used even when -mconstructor-aliases is not used, but that would make many tests hard to read. This is a fixed version of r194357 which handles replacing a destructor with another which is an alias to a third one. llvm-svn: 194452
2013-11-11Revert "Keep the old function order in CodeGenModule::applyReplacements."Rafael Espindola1-14/+2
This reverts commit r194357. Debugging a cast failure during bootstrap. llvm-svn: 194358
2013-11-10Keep the old function order in CodeGenModule::applyReplacements.Rafael Espindola1-2/+14
The original decls are created when used. The replacements are created at the end of the TU in reverse order. This makes the original order far better for testing. This is particularly important since the replacement logic could be used even when -mconstructor-aliases is not used, but that would make many tests hard to read. llvm-svn: 194357
2013-11-10Avoid double StringMap lookups. No functionality change.Benjamin Kramer1-4/+4
llvm-svn: 194355
2013-11-05Produce direct calls instead of alias to linkonce_odr functions.Rafael Espindola1-0/+15
This is a small optimization on linux, but should help more on windows where msvc only outputs one destructor if there would be two identical ones. llvm-svn: 194095
2013-11-05C++1y sized deallocation: if we have a use, but not a definition, of a sizedRichard Smith1-0/+6
deallocation function (and the corresponding unsized deallocation function has been declared), emit a weak discardable definition of the function that forwards to the corresponding unsized deallocation. This allows a C++ standard library implementation to provide both a sized and an unsized deallocation function, where the unsized one does not just call the sized one, for instance by putting both in the same object file within an archive. llvm-svn: 194055
2013-10-22New fix for pr17535.Rafael Espindola1-0/+37
This is a fixed version of r193161. In order to handle void foo() __attribute__((alias("bar"))); void bar() {} void zed() __attribute__((alias("foo"))); it is not enough to delay aliases to the end of the TU, we have to do two passes over them to find if they are defined or not. This can be implemented by producing alias as we go and just doing the second pass at the end. This has the advantage that other parts of clang that were expecting alias to be processed in order don't have to be changed. This patch also handles cyclic aliases. llvm-svn: 193188
2013-10-22Revert "This patch causes clang to reject alias attributes that point to ↵Rafael Espindola1-38/+1
undefined names. For example, with this patch we now reject" This reverts commit r193161. It broke void foo() __attribute__((alias("bar"))); void bar() {} void zed() __attribute__((alias("foo"))); Looks like we have to fix pr17639 first :-( llvm-svn: 193162
2013-10-22This patch causes clang to reject alias attributes that point to undefinedRafael Espindola1-1/+38
names. For example, with this patch we now reject void f1(void) __attribute__((alias("g1"))); This patch is implemented in CodeGen. It is quiet a bit simpler and more compatible with gcc than implementing it in Sema. The downside is that the errors only fire during -emit-llvm. llvm-svn: 193161
2013-10-17Rename some functions for consistency.Rafael Espindola1-1/+1
Every other function in Redeclarable.h was using Decl instead of Declaration. llvm-svn: 192900
2013-10-16Emit a .ident saying that clang produced this file.Rafael Espindola1-0/+15
Patch by Katya Romanova. llvm-svn: 192832
2013-10-08TBAA: use the same format for scalar TBAA and struct-path aware TBAA.Manman Ren1-4/+4
An updated version of r191586 with bug fix. Struct-path aware TBAA generates tags to specify the access path, while scalar TBAA only generates tags to scalar types. We should not generate a TBAA tag with null being the first field. When a TBAA type node is null, the tag should be null too. Make sure we don't decorate an instruction with a null TBAA tag. Added a testing case for the bug reported by Richard with -relaxed-aliasing and -fsanitizer=thread. llvm-svn: 192145
2013-10-01Revert r191586 and r191695. They cause crashes when building withRichard Smith1-4/+4
-relaxed-aliasing. llvm-svn: 191725
2013-09-27TBAA: use the same format for scalar TBAA and struct-path aware TBAA.Manman Ren1-4/+4
Struct-path aware TBAA generates tags to specify the access path, while scalar TBAA only generates tags to scalar types. llvm-svn: 191586
2013-09-04Do not emit duplicate global initializers for template static data members ↵David Blaikie1-1/+6
inside namespaces A quirk of AST representation leads to class template static data member definitions being visited twice during Clang IRGen resulting in duplicate (benign) initializers. Discovered while investigating a possibly-related debug info bug tickled by the duplicate emission of these members & their associated debug info. With thanks to Richard Smith for help investigating, understanding, and helping with the fix. llvm-svn: 189996
2013-09-03Emit uuid globals as linkonce_odrReid Kleckner1-1/+1
Patch by Nico Rieck! llvm-svn: 189860
2013-08-23Use pop_back_val() instead of both back() and pop_back().Robert Wilhelm1-2/+1
No functionality change intended. llvm-svn: 189112
2013-08-19PR16933: Don't try to codegen things after we've seen errors.David Blaikie1-14/+2
Refactor the underlying code a bit to remove unnecessary calls to "hasErrorOccurred" & make them consistently at all the entry points to the IRGen ASTConsumer. llvm-svn: 188707
2013-08-15CodeGen: __uuidof should work even with an incomplete _GUID typeDavid Majnemer1-36/+21
Summary: We would crash in CodeGen::CodeGenModule::EmitUuidofInitializer because our attempt to enter CodeGen::CodeGenModule::EmitConstantValue will be foiled: the type of the constant value is incomplete. Instead, create an unnamed type with the proper layout on all platforms. Punt the problem of wrongly defined struct _GUID types to the user. (It's impossible because the TU may never get to see the type and thus we can't verify that it is suitable.) This fixes PR16856. Reviewers: rsmith, rnk, thakis Reviewed By: rnk CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1375 llvm-svn: 188481
2013-08-13[-cxx-abi microsoft] Mangle __uuidof correctly into template parametersDavid Majnemer1-11/+1
Summary: It seems that __uuidof introduces a global extern "C" declaration of type __s_GUID. However, our implementation of __uuidof does not provide such a declaration and thus must open-code the mangling for __uuidof in template parameters. This allows us to codegen scoped COM pointers and other such things. This fixes PR16836. Depends on D1356. Reviewers: rnk, cdavis5x, rsmith Reviewed By: rnk CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1357 llvm-svn: 188252
2013-08-12Use new llvm::SpecialCaseList API in CodeGenModuleAlexey Samsonov1-17/+15
llvm-svn: 188170
2013-08-09[-cxx-abi microsoft] Mangle UUIDs correctly, stick them in the proper sectionDavid Majnemer1-2/+3
Revert r188055 which reverted r188053. An unrelated change previously snuck in. llvm-svn: 188060
2013-08-09Revert "[-cxx-abi microsoft] Mangle UUIDs correctly, stick them in the ↵David Majnemer1-3/+2
proper section" This commit reverts r188053. It is breaking the build bots. llvm-svn: 188055
2013-08-09[-cxx-abi microsoft] Mangle UUIDs correctly, stick them in the proper sectionDavid Majnemer1-2/+3
We mangled them like: L___uuid_12345678-1234-1234-1234-123456789abc We should've mangled them like: __GUID_12345678_1234_1234_1234_123456789abc Furthermore, they are external symbols. llvm-svn: 188053
2013-08-06Started implementing variable templates. Top level declarations should be ↵Larisse Voufo1-1/+7
fully supported, up to some limitations documented as FIXMEs or TODO. Static data member templates work very partially. Static data member templates of class templates need particular attention... llvm-svn: 187762