summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
AgeCommit message (Collapse)Author
2018-03-02Always set dso_local in CodeGenModule::setDSOLocal.Rafael Espindola
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. llvm-svn: 326527
2018-03-01Remove redundant casts. NFCGeorge Burgess IV
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. llvm-svn: 326416
2018-03-01Start setting dllimport/dllexport in setGVProperties.Rafael Espindola
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-03-01Pass a GlobalDecl to SetCommonAttributes. NFC.Rafael Espindola
Part of D43900. llvm-svn: 326392
2018-03-01Inline a trivial function. NFC.Rafael Espindola
llvm-svn: 326391
2018-02-28Pass a GlobalDecl to setNonAliasAttributes. NFC.Rafael Espindola
Also part of D43900. llvm-svn: 326388
2018-02-28Pass a GlobalDecl to SetInternalFunctionAttributes. NFC.Rafael Espindola
This just reduces the noise in a followup patch. Part of D43900. llvm-svn: 326385
2018-02-28Pass a GlobalDecl to setAliasAttributes. NFC.Rafael Espindola
This just makes a followup change easier to read. llvm-svn: 326270
2018-02-27Pass a GlobalDecl to setFunctionDefinitionAttributes. NFC.Rafael Espindola
This just makes a followup patch easier to read. llvm-svn: 326265
2018-02-23Set Module Metadata "RtLibUseGOT" when fno-plt is used.Sriraman Tallam
Differential Revision: https://reviews.llvm.org/D42217 llvm-svn: 325961
2018-02-23Bring r325915 back.Rafael Espindola
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. llvm-svn: 325940
2018-02-23Revert "Start setting dso_local for COFF."Rafael Espindola
This reverts commit r325915. It will take some time to fix the failures on a windows host. llvm-svn: 325929
2018-02-23Start setting dso_local for COFF.Rafael Espindola
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. llvm-svn: 325915
2018-02-23Simplify setting dso_local. NFC.Rafael Espindola
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. llvm-svn: 325846
2018-02-20[CodeGen] Fix generation of TBAA tags for may-alias accessesIvan A. Kosarev
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 llvm-svn: 325575
2018-02-12Make attribute-target on a Definition-after-use update the LLVM attributesErich Keane
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 llvm-svn: 324907
2018-02-08Fix improper indentation issue in CodeGenModule [NFC]Erich Keane
llvm-svn: 324644
2018-02-07Don't try to use copy relocations with tls variables.Rafael Espindola
Should fix the lldb bot. llvm-svn: 324539
2018-02-07Recommit r324107 again.Rafael Espindola
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 Espindola
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 Espindola
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 Espindola
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-07Support `#pragma comment(lib, "name")` in the frontend for ELFSaleem Abdulrasool
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). llvm-svn: 324438
2018-02-02Revert "Start setting dso_local in clang."Rafael Espindola
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 Espindola
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
2018-02-01PR36181: Teach CodeGen to properly ignore requests to emit dependent entities.Richard Smith
Previously, friend function definitions within class templates slipped through the gaps and caused the MS mangler to assert. llvm-svn: 323935
2018-01-25[CodeGen] Decorate aggregate accesses with TBAA tagsIvan A. Kosarev
Differential Revision: https://reviews.llvm.org/D41539 llvm-svn: 323421
2018-01-24Don't create hidden dllimport global values.Rafael Espindola
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. llvm-svn: 323361
2018-01-17[CodeGen] Fix a crash on mangling multiversioned functionsGeorge Burgess IV
`multiVersionSortPriority` expects features to have no prefix. We currently carry them around in the format "+${feature}". llvm-svn: 322618
2018-01-16Move target MV resolver to COMDATErich Keane
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 llvm-svn: 322592
2018-01-09Reland "Emit Function IDs table for Control Flow Guard"Adrian McCarthy
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. llvm-svn: 322136
2018-01-09Added Control Flow Protection FlagOren Ben Simhon
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 llvm-svn: 322063
2018-01-09Fix use-after-free found by address-san on -r322028.Erich Keane
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. llvm-svn: 322052
2018-01-08Implement Attribute Target MultiVersioningErich Keane
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. llvm-svn: 322028
2018-01-08Revert "Emit Function IDs table for Control Flow Guard"Adrian McCarthy
The new test fails on the Hexagon bot. Reverting while I investigate. This reverts https://reviews.llvm.org/rL322005 This reverts commit b7e0026b4385180c378edc658ec91a39566f2942. llvm-svn: 322008
2018-01-08Emit Function IDs table for Control Flow GuardAdrian McCarthy
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. Differential Revision: https://reviews.llvm.org/D40531 llvm-svn: 322005
2017-12-29[OPENMP] Support for -fopenmp-simd option with compilation of simd loopsAlexey Bataev
only. Added support for -fopenmp-simd option that allows compilation of simd-based constructs without emission of OpenMP runtime calls. llvm-svn: 321560
2017-12-21Revert "Fix for PR32990"Reid Kleckner
This reverts commit r321239. It broke the Chromium DLL build: [8834/50217] LINK(DLL) icui18n.dll icui18n.dll.lib icui18n.dll.pdb FAILED: icui18n.dll icui18n.dll.lib icui18n.dll.pdb zrule.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl icu_60::UnicodeString::`vbase destructor'(void)" (__imp_??_DUnicodeString@icu_60@@QEAAXXZ) llvm-svn: 321298
2017-12-21[AARch64] Add ARMv8.2-A FP16 vector intrinsicsAbderrazek Zaafrani
Putting back the code that was reverted few weeks ago. Differential Revision: https://reviews.llvm.org/D34161 llvm-svn: 321294
2017-12-21Fix for PR32990Erich Keane
This fixes the bug in https://bugs.llvm.org/show_bug.cgi?id=32990. Patch By: zahiraam Differential Revision: https://reviews.llvm.org/D39063 llvm-svn: 321239
2017-12-19[Coverage] Fix use-after free in coverage emissionEli Friedman
Fixes regression from r320533. This fixes the undefined behavior, but I'm not sure it's really right... I think we end up with missing coverage for code in modules. Differential Revision: https://reviews.llvm.org/D41374 llvm-svn: 321052
2017-12-15[OPENMP] Codegen `declare simd` for function declarations.Alexey Bataev
Previously the attributes were emitted only for function definitions. Patch adds emission of the attributes for function declarations. llvm-svn: 320826
2017-12-13[Coverage] Always emit unused coverage mappings in the same order.Eli Friedman
Non-determinism is confusing at best. Differential Revision: https://reviews.llvm.org/D41140 llvm-svn: 320533
2017-12-09Hardware-assisted AddressSanitizer (clang part).Evgeniy Stepanov
Summary: Driver, frontend and LLVM codegen for HWASan. A clone of ASan, basically. Reviewers: kcc, pcc, alekseyshl Subscribers: srhines, javed.absar, cfe-commits Differential Revision: https://reviews.llvm.org/D40936 llvm-svn: 320232
2017-12-01Mark all library options as hidden.Zachary Turner
These command line options are not intended for public use, and often don't even make sense in the context of a particular tool anyway. About 90% of them are already hidden, but when people add new options they forget to hide them, so if you were to make a brand new tool today, link against one of LLVM's libraries, and run tool -help you would get a bunch of junk that doesn't make sense for the tool you're writing. This patch hides these options. The real solution is to not have libraries defining command line options, but that's a much larger effort and not something I'm prepared to take on. Differential Revision: https://reviews.llvm.org/D40674 llvm-svn: 319505
2017-11-29Reland "Fix vtable not receiving hidden visibility when using push(visibility)"Jake Ehrlich
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-27[CodeGen] Collect information about sizes of accesses and access types for TBAAIvan A. Kosarev
The information about access and type sizes is necessary for producing TBAA metadata in the new size-aware format. With this patch, D39955 and D39956 in place we should be able to change CodeGenTBAA::createScalarTypeNode() and CodeGenTBAA::getBaseTypeInfo() to generate metadata in the new format under the -new-struct-path-tbaa command-line option. For now, this new information remains unused. Differential Revision: https://reviews.llvm.org/D40176 llvm-svn: 319012
2017-11-22Revert "[CodeGen] Fix vtable not receiving hidden visibility when using ↵Petr Hosek
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 Hosek
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-11-11Add CLANG_DEFAULT_OBJCOPY to allow Clang to use llvm-objcopy for dwarf fissionJake Ehrlich
llvm-objcopy is getting to where it can be used in non-trivial ways (such as for dwarf fission in clang). It now supports dwarf fission but this feature hasn't been thoroughly tested yet. This change allows people to optionally build clang to use llvm-objcopy rather than GNU objcopy. By default GNU objcopy is still used so nothing should change. Differential Revision: https://reviews.llvm.org/D39029 llvm-svn: 317960