aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
AgeCommit message (Collapse)AuthorFilesLines
2015-05-20Use Intrinsic::ID instead of unsigned. NFC.Pete Cooper1-3/+2
This is after LLVM r237810 which made Function::getIntrinsicID() return an Intrinsic::ID. llvm-svn: 237811
2015-05-15[modules] Add local submodule visibility support for declarations.Richard Smith1-1/+1
With this change, enabling -fmodules-local-submodule-visibility results in name visibility rules being applied to submodules of the current module in addition to imported modules (that is, names no longer "leak" between submodules of the same top-level module). This also makes it much safer to textually include a non-modular library into a module: each submodule that textually includes that library will get its own "copy" of that library, and so the library becomes visible no matter which including submodule you import. llvm-svn: 237473
2015-05-15Implement no_sanitize attribute.Peter Collingbourne1-17/+0
Differential Revision: http://reviews.llvm.org/D9631 llvm-svn: 237463
2015-05-09Revert r236879, "Do not emit thunks with available_externally linkage in ↵NAKAMURA Takumi1-12/+11
comdats" It broke pecoff, at least i686-cygwin. llvm-svn: 236937
2015-05-08Do not emit thunks with available_externally linkage in comdatsDerek Schuff1-11/+12
Functions with available_externally linkage will not be emitted to object files (they will just be undefined symbols), so it does not make sense to put them in comdats. Creates a second overload of maybeSetTrivialComdat that uses the GlobalObject instead of the Decl, and uses that in several places that had the faulty logic. Differential Revision: http://reviews.llvm.org/D9580 llvm-svn: 236879
2015-05-07[cuda] Include GPU binary into host object file and generate init/deinit code.Artem Belevich1-1/+7
- added -fcuda-include-gpubinary option to incorporate results of device-side compilation into host-side one. - generate code to register GPU binaries and associated kernels with CUDA runtime and clean-up on exit. - added test case for init/deinit code generation. Differential Revision: http://reviews.llvm.org/D9507 llvm-svn: 236765
2015-05-07[opaque pointer type] Correctly pass the pointee type when creating a GEP ↵David Blaikie1-1/+2
constant expression llvm-svn: 236751
2015-04-29[opaque pointer type] update for LLVM API changeDavid Blaikie1-1/+1
llvm-svn: 236161
2015-04-29Revert code changes made under r235976.Bradley Smith1-17/+0
This issue was fixed elsewhere in r235396 in a more general way, hence these changes no longer do anything. Keep the testcase however, to ensure that we don't regress this for ARM. llvm-svn: 236104
2015-04-28[ARM/AArch64] Enforce alignment for bitfielded structsBradley Smith1-0/+17
When creating a global variable with a type of a struct with bitfields, we must forcibly set the alignment of the global from the RecordDecl. We must do this so that the proper bitfield alignment makes its way down to LLVM, since clang will mangle the bitfields into one large type. llvm-svn: 235976
2015-04-27[cuda] treat file scope __asm as __host__ and ignore it during device-side ↵Artem Belevich1-0/+3
compilation. Currently clang emits file-scope asm during *both* host and device compilation modes which is usually a wrong thing to do. There's no way to attach any attribute to an __asm statement, so there's no way to differentiate between host-side and device-side file-scope asm. This patch makes clang to match nvcc behavior and emit file-scope-asm only during host-side compilation. Differential Revision: http://reviews.llvm.org/D9270 llvm-svn: 235905
2015-04-21Provide alignment info on LLVM external symbolsUlrich Weigand1-0/+2
Code in CodeGenModule::GetOrCreateLLVMGlobal that sets up GlobalValue object for LLVM external symbols has this comment: // FIXME: This code is overly simple and should be merged with other global // handling. One part does seems to be "overly simple" currently is that this code never sets any alignment info on the GlobalValue, so that the emitted IR does not have any align attribute on external globals. This can lead to unnecessarily inefficient code generation. This patch adds a GV->setAlignment call to set alignment info. llvm-svn: 235396
2015-04-15Don't crash when a selectany symbol would get common linkageNico Weber1-2/+7
Things can't both be in comdats and have common linkage, so never give things in comdats common linkage. Common linkage is only used in .c files, and the only thing that can trigger a comdat in c is selectany from what I can tell. Fixes PR23243. Also address an over-the-shoulder review comment from rnk by moving the hasAttr<SelectAnyAttr>() in Decl.cpp around a bit. It only makes a minor difference for selectany on global variables, so it goes well with the rest of this patch. http://reviews.llvm.org/D9042 llvm-svn: 235053
2015-04-15Revert "[CodeGen] Fix crash with duplicated mangled name."Renato Golin1-9/+8
This reverts commit r234767, as it was breaking all ARM buildbots for two days and the assert is not in the code, making it difficult to spot the error, which would keep the bots red for a few more days. New errors were silently introduced because of this bug, and we don't want this to escalate. llvm-svn: 234983
2015-04-15Change range-based for-loops to be -Wrange-loop-analysis clean.Richard Trieu1-1/+1
No functionality change. llvm-svn: 234964
2015-04-13[CodeGen] Fix crash with duplicated mangled name.Argyrios Kyrtzidis1-8/+9
Patch by Yunzhong Gao! llvm-svn: 234767
2015-04-06Don't crash when passing a non-existent file to -fprofile-instr-use=.Nico Weber1-2/+2
Fixes a regression from r229434. llvm-svn: 234141
2015-04-05clang-format my last commitDavid Blaikie1-16/+13
(sorry, keep forgetting that) llvm-svn: 234129
2015-04-05[opaque pointer type] More GEP API migrationsDavid Blaikie1-9/+8
Looks like the VTable code in particular will need some work to pass around the pointee type explicitly. llvm-svn: 234128
2015-04-02[opaque pointer type] Update for GEP API changes in LLVMDavid Blaikie1-5/+6
Now the GEP constant utility functions require the type to be explicitly passed (since eventually the pointer type will be opaque and not convey the required type information). For now callers can still pass nullptr (though none were needed here in Clang, which is nice) if convenienc/necessary, but eventually that will be disallowed as well. llvm-svn: 233937
2015-03-30DebugInfo: Use new LLVM API for DebugLocDuncan P. N. Exon Smith1-1/+1
Use the new API for `DebugLoc` added in r233573 before the old one disappears. llvm-svn: 233589
2015-03-29[MS ABI] Rework .xdata HandlerType emissionDavid Majnemer1-3/+3
Utilizing IMAGEREL relocations for synthetic IR constructs isn't valuable, just clutter. While we are here, simplify HandlerType names by making the numeric value for the 'adjective' part of the mangled name instead of appending '.const', etc. The old scheme made for very long global names and leads to wordy things like '.std_bad_alloc' llvm-svn: 233503
2015-03-20C++14: Disable sized deallocation by default due to ABI breakageReid Kleckner1-10/+0
There are no widely deployed standard libraries providing sized deallocation functions, so we have to punt and ask the user if they want us to use sized deallocation. In the future, when such libraries are deployed, we can teach the driver to detect them and enable this feature. N3536 claimed that a weak thunk from sized to unsized deallocation could be emitted to avoid breaking backwards compatibility with standard libraries not providing sized deallocation. However, this approach and other variations don't work in practice. With the weak function approach, the thunk has to have default visibility in order to ensure that it is overridden by other DSOs providing sized deallocation. Weak, default visibility symbols are particularly expensive on MachO, so John McCall was considering disabling this feature by default on Darwin. It also changes behavior ELF linking behavior, causing certain otherwise unreferenced object files from an archive to be pulled into the link. Our second approach was to use an extern_weak function declaration and do an inline conditional branch at the deletion call site. This doesn't work because extern_weak only works on MachO if you have some archive providing the default value of the extern_weak symbol. Arranging to provide such an archive has the same challenges as providing the symbol in the standard library. Not to mention that extern_weak doesn't really work on COFF. Reviewers: rsmith, rjmccall Differential Revision: http://reviews.llvm.org/D8467 llvm-svn: 232788
2015-03-19Remove .CUDAIsDevice flags from CodeGenOpts as it's alreadyArtem Belevich1-2/+2
available in LangOpts. Differential Revision: http://reviews.llvm.org/D8385 llvm-svn: 232749
2015-03-18MS ABI: Don't try to emit VF/VB-Tables for extern class templatesDavid Majnemer1-1/+2
There will be an explicit template instantiation in another translation unit which will provide the definition of the VF/VB-Tables. This fixes PR22932. llvm-svn: 232680
2015-03-18[OPENMP] Fix crash on code emitting if errors are found.Alexey Bataev1-0/+2
Codegen for threadprivate variables (and in some other cases) may cause crash of the compiler if some diagnostic is produced later. This happens because some of the autogenerated globals are not removed from InternalVars StringMap when llvm::Module is reset. Differential Revision: http://reviews.llvm.org/D8360 llvm-svn: 232610
2015-03-17MS ABI: Emit HandlerMap entries for C++ catchDavid Majnemer1-2/+4
The HandlerMap describes, to the runtime, what sort of catches surround the try. In principle, this structure has to be emitted by the backend because only it knows the layout of the stack (the runtime needs to know where on the stack the destination of a copy lives, etc.) but there is some C++ specific information that the backend can't reason about. Stick this information in special LLVM globals with the relevant "const", "volatile", "reference" info mangled into the name. llvm-svn: 232538
2015-03-17WIPDavid Majnemer1-1/+5
llvm-svn: 232537
2015-03-15MS ABI: Don't use qualified pointee types for 'catch' EH TypeDescriptorsDavid Majnemer1-1/+1
Qualifiers are located next to the TypeDescriptor in order to properly ensure that a pointer type can only be caught by a more qualified catch handler. This means that a catch handler of type 'const int *' requires an RTTI object for 'int *'. We got this correct for 'throw' but not for 'catch'. N.B. We don't currently have the means to store the qualifiers because LLVM's EH strategy is tailored to the Itanium scheme. The Itanium ABI stores qualifiers inside the type descriptor in such a way that the manner of qualification is stored in addition to the pointee type's descriptor. Perhaps the best way of modeling this for the MS ABI is using an aggregate type to bundle the qualifiers with the descriptor? This is tricky because we want to make it clear to the optimization passes which catch handlers invalidate other handlers. My current thoughts on a design for this is along the lines of: { { TypeDescriptor* TD, i32 QualifierFlags }, i32 MiscFlags } The idea is that the inner most aggregate is all that is needed to communicate that one catch handler might supercede another. The 'MiscFlags' field would be used to hold the bitpattern for the notion that the 'catch' handler does not need to invoke a copy-constructor because we are catching by reference. llvm-svn: 232318
2015-03-13Simplify.Joerg Sonnenberger1-9/+1
llvm-svn: 232130
2015-02-25[OPENMP] Rename methods of OpenMPRuntime class. NFC. Alexey Bataev1-4/+2
llvm-svn: 230470
2015-02-19CodeGen: Weak reference temporaries belong in a COMDATDavid Majnemer1-0/+2
llvm-svn: 229902
2015-02-19CodeGen: static constexpr data members should have a linkonce_odr initDavid Majnemer1-4/+13
Classes can be defined in multiple translation units. This means that the static constexpr data members should have identical initializers in all translation units. Implement this by giving the reference temporary linkonce_odr linkage. llvm-svn: 229900
2015-02-18Change representation of member function pointers for MIPS targetsZoran Jovanovic1-0/+1
Differential Revision: http://reviews.llvm.org/D7148 llvm-svn: 229680
2015-02-18Rename flags and options to match current naming: from -fdef-sized-delete to ↵Larisse Voufo1-1/+1
-fdefine-sized-deallocation, and from DefaultSizedDelete to DefineSizedDeallocation. llvm-svn: 229597
2015-02-16InstrProf: Update for LLVM API changeJustin Bogner1-2/+4
Update for the API change in r229433 llvm-svn: 229434
2015-02-15Fix a typo in r229291 causing buildbot failure.Larisse Voufo1-1/+1
llvm-svn: 229295
2015-02-15More on fixing sized deallocation implementation logic: Fix PR21754.Larisse Voufo1-5/+8
llvm-svn: 229291
2015-02-14Revise the implementation logic of sized deallocation: Do not automatically ↵Larisse Voufo1-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. llvm-svn: 229241
2015-02-03MS ABI: Records with fields with required aligmnet shouldn't be commonDavid Majnemer1-3/+19
llvm-svn: 227954
2015-02-02When generating llvm.used, we may need an addrspacecast instead of a bitcast.Justin Holewinski1-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 llvm-svn: 227861
2015-01-22Emit DeferredDeclsToEmit in a DFS order.Rafael Espindola1-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. llvm-svn: 226751
2015-01-21clang-format function. NFC.Rafael Espindola1-2/+2
llvm-svn: 226662
2015-01-21CodeGen: Compiler generated __declspec(uuid) objects should be COMDAT'dDavid Majnemer1-0/+2
llvm-svn: 226628
2015-01-16Add comdat to string literal variables on COFF.Rafael Espindola1-2/+8
llvm-svn: 226317
2015-01-15Use a trivial comdat for C++ tables.Rafael Espindola1-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. llvm-svn: 226227
2015-01-15Use a trivial comdat for inline ctor/dtor when not using C5/D5.Rafael Espindola1-4/+9
When combined with llvm not producing implicit comdats, not doing this would cause code bloat on ELF and link errors on COFF. llvm-svn: 226211
2015-01-14[cleanup] Re-sort *all* #include lines with llvm/utils/sort_includes.pyChandler Carruth1-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. llvm-svn: 225979
2015-01-12[patch][pr19848] Produce explicit comdats in clang.Rafael Espindola1-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. llvm-svn: 225705
2015-01-10Don't emit implicit template instantiations eagerly (PR21718)Hans Wennborg1-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