summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Set dso_local when clearing dllimport.Rafael Espindola2018-03-291-1/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328801 91177308-0d34-0410-b5e6-96231b3b80d8
* Disable emitting static extern C aliases for amdgcn target for CUDAYaxun Liu2018-03-291-3/+1
| | | | | | | | | | Patch by Greg Rodgers. Revised and lit test added by Yaxun Liu. Differential Revision: https://reviews.llvm.org/D44987 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328793 91177308-0d34-0410-b5e6-96231b3b80d8
* [clang] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang2018-03-271-1/+1
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328636 91177308-0d34-0410-b5e6-96231b3b80d8
* Set dso_local on builtin functions.Rafael Espindola2018-03-221-7/+1
| | | | | | | | | | The difference between CreateRuntimeFunction and CreateBuiltinFunction is that CreateBuiltinFunction would not set dllimport or dso_local. To keep the current semantics, just forward to CreateRuntimeFunction with Local=true so it doesn't add dllimport. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328224 91177308-0d34-0410-b5e6-96231b3b80d8
* Set dso_local on runtime variables.Rafael Espindola2018-03-211-1/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328068 91177308-0d34-0410-b5e6-96231b3b80d8
* Delete BuiltinCC. NFC.Rafael Espindola2018-03-201-2/+1
| | | | | | It is always identical to RuntimeCC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328050 91177308-0d34-0410-b5e6-96231b3b80d8
* Set dso_local on string literals.Rafael Espindola2018-03-201-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328040 91177308-0d34-0410-b5e6-96231b3b80d8
* Set dso_local for runtime function.Rafael Espindola2018-03-201-0/+1
| | | | | | | This is another case where there is special logic for adding dllimport and so we cannot use setGVProperties. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328036 91177308-0d34-0410-b5e6-96231b3b80d8
* Set dso_local for CFConstantStringClassReference.Rafael Espindola2018-03-201-7/+7
| | | | | | | This one cannot use setGVProperties since it has special logic for when it is dllimport or not. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327993 91177308-0d34-0410-b5e6-96231b3b80d8
* Set dso_local for guid decls.Rafael Espindola2018-03-201-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327991 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS] Fix bug in r327732 with devirtualized complete destructor callsReid Kleckner2018-03-161-0/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327754 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS] Don't escape MS C++ names with \01Reid Kleckner2018-03-161-1/+1
| | | | | | | It is not needed after LLVM r327734. Now it will be easier to copy-paste IR symbol names from Clang. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327738 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS] Always use base dtors in place of complete/vbase dtors when possibleReid Kleckner2018-03-161-13/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously we tried too hard to uphold the fiction that destructor variants work like they do on Itanium throughout the ABI-neutral parts of clang. This lead to MS C++ ABI incompatiblities and other bugs. Now, -mconstructor-aliases will no longer control this ABI detail, and clang -cc1's LLVM IR output will be this much closer to the clang driver's. Based on a patch by Zahira Ammarguellat: https://reviews.llvm.org/D39063 I've tried to move the logic that Zahira added into MicrosoftCXXABI.cpp. There is only one ABI-specific detail sticking out, and that is in CodeGenModule::getAddrOfCXXStructor, where we collapse complete dtors to base dtors in the MS ABI. This fixes PR32990. Reviewers: erichkeane, zahiraam, majnemer, rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44505 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327732 91177308-0d34-0410-b5e6-96231b3b80d8
* [OPENMP] Codegen for `omp declare target` construct.Alexey Bataev2018-03-151-0/+12
| | | | | | | | Added initial codegen for device side of declarations inside `omp declare target` construct + codegen for implicit `declare target` functions, which are used in the target regions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327636 91177308-0d34-0410-b5e6-96231b3b80d8
* Set dso_local on external rtti GVs.Rafael Espindola2018-03-141-2/+3
| | | | | | | | | | | In this particular case it would be possible to just add an else with CGM.setDSOLocal(GV), but it seems better to have as many callers as possible just call setGVProperties so that we can centralize the logic there. This patch then makes setGVProperties able to handle null Decls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327543 91177308-0d34-0410-b5e6-96231b3b80d8
* Always set dso_local in CodeGenModule::setDSOLocal.Rafael Espindola2018-03-021-2/+7
| | | | | | | | | | | | | This shouldn't change any results for now, but is more consistent with how we set dllimport/dllexport and will make future changes easier. Since clang produces IR as it parses, it can find out mid file that something is dllimport. When that happens we have to drop dso_local. This is not a problem right now because CodeGenModule::setDSOLocal is called from relatively few places at the moment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326527 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove redundant casts. NFCGeorge Burgess IV2018-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | So I wrote a clang-tidy check to lint out redundant `isa`, `cast`, and `dyn_cast`s for fun. This is a portion of what it found for clang; I plan to do similar cleanups in LLVM and other subprojects when I find time. Because of the volume of changes, I explicitly avoided making any change that wasn't highly local and obviously correct to me (e.g. we still have a number of foo(cast<Bar>(baz)) that I didn't touch, since overloading is a thing and the cast<Bar> did actually change the type -- just up the class hierarchy). I also tried to leave the types we were cast<>ing to somewhere nearby, in cases where it wasn't locally obvious what we were dealing with before. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326416 91177308-0d34-0410-b5e6-96231b3b80d8
* Start setting dllimport/dllexport in setGVProperties.Rafael Espindola2018-03-011-50/+46
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326397 91177308-0d34-0410-b5e6-96231b3b80d8
* Pass a GlobalDecl to SetCommonAttributes. NFC.Rafael Espindola2018-03-011-5/+5
| | | | | | Part of D43900. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326392 91177308-0d34-0410-b5e6-96231b3b80d8
* Inline a trivial function. NFC.Rafael Espindola2018-03-011-6/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326391 91177308-0d34-0410-b5e6-96231b3b80d8
* Pass a GlobalDecl to setNonAliasAttributes. NFC.Rafael Espindola2018-02-281-3/+4
| | | | | | Also part of D43900. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326388 91177308-0d34-0410-b5e6-96231b3b80d8
* Pass a GlobalDecl to SetInternalFunctionAttributes. NFC.Rafael Espindola2018-02-281-1/+2
| | | | | | | | This just reduces the noise in a followup patch. Part of D43900. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326385 91177308-0d34-0410-b5e6-96231b3b80d8
* Pass a GlobalDecl to setAliasAttributes. NFC.Rafael Espindola2018-02-281-3/+3
| | | | | | This just makes a followup change easier to read. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326270 91177308-0d34-0410-b5e6-96231b3b80d8
* Pass a GlobalDecl to setFunctionDefinitionAttributes. NFC.Rafael Espindola2018-02-271-3/+3
| | | | | | This just makes a followup patch easier to read. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326265 91177308-0d34-0410-b5e6-96231b3b80d8
* Set Module Metadata "RtLibUseGOT" when fno-plt is used.Sriraman Tallam2018-02-231-0/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D42217 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325961 91177308-0d34-0410-b5e6-96231b3b80d8
* Bring r325915 back.Rafael Espindola2018-02-231-1/+13
| | | | | | | | | | | | | | | The tests that failed on a windows host have been fixed. Original message: Start setting dso_local for COFF. With this there are still some GVs where we don't set dso_local because setGVProperties is never called. I intend to fix that in followup commits. This is just the bare minimum to teach shouldAssumeDSOLocal what it should do for COFF. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325940 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Start setting dso_local for COFF."Rafael Espindola2018-02-231-13/+1
| | | | | | | | This reverts commit r325915. It will take some time to fix the failures on a windows host. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325929 91177308-0d34-0410-b5e6-96231b3b80d8
* Start setting dso_local for COFF.Rafael Espindola2018-02-231-1/+13
| | | | | | | | | With this there are still some GVs where we don't set dso_local because setGVProperties is never called. I intend to fix that in followup commits. This is just the bare minimum to teach shouldAssumeDSOLocal what it should do for COFF. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325915 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify setting dso_local. NFC.Rafael Espindola2018-02-231-9/+9
| | | | | | | | | | | The value of dso_local can be computed from just IR properties and global information (object file type, command line options, etc). With this patch we no longer pass in the Decl. It was almost unused and making it fully unused guarantees that dso_local is consistent with the rest of the IR. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325846 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Fix generation of TBAA tags for may-alias accessesIvan A. Kosarev2018-02-201-7/+3
| | | | | | | | | | | | This patch fixes creating TBAA access descriptors for may_alias-marked access types. Currently, for such types we generate ordinary descriptors with char as its access type. The patch changes this to produce proper may-alias descriptors. Differential Revision: https://reviews.llvm.org/D42366 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325575 91177308-0d34-0410-b5e6-96231b3b80d8
* Make attribute-target on a Definition-after-use update the LLVM attributesErich Keane2018-02-121-0/+56
| | | | | | | | | | | | | | | | As reported here: https://bugs.llvm.org/show_bug.cgi?id=36301 The issue is that the 'use' causes the plain declaration to emit the attributes to LLVM-IR. However, if the definition added it later, these would silently disappear. This commit extracts that logic to its own function in CodeGenModule, and has the attribute-applications done during 'definition' update the attributes properly. Differential Revision: https://reviews.llvm.org/D43095 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324907 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix improper indentation issue in CodeGenModule [NFC]Erich Keane2018-02-081-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324644 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't try to use copy relocations with tls variables.Rafael Espindola2018-02-071-3/+4
| | | | | | Should fix the lldb bot. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324539 91177308-0d34-0410-b5e6-96231b3b80d8
* Recommit r324107 again.Rafael Espindola2018-02-071-5/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324535 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Recommit r324107."Rafael Espindola2018-02-071-61/+5
| | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324505 91177308-0d34-0410-b5e6-96231b3b80d8
* Recommit r324107.Rafael Espindola2018-02-071-5/+61
| | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324500 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't pass ForDefinition_t in places it is redundant.Rafael Espindola2018-02-071-17/+12
| | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324499 91177308-0d34-0410-b5e6-96231b3b80d8
* Support `#pragma comment(lib, "name")` in the frontend for ELFSaleem Abdulrasool2018-02-071-1/+11
| | | | | | | | | | | | | This adds the frontend support required to support the use of the comment pragma to enable auto linking on ELFish targets. This is a generic ELF extension supported by LLVM. We need to change the handling for the "dependentlib" in order to accommodate the previously discussed encoding for the dependent library descriptor. Without the custom handling of the PCK_Lib directive, the -l prefixed option would be encoded into the resulting object (which is treated as a frontend error). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324438 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Start setting dso_local in clang."Rafael Espindola2018-02-021-62/+5
| | | | | | | | This reverts commit r324107. I will have to test it on OS X. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324108 91177308-0d34-0410-b5e6-96231b3b80d8
* Start setting dso_local in clang.Rafael Espindola2018-02-021-5/+62
| | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324107 91177308-0d34-0410-b5e6-96231b3b80d8
* PR36181: Teach CodeGen to properly ignore requests to emit dependent entities.Richard Smith2018-02-011-17/+1
| | | | | | | | Previously, friend function definitions within class templates slipped through the gaps and caused the MS mangler to assert. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323935 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Decorate aggregate accesses with TBAA tagsIvan A. Kosarev2018-01-251-0/+8
| | | | | | | Differential Revision: https://reviews.llvm.org/D41539 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323421 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't create hidden dllimport global values.Rafael Espindola2018-01-241-0/+2
| | | | | | | | Hidden visibility is almost the opposite of dllimport. We were producing them before (dllimport wins in the existing llvm implementation), but now the llvm verifier produces an error. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323361 91177308-0d34-0410-b5e6-96231b3b80d8
* [CodeGen] Fix a crash on mangling multiversioned functionsGeorge Burgess IV2018-01-171-2/+6
| | | | | | | | `multiVersionSortPriority` expects features to have no prefix. We currently carry them around in the format "+${feature}". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322618 91177308-0d34-0410-b5e6-96231b3b80d8
* Move target MV resolver to COMDATErich Keane2018-01-161-0/+3
| | | | | | | | | | | As reported here: https://bugs.llvm.org/show_bug.cgi?id=35921 The resolver functions should be in their own COMDAT regions. This patch sets that up. Differential Revision: https://reviews.llvm.org/D42110 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322592 91177308-0d34-0410-b5e6-96231b3b80d8
* Reland "Emit Function IDs table for Control Flow Guard"Adrian McCarthy2018-01-091-0/+4
| | | | | | | | | | | | | | | | | Adds option /guard:cf to clang-cl and -cfguard to cc1 to emit function IDs of functions that have their address taken into a section named .gfids$y for compatibility with Microsoft's Control Flow Guard feature. The original patch didn't have the lit.local.cfg file that restricts the new test to x86, thus the new test was failing on the non-x86 bots. Differential Revision: https://reviews.llvm.org/D40531 The reverts r322008, which was a revert of r322005. This reverts commit a05b89f9aca70597dc79fe97bc49b50b51f525ba. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322136 91177308-0d34-0410-b5e6-96231b3b80d8
* Added Control Flow Protection FlagOren Ben Simhon2018-01-091-0/+14
| | | | | | | | | | | Cf-protection is a target independent flag that instructs the back-end to instrument control flow mechanisms like: Branch, Return, etc. For example in X86 this flag will be used to instrument Indirect Branch Tracking instructions. Differential Revision: https://reviews.llvm.org/D40478 Change-Id: I5126e766c0e6b84118cae0ee8a20fe78cc373dea git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322063 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix use-after-free found by address-san on -r322028.Erich Keane2018-01-091-1/+5
| | | | | | | | | | | | r322028 attempted to remove something from the "Manglings" list when it was no longer valid, and did so with 'erase'. However, StringRefs to these were stored, so these became dangling references. This patch changes to using 'remove' instead of 'erase' to keep the strings valid. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322052 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement Attribute Target MultiVersioningErich Keane2018-01-081-24/+175
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC's attribute 'target', in addition to being an optimization hint, also allows function multiversioning. We currently have the former implemented, this is the latter's implementation. This works by enabling functions with the same name/signature to coexist, so that they can all be emitted. Multiversion state is stored in the FunctionDecl itself, and SemaDecl manages the definitions. Note that it ends up having to permit redefinition of functions so that they can all be emitted. Additionally, all versions of the function must be emitted, so this also manages that. Note that this includes some additional rules that GCC does not, since defining something as a MultiVersion function after a usage has been made illegal. The only 'history rewriting' that happens is if a function is emitted before it has been converted to a multiversion'ed function, at which point its name needs to be changed. Function templates and virtual functions are NOT yet supported (not supported in GCC either). Additionally, constructors/destructors are disallowed, but the former is planned. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322028 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Emit Function IDs table for Control Flow Guard"Adrian McCarthy2018-01-081-4/+0
| | | | | | | | | | The new test fails on the Hexagon bot. Reverting while I investigate. This reverts https://reviews.llvm.org/rL322005 This reverts commit b7e0026b4385180c378edc658ec91a39566f2942. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322008 91177308-0d34-0410-b5e6-96231b3b80d8