aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGVTables.cpp
AgeCommit message (Collapse)AuthorFilesLines
2018-04-06Fix typos in clangAlexander Kornienko1-1/+1
Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
2018-04-02[MS] Emit vftable thunks for functions with incomplete prototypesReid Kleckner1-88/+114
Summary: The following class hierarchy requires that we be able to emit a this-adjusting thunk for B::foo in C's vftable: struct Incomplete; struct A { virtual A* foo(Incomplete p) = 0; }; struct B : virtual A { void foo(Incomplete p) override; }; struct C : B { int c; }; This TU is valid, but lacks a definition of 'Incomplete', which makes it hard to build a thunk for the final overrider, B::foo. Before this change, Clang gives up attempting to emit the thunk, because it assumes that if the parameter types are incomplete, it must be emitting the thunk for optimization purposes. This is untrue for the MS ABI, where the implementation of B::foo has no idea what thunks C's vftable may require. Clang needs to emit the thunk without necessarily having access to the complete prototype of foo. This change makes Clang emit a musttail variadic call when it needs such a thunk. I call these "unprototyped" thunks, because they only prototype the "this" parameter, which must always come first in the MS C++ ABI. These thunks work, but they create ugly LLVM IR. If the call to the thunk is devirtualized, it will be a call to a bitcast of a function pointer. Today, LLVM cannot inline through such a call, but I want to address that soon, because we also use this pattern for virtual member pointer thunks. This change also implements an old FIXME in the code about reusing the thunk's computed CGFunctionInfo as much as possible. Now we don't end up computing the thunk's mangled name and arranging it's prototype up to around three times. Fixes PR25641 Reviewers: rjmccall, rsmith, hans Subscribers: Prazek, cfe-commits Differential Revision: https://reviews.llvm.org/D45112 llvm-svn: 329009
2018-03-27[clang] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang1-2/+2
r327219 added wrappers to std::sort which randomly shuffle the container before sorting. This will help in uncovering non-determinism caused due to undefined sorting order of objects having the same key. To make use of that infrastructure we need to invoke llvm::sort instead of std::sort. llvm-svn: 328636
2018-03-01Start setting dllimport/dllexport in setGVProperties.Rafael Espindola1-1/+6
This is the next step in setting dso_local for COFF. The patches changes setGVProperties to first set dllimport/dllexport and changes a few cases that were setting dllimport/dllexport manually. With this a few more GVs are marked dso_local. llvm-svn: 326397
2018-02-28Inline trivial function. NFC.Rafael Espindola1-7/+1
llvm-svn: 326272
2018-02-07Recommit r324107 again.Rafael Espindola1-2/+2
The difference from the previous try is that we no longer directly access function declarations from position independent executables. It should work, but currently doesn't with some linkers. It now includes a fix to not mark available_externally definitions as dso_local. Original message: Start setting dso_local in clang. This starts adding dso_local to clang. The hope is to eventually have TargetMachine::shouldAssumeDsoLocal go away. My objective for now is to move enough of it to clang to remove the need for the TargetMachine one to handle PIE copy relocations and -fno-plt. With that it should then be easy to implement a -fno-copy-reloc in clang. This patch just adds the cases where we assume a symbol to be local based on the file being compiled for an executable or a shared library. llvm-svn: 324535
2018-02-07Revert "Recommit r324107."Rafael Espindola1-2/+2
This reverts commit r324500. The bots found two failures: ThreadSanitizer-x86_64 :: Linux/pie_no_aslr.cc ThreadSanitizer-x86_64 :: pie_test.cc when using gold. The issue is a limitation in gold when building pie binaries. I will investigate how to work around it. llvm-svn: 324505
2018-02-07Recommit r324107.Rafael Espindola1-2/+2
It now includes a fix to not mark available_externally definitions as dso_local. Original message: Start setting dso_local in clang. This starts adding dso_local to clang. The hope is to eventually have TargetMachine::shouldAssumeDsoLocal go away. My objective for now is to move enough of it to clang to remove the need for the TargetMachine one to handle PIE copy relocations and -fno-plt. With that it should then be easy to implement a -fno-copy-reloc in clang. This patch just adds the cases where we assume a symbol to be local based on the file being compiled for an executable or a shared library. llvm-svn: 324500
2018-02-07Don't pass ForDefinition_t in places it is redundant.Rafael Espindola1-2/+2
I found this while looking at the ppc failures caused by the dso_local change. The issue was that the patch would produce the wrong answer for available_externally. Having ForDefinition_t available in places where the code can just check the linkage is a bit of a foot gun. This patch removes the ForDefiniton_t argument in places where the linkage is already know. llvm-svn: 324499
2018-02-02Revert "Start setting dso_local in clang."Rafael Espindola1-2/+2
This reverts commit r324107. I will have to test it on OS X. llvm-svn: 324108
2018-02-02Start setting dso_local in clang.Rafael Espindola1-2/+2
This starts adding dso_local to clang. The hope is to eventually have TargetMachine::shouldAssumeDsoLocal go away. My objective for now is to move enough of it to clang to remove the need for the TargetMachine one to handle PIE copy relocations and -fno-plt. With that it should then be easy to implement a -fno-copy-reloc in clang. This patch just adds the cases where we assume a symbol to be local based on the file being compiled for an executable or a shared library. llvm-svn: 324107
2017-11-29Reland "Fix vtable not receiving hidden visibility when using push(visibility)"Jake Ehrlich1-2/+2
I had to reland this change in order to make the test work on windows This change should resolve https://bugs.llvm.org/show_bug.cgi?id=35022 https://reviews.llvm.org/D39627 llvm-svn: 319269
2017-11-22Revert "[CodeGen] Fix vtable not receiving hidden visibility when using ↵Petr Hosek1-2/+2
push(visibility)" This reverts commit r318853: tests are failing on Windows bots llvm-svn: 318866
2017-11-22[CodeGen] Fix vtable not receiving hidden visibility when using push(visibility)Petr Hosek1-2/+2
This change should resolve https://bugs.llvm.org/show_bug.cgi?id=35022 Patch by Jake Ehrlich Differential Revision: https://reviews.llvm.org/D39627 llvm-svn: 318853
2017-10-31Fix for PR33930. Short-circuit metadata mapping when cloning a varargs thunk.Wolfgang Pieb1-1/+33
The cloning happens before all metadata nodes are resolved. Prevent the value mapper from running into unresolved or temporary MD nodes. Differential Revision: https://reviews.llvm.org/D39396 llvm-svn: 317047
2017-06-30Revert "[CodeGen] Propagate dllexport to thunks"Reid Kleckner1-4/+0
This reverts r306770, it causes LNK4102 warnings in MSVC builds. llvm-svn: 306835
2017-06-30[CodeGen] Propagate dllexport to thunksShoaib Meenai1-0/+4
Under Windows Itanium, we need to export virtual and non-virtual thunks if the functions being thunked are exported. These thunks would previously inherit their dllexport attribute from the declaration, but r298330 changed declarations to not have dllexport attributes. We therefore need to add the dllexport attribute to the definition ourselves now. Differential Revision: https://reviews.llvm.org/D34850 llvm-svn: 306770
2017-06-01Emit available_externally vtables opportunisticallyPiotr Padlewski1-0/+2
Summary: We can emit vtable definition having inline function if they are all emitted. Reviewers: rjmccall, rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33437 llvm-svn: 304394
2017-04-18Use less temporary AttributeLists NFCReid Kleckner1-5/+2
llvm-svn: 300628
2017-03-21Update Clang for LLVM rename AttributeSet -> AttributeListReid Kleckner1-2/+2
llvm-svn: 298394
2017-03-02Promote ConstantInitBuilder to be a public CodeGen API; it'sJohn McCall1-1/+1
a generally useful utility for other frontends. NFC. llvm-svn: 296806
2017-02-23[CodeGen] Silence unused variable warning in Release builds.Benjamin Kramer1-0/+2
llvm-svn: 296034
2017-02-23[CodeGen] Fix ExtParameterInfo bugs in C++ CodeGen code.George Burgess IV1-1/+2
This patch makes use of the prefix/suffix ABI argument distinction that was introduced in r295870, so that we now emit ExtParameterInfo at the correct offset for member calls that have added ABI arguments. I don't see a good way to test the generated param info, since we don't actually seem to use it in CGFunctionInfo outside of Swift. Any suggestions/thoughts for how to better test this are welcome. :) This patch also fixes a small bug with inheriting constructors: if we decide not to pass args into an base class ctor, we would still generate ExtParameterInfo as though we did. The added test-case is for that behavior. llvm-svn: 296024
2017-01-30Reapply "DebugInfo: Omit class definitions even in the presence of ↵David Blaikie1-3/+4
available_externally vtables" Accounts for a case that caused an assertion failure by attempting to query for the vtable linkage of a non-dynamic type.t This reverts commit r292801. llvm-svn: 293462
2017-01-23Revert "DebugInfo: Omit class definitions even in the presence of ↵David Blaikie1-4/+3
available_externally vtables" Patch crashing on a bootstrapping sanitizer bot: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/679 Reverting while I investigate. This reverts commit r292768. llvm-svn: 292801
2017-01-23DebugInfo: Omit class definitions even in the presence of ↵David Blaikie1-3/+4
available_externally vtables To ensure optimization level doesn't pessimize the -fstandalone-debug vtable debug info optimization (where class definitions are only emitted where the vtable is emitted - reducing redundant debug info) ensure the debug info class definition is still omitted when an available_externally vtable definition is emitted for optimization purposes. llvm-svn: 292768
2017-01-18Move vtable type metadata emission behind a cc1-level flag.Peter Collingbourne1-1/+1
In ThinLTO mode, type metadata will require the module to be written as a multi-module bitcode file, which is currently incompatible with the Darwin linker. It is also useful to be able to enable or disable multi-module bitcode for testing purposes. This introduces a cc1-level flag, -f{,no-}lto-unit, which is used by the driver to enable multi-module bitcode on all but Darwin+ThinLTO, and can also be used to enable/disable the feature manually. Differential Revision: https://reviews.llvm.org/D28877 llvm-svn: 292448
2016-12-13CodeGen: New vtable group representation: struct of vtable arrays.Peter Collingbourne1-8/+25
In a future change, this representation will allow us to use the new inrange annotation on getelementptr to allow the optimizer to split vtable groups. Differential Revision: https://reviews.llvm.org/D22296 llvm-svn: 289584
2016-11-28Make CGVTables use ConstantInitBuilder. NFC.John McCall1-65/+69
llvm-svn: 288081
2016-11-09Use an artificial debug location for non-virtual thunks.Adrian Prantl1-2/+7
Thunks are artificial and have no corresponding source location except for the line number on the DISubprogram, which is marked as artificial. <rdar://problem/11941095> llvm-svn: 286400
2016-10-26Refactor call emission to package the function pointer together withJohn McCall1-7/+9
abstract information about the callee. NFC. The goal here is to make it easier to recognize indirect calls and trigger additional logic in certain cases. That logic will come in a later patch; in the meantime, I felt that this was a significant improvement to the code. llvm-svn: 285258
2016-09-08Moved unreachable to appease msvc, gcc and clangSimon Pilgrim1-3/+2
llvm-svn: 280921
2016-09-08Fixed a 'not all control paths return a value' warning on MSVC buildsSimon Pilgrim1-19/+22
llvm-svn: 280917
2016-09-08CodeGen: Clean up implementation of vtable initializer builder. NFC.Peter Collingbourne1-121/+100
- Simplify signature of CreateVTableInitializer function. - Move vtable component builder to a separate function. - Remove unnecessary accessors from VTableLayout class. This is in preparation for a future change that will alter the type of the vtable initializer. Differential Revision: https://reviews.llvm.org/D22642 llvm-svn: 280897
2016-07-18[NFC] Header cleanupMehdi Amini1-4/+1
Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
2016-06-29Re-land "[MS] Don't expect vftables to be provided for extern template ↵Reid Kleckner1-3/+7
instantiations" Reverts r273305 and re-instates r273296. We needed to fix a bug in Sema::MarkVTableUsed to ensure that operator delete lookup occurs when the vtable is referenced. We already had a special case to look up operator delete when dllimport was used, but I think should really mark virtual destructors referenced any time the vtable is used. llvm-svn: 274147
2016-06-24CodeGen: Update Clang to use the new type metadata.Peter Collingbourne1-8/+5
Differential Revision: http://reviews.llvm.org/D21054 llvm-svn: 273730
2016-06-24Use more ArrayRefsDavid Majnemer1-1/+1
No functional change is intended, just a small refactoring. llvm-svn: 273647
2016-06-21Revert "[MS] Don't expect vftables to be provided for extern template ↵Reid Kleckner1-7/+3
instantiations" This reverts commit r273296, it broke the Windows self-host. llvm-svn: 273305
2016-06-21[MS] Don't expect vftables to be provided for extern template instantiationsReid Kleckner1-3/+7
MSVC doesn't provide them. PR28223 I left behind the machinery in case we want to resurrect available_externally vftable emission to support devirtualization. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D21544 llvm-svn: 273296
2016-06-16[CodeGen] Fix a segfault caused by pass_object_size.George Burgess IV1-3/+2
This patch fixes a bug where we'd segfault (in some cases) if we saw a variadic function with one or more pass_object_size arguments. Differential Revision: http://reviews.llvm.org/D17462 llvm-svn: 272971
2016-06-14Update clang for D20348Peter Collingbourne1-3/+3
Differential Revision: http://reviews.llvm.org/D20339 llvm-svn: 272710
2016-05-10Update clang for LLVM API change.Peter Collingbourne1-3/+1
llvm-svn: 269111
2016-04-28Re-apply r267784, r267824 and r267830.Peter Collingbourne1-26/+31
I have updated the compiler-rt tests. llvm-svn: 267903
2016-04-28Revert r267784, r267824 and r267830.Benjamin Kramer1-31/+26
It makes compiler-rt tests fail if the gold plugin is enabled. Revert "Rework interface for bitset-using features to use a notion of LTO visibility." Revert "Driver: only produce CFI -fvisibility= error when compiling." Revert "clang/test/CodeGenCXX/cfi-blacklist.cpp: Exclude ms targets. They would be non-cfi." llvm-svn: 267871
2016-04-27Rework interface for bitset-using features to use a notion of LTO visibility.Peter Collingbourne1-26/+31
Bitsets, and the compiler features they rely on (vtable opt, CFI), only have visibility within the LTO'd part of the linkage unit. Therefore, only enable these features for classes with hidden LTO visibility. This notion is based on object file visibility or (on Windows) dllimport/dllexport attributes. We provide the [[clang::lto_visibility_public]] attribute to override the compiler's LTO visibility inference in cases where the class is defined in the non-LTO'd part of the linkage unit, or where the ABI supports calling classes derived from abstract base classes with hidden visibility in other linkage units (e.g. COM on Windows). If the cross-DSO CFI mode is enabled, bitset checks are emitted even for classes with public LTO visibility, as that mode uses a separate mechanism to cause bitsets to be exported. This mechanism replaces the whole-program-vtables blacklist, so remove the -fwhole-program-vtables-blacklist flag. Because __declspec(uuid()) now implies [[clang::lto_visibility_public]], the support for the special attr:uuid blacklist entry is removed. Differential Revision: http://reviews.llvm.org/D18635 llvm-svn: 267784
2016-04-08revert SVN r265702, r265640Saleem Abdulrasool1-2/+1
Revert the two changes to thread CodeGenOptions into the TargetInfo allocation and to fix the layering violation by moving CodeGenOptions into Basic. Code Generation is arguably not particularly "basic". This addresses Richard's post-commit review comments. This change purely does the mechanical revert and will be followed up with an alternate approach to thread the desired information into TargetInfo. llvm-svn: 265806
2016-04-07Basic: move CodeGenOptions from FrontendSaleem Abdulrasool1-1/+2
This is a mechanical move of CodeGenOptions from libFrontend to libBasic. This fixes the layering violation introduced earlier by threading CodeGenOptions into TargetInfo. It should also fix the modules based self-hosting builds. NFC. llvm-svn: 265702
2016-03-14CodeGen: Mark functions used in vtables as unnamed_addr.Peter Collingbourne1-0/+4
This marks virtual function declarations, as well as runtime library functions __cxa_pure_virtual, __cxa_deleted_virtual and _purecall, as unnamed_addr. This will allow us to correctly form relative references to them from vtables in the relative vtable ABI. Differential Revision: http://reviews.llvm.org/D18071 llvm-svn: 263464
2016-02-24Add whole-program vtable optimization feature to Clang.Peter Collingbourne1-11/+24
This patch introduces the -fwhole-program-vtables flag, which enables the whole-program vtable optimization feature (D16795) in Clang. Differential Revision: http://reviews.llvm.org/D16821 llvm-svn: 261767