summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* Recommit r324107.Rafael Espindola2018-02-076-11/+76
| | | | | | | | | | | | | | | | | | | | | | | 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
* Don't pass ForDefinition_t in places it is redundant.Rafael Espindola2018-02-078-84/+56
| | | | | | | | | | | | | | 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
* [DebugInfo] Improvements to representation of enumeration types (PR36168)Momchil Velikov2018-02-071-5/+7
| | | | | | | | | | | | | | | This patch: * fixes an incorrect sign-extension of unsigned values, when emitting debug info metadata for enumerators * the enumerators metadata is created with a flag, which determines interpretation of the value bits (signed or unsigned) * the enumerations metadata contains the underlying integer type and a flag, indicating whether this is a C++ "fixed enum" Differential Revision: https://reviews.llvm.org/D42736 llvm-svn: 324490
* Support `#pragma comment(lib, "name")` in the frontend for ELFSaleem Abdulrasool2018-02-072-1/+13
| | | | | | | | | | | | | 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
* Pass around function pointers as CGCallees, not bare llvm::Value*s.John McCall2018-02-065-58/+77
| | | | | | | The intention here is to make it easy to write frontend-assisted CFI systems by propagating extra information in the CGCallee. llvm-svn: 324377
* IRGen: Move vtable load after argument evaluation.Peter Collingbourne2018-02-056-78/+112
| | | | | | | | | | | | | | This change reduces the live range of the loaded function pointer, resulting in a slight code size decrease (~10KB in clang), and also improves the security of CFI for virtual calls by making it less likely that the function pointer will be spilled, and ensuring that it is not spilled across a function call boundary. Fixes PR35353. Differential Revision: https://reviews.llvm.org/D42725 llvm-svn: 324286
* Add support for attribute 'trivial_abi'.Akira Hatanaka2018-02-054-31/+45
| | | | | | | | | | | | | | | | | | | | | | | | | The 'trivial_abi' attribute can be applied to a C++ class, struct, or union. It makes special functions of the annotated class (the destructor and copy/move constructors) to be trivial for the purpose of calls and, as a result, enables the annotated class or containing classes to be passed or returned using the C ABI for the underlying type. When a type that is considered trivial for the purpose of calls despite having a non-trivial destructor (which happens only when the class type or one of its subobjects is a 'trivial_abi' class) is passed to a function, the callee is responsible for destroying the object. For more background, see the discussions that took place on the mailing list: http://lists.llvm.org/pipermail/cfe-dev/2017-November/055955.html http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180101/thread.html#214043 rdar://problem/35204524 Differential Revision: https://reviews.llvm.org/D41039 llvm-svn: 324269
* Recommit rL323952: [DebugInfo] Enable debug information for C99 VLA types.Sander de Smalen2018-02-0311-71/+180
| | | | | | Fixed build issue when building with g++-4.8 (specialization after instantiation). llvm-svn: 324173
* Emit label names according to -discard-value-names.Eric Fiselier2018-02-021-4/+0
| | | | | | | | | | | | | | | | | | | Summary: Previously, Clang only emitted label names in assert builds. However there is a CC1 option -discard-value-names that should have been used to control emission instead. This patch removes the NDEBUG preprocessor block and instead allows LLVM to handle removing the names in accordance with the option. Reviewers: erichkeane, aaron.ballman, majnemer Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42829 llvm-svn: 324127
* Revert "Start setting dso_local in clang."Rafael Espindola2018-02-026-79/+11
| | | | | | | | This reverts commit r324107. I will have to test it on OS X. llvm-svn: 324108
* Start setting dso_local in clang.Rafael Espindola2018-02-026-11/+79
| | | | | | | | | | | | | | | | 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
* [CodeGen][va_args] Correct Vector Struct va-arg 'in_reg' code genErich Keane2018-02-021-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | When trying to track down a different bug, we discovered that calling __builtin_va_arg on a vec3f type caused the SROA pass to issue a warning that there was an illegal access. Further research showed that the vec3f type is alloca'ed as size '12', but the _builtin_va_arg code on x86_64 was always loading this out of registers as {double, double}. Thus, the 2nd store into the vec3f was storing in bytes 12-15! This patch alters the original implementation which always assumed {double, double} to use the actual coerced type instead, so the LLVM-IR generated is a load/GEP/store of a <2 x float> and a float, rather than a double and a double. Tests were added for all combinations I could think of that would fit in 2 FP registers, and all work exactly as expected. Differential Revision: https://reviews.llvm.org/D42811 llvm-svn: 324098
* [MinGW] Emit typeinfo locally for dllimported classes without key functionsMartin Storsjo2018-02-021-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | This fixes building Qt as shared libraries with clang in MinGW mode; previously subclasses of the QObjectData class (in other DLLs than the base DLL) failed to find the typeinfo symbols (that neither were emitted in the base DLL nor in the DLL containing the subclass). If the virtual destructor in the newly added testcase wouldn't be pure (or if there'd be another non-pure virtual method), it'd be a key function and things would work out even before this change. Make sure to locally emit the typeinfo for these classes as well. This matches what GCC does in this specific testcase. This fixes the root issue that spawned PR35146. (The difference to GCC that is initially described in that bug still is present though.) Differential Revision: https://reviews.llvm.org/D42641 llvm-svn: 324059
* Reverting patch rL323952 due to build errors that ISander de Smalen2018-02-0111-179/+71
| | | | | | haven't encountered in local builds. llvm-svn: 323956
* [DebugInfo] Enable debug information for C99 VLA typesSander de Smalen2018-02-0111-71/+179
| | | | | | | | | | | | | | | | | | | | | Summary: This patch enables debugging of C99 VLA types by generating more precise LLVM Debug metadata, using the extended DISubrange 'count' field that takes a DIVariable. This should implement: Bug 30553: Debug info generated for arrays is not what GDB expects (not as good as GCC's) https://bugs.llvm.org/show_bug.cgi?id=30553 Reviewers: echristo, aprantl, dexonsmith, clayborg, pcc, kristof.beyls, dblaikie Reviewed By: aprantl Subscribers: jholewinski, schweitz, davide, fhahn, JDevlieghere, cfe-commits Differential Revision: https://reviews.llvm.org/D41698 llvm-svn: 323952
* [CodeGen] Fix an assertion failure in CGRecordLowering.Akira Hatanaka2018-02-011-2/+6
| | | | | | | | | | | | | | This patch fixes a bug in CGRecordLowering::accumulateBitFields where it unconditionally starts a new run and emits a storage field when it sees a zero-sized bitfield, which causes an assertion in insertPadding to fail when -fno-bitfield-type-align is used. It shouldn't emit new storage if UseZeroLengthBitfieldAlignment and UseBitFieldTypeAlignment are both false. rdar://problem/36762205 llvm-svn: 323943
* 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. llvm-svn: 323935
* Revert "CodeGen: annotate ObjC ARC functions with ABI constraints"Akira Hatanaka2018-01-301-19/+0
| | | | | | | | This reverts commit r294872. Although this patch is correct, it caused the objc_autoreleaseRValue/objc_retainAutoreleasedReturnValue llvm-svn: 323814
* Change memcpy/memove/memset to have dest and source alignment attributes.Daniel Neilson2018-01-281-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change is step three in the series of changes to remove alignment argument from memcpy/memmove/memset in favour of alignment attributes. Steps: Step 1) Remove alignment parameter and create alignment parameter attributes for memcpy/memmove/memset. ( rL322965, rC322964, rL322963 ) Step 2) Expand the IRBuilder API to allow creation of memcpy/memmove with differing source and dest alignments. ( rL323597 ) Step 3) Update Clang to use the new IRBuilder API. Step 4) Update Polly to use the new IRBuilder API. Step 5) Update LLVM passes that create memcpy/memmove calls to use the new IRBuilder API, and those that use use MemIntrinsicInst::[get|set]Alignment() to use getDestAlignment() and getSourceAlignment() instead. Step 6) Remove the single-alignment IRBuilder API for memcpy/memmove, and the MemIntrinsicInst::[get|set]Alignment() methods. Reference http://lists.llvm.org/pipermail/llvm-dev/2015-August/089384.html http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html Reviewers: rjmccall Subscribers: jyknight, nemanjai, nhaehnle, javed.absar, sbc100, aheejin, kbarton, fedor.sergeev, cfe-commits Differential Revision: https://reviews.llvm.org/D41677 llvm-svn: 323617
* [CodeGen] Use the non-virtual alignment when emitting the baseAkira Hatanaka2018-01-271-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | constructor. Previously, clang would emit an over-aligned (16-byte) store to initialize B::x in B's base constructor when compiling the following code: struct A { __attribute__((aligned(16))) double data1; }; struct B : public virtual A { B() : x(123) {} double a; int x; }; struct C : public virtual B {}; void test() { B b; C c; } This was happening because the code in IRGen that does member initialization was using the alignment of a complete object instead of the non-virtual alignment. This commit fixes the bug. rdar://problem/36382481 Differential Revision: https://reviews.llvm.org/D42521 llvm-svn: 323578
* [NFC] fix trivial typos in comments and documentsHiroshi Inoue2018-01-261-1/+1
| | | | | | "in in" -> "in", "on on" -> "on" etc. llvm-svn: 323509
* [CodeGen] Decorate aggregate accesses with TBAA tagsIvan A. Kosarev2018-01-2515-55/+123
| | | | | | Differential Revision: https://reviews.llvm.org/D41539 llvm-svn: 323421
* IRGen: Emit an inline implementation of __builtin_wmemcmp on MSVCRT platforms.Peter Collingbourne2018-01-241-0/+57
| | | | | | | | | The MSVC runtime library does not provide a definition of wmemcmp, so we need an inline implementation. Differential Revision: https://reviews.llvm.org/D42441 llvm-svn: 323362
* 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. llvm-svn: 323361
* CodeGen: use `llvm.used` for ObjC protocolsSaleem Abdulrasool2018-01-231-3/+3
| | | | | | | | | These symbols are supposed to be preserved even by the linker. Use the `llvm.used` to ensure that the symbols are not removed by DCE in the linker. This should be a no-op change on MachO since the symbols are annotated as `no_dead_strip`. llvm-svn: 323247
* [OPENMP] Replace call of EmitLoadOfLValue() by EmitLoadOfScalar(), NFC.Alexey Bataev2018-01-232-18/+13
| | | | | | | Replace calls of EmitLoadOfLValue() by EmitLoadOfScalar() functions if it is known that the value is scalar. llvm-svn: 323236
* [OPENMP] Remove more empty SourceLocations() from the code.Alexey Bataev2018-01-233-95/+93
| | | | | | | Removed more empty SourceLocations() from the OpenMP code and replaced with the correct locations for better debug info emission. llvm-svn: 323232
* [WebAssembly] Add mem.* builtin functions.Dan Gohman2018-01-231-0/+15
| | | | | | | This corresponds to r323222 in LLVM. The new names are not yet finalized, so use them at your own risk. llvm-svn: 323224
* [ARM] Pass _Float16 as int or floatSjoerd Meijer2018-01-231-8/+10
| | | | | | | | | | | | Pass and return _Float16 as if it were an int or float for ARM, but with the top 16 bits unspecified, similarly like we already do for __fp16. We will implement proper half-precision function argument lowering in the ARM backend soon, but want to use this workaround in the mean time. Differential Revision: https://reviews.llvm.org/D42318 llvm-svn: 323185
* NewPM: Improve/fix GCOV - which needs to run early in the pass pipeline.David Blaikie2018-01-231-3/+7
| | | | | | | Using a new extension point in the new PM, register GCOV at the start of the pipeline rather than the end. llvm-svn: 323167
* Reland "[CodeGen] Fix crash when a function taking transparent union is ↵Volodymyr Sapsai2018-01-221-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | redeclared." When a function taking transparent union is declared as taking one of union members earlier in the translation unit, clang would hit an "Invalid cast" assertion during EmitFunctionProlog. This case corresponds to function f1 in test/CodeGen/transparent-union-redecl.c. We decided to cast i32 to union because after merging function declarations function parameter type becomes int, CGFunctionInfo::ArgInfo type matches with ABIArgInfo type, so we decide it is a trivial case. But these types should also be castable to parameter declaration type which is not the case here. Now the fix is in converting from ABIArgInfo type to VarDecl type and using argument demotion when necessary. Additional tests in Sema/transparent-union.c capture current behavior and make sure there are no regressions. rdar://problem/34949329 Reviewers: rjmccall, rafael Reviewed By: rjmccall Subscribers: aemerson, cfe-commits, kristof.beyls, ahatanak Differential Revision: https://reviews.llvm.org/D41311 llvm-svn: 323156
* [AArch64] Add ARMv8.2-A FP16 scalar intrinsicsAbderrazek Zaafrani2018-01-191-2/+215
| | | | | | https://reviews.llvm.org/D41792 llvm-svn: 323006
* [CodeGenCXX] annotate a GEP to a derived class with 'inbounds' (PR35909)Sanjay Patel2018-01-191-2/+2
| | | | | | | | | | | | | | | | The standard says: [expr.static.cast] p11: "If the prvalue of type “pointer to cv1 B” points to a B that is actually a subobject of an object of type D, the resulting pointer points to the enclosing object of type D. Otherwise, the behavior is undefined." Therefore, the GEP must be inbounds. This should solve the failure to optimize away a null check shown in PR35909: https://bugs.llvm.org/show_bug.cgi?id=35909 Differential Revision: https://reviews.llvm.org/D42249 llvm-svn: 322950
* [OpenMP] Correct generation of offloading entriesJonas Hahnfeld2018-01-181-5/+4
| | | | | | | | | | | Firstly, each offloading entry must have a unique name or the linker will complain if there are multiple files with target regions. Secondly, the compiler must not introduce padding so mark the struct with a PackedAttr. Differential Revision: https://reviews.llvm.org/D42168 llvm-svn: 322858
* Use an enum value instead of a string.Rafael Espindola2018-01-181-17/+2
| | | | | | | | The old StringSwitch use was also broken. It assumed that a StringSwitch returns Optional<T> instead of T and was missing a .Default. llvm-svn: 322792
* [Parse] Forward brace locations to TypeConstructExprVedant Kumar2018-01-171-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | When parsing C++ type construction expressions with list initialization, forward the locations of the braces to Sema. Without these locations, the code coverage pass crashes on the given test case, because the pass relies on getLocEnd() returning a valid location. Here is what this patch does in more detail: - Forwards init-list brace locations to Sema (ParseExprCXX), - Builds an InitializationKind with these locations (SemaExprCXX), and - Uses these locations for constructor initialization (SemaInit). The remaining changes fall out of introducing a new overload for creating direct-list InitializationKinds. Testing: check-clang, and a stage2 coverage-enabled build of clang with asserts enabled. Differential Revision: https://reviews.llvm.org/D41921 llvm-svn: 322729
* [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}". llvm-svn: 322618
* 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 llvm-svn: 322592
* [OPENMP] Initial codegen for `target teams distribute parallel forAlexey Bataev2018-01-153-10/+61
| | | | | | | | | simd`. Added host codegen + codegen for devices with default codegen for `#pragma omp target teams distribute parallel for simd` directive. llvm-svn: 322515
* [OPENMP] Add codegen for `depend` clauses on `target` directive.Alexey Bataev2018-01-153-133/+173
| | | | | | | Added basic support for codegen of `depend` clauses on `target` directive. llvm-svn: 322501
* [RISCV] Implement RISCV ABI loweringAlex Bradbury2018-01-151-0/+181
| | | | | | | | | | | | | | | | | | | | RISCVABIInfo is implemented in terms of XLen, supporting both RV32 and RV64. Unfortunately we need to count argument registers in the frontend in order to determine when to emit signext and zeroext attributes. Integer scalars are extended according to their type up to 32-bits and then sign-extended to XLen when passed in registers, but are anyext when passed on the stack. This patch only implements the base integer (soft float) ABIs. For more information on the RISC-V ABI, see [the ABI doc](https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md), my [golden model](https://github.com/lowRISC/riscv-calling-conv-model), and the [LLVM RISC-V calling convention patch](https://reviews.llvm.org/D39898#2d1595b4) (specifically the comment documenting frontend expectations). Differential Revision: https://reviews.llvm.org/D40023 llvm-svn: 322494
* [X86] Implement old kunpck intrinsics using vector ops on vXi1 instead of ↵Craig Topper2018-01-141-0/+22
| | | | | | | | | | | | | | | | | | | integer shift/and/or Summary: kunpck intrinsics were removed in favor of native IR a few months ago. The implementation lowers them as by operation on the integer types passed to the intrinsic and then just shifting, masking, and oring them together. A special X86 DAG combine was added to recognize this patter and turn it into a concat_vector operation. I think it makes more sense to keep the IR implementation closer to vector operations on vXi1. Given that we expect these builtins to be used around other builtins that operate on k-registers which we try to represent in IR with vXi1. InstCombine should be able to get rid of the bitcasts between integers and vXi1 leaving only the vector operations. Reviewers: RKSimon, spatel, zvi, jina.nahias Reviewed By: RKSimon Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42016 llvm-svn: 322461
* Remove unused addIfPresent function.Eric Christopher2018-01-131-4/+0
| | | | llvm-svn: 322427
* [DWARFv5] Have -gdwarf-5 generate MD5 checksumsPaul Robinson2018-01-121-1/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D42011 llvm-svn: 322413
* Allocate and access NormalCleanupDest with the natural alignment of i32.John McCall2018-01-123-10/+11
| | | | | | | | | This alignment can be less than 4 on certain embedded targets, which may not even be able to deal with 4-byte alignment on the stack. Patch by Jacob Young! llvm-svn: 322406
* Refactor handling of signext/zeroext in ABIArgInfoAlex Bradbury2018-01-123-62/+52
| | | | | | | | | | | | | | | | | | | | As @rjmccall suggested in D40023, we can get rid of ABIInfo::shouldSignExtUnsignedType (used to handle cases like the Mips calling convention where 32-bit integers are always sign extended regardless of the sign of the type) by adding a SignExt field to ABIArgInfo. In the common case, this new field is set automatically by ABIArgInfo::getExtend based on the sign of the type. For targets that want greater control, they can use ABIArgInfo::getSignExtend or ABIArgInfo::getZeroExtend when necessary. This change also cleans up logic in CGCall.cpp. There is no functional change intended in this patch, and all tests pass unchanged. As noted in D40023, Mips might want to sign-extend unsigned 32-bit integer return types. A future patch might modify MipsABIInfo::classifyReturnType to use MipsABIInfo::extendType. Differential Revision: https://reviews.llvm.org/D41999 llvm-svn: 322396
* [OPENMP] Replace calls of getAssociatedStmt().Alexey Bataev2018-01-124-101/+103
| | | | | | | | | | | | | getAssociatedStmt() returns the outermost captured statement for the OpenMP directive. It may return incorrect region in case of combined constructs. Reworked the code to reduce the number of calls of getAssociatedStmt() and used getInnermostCapturedStmt() and getCapturedStmt() functions instead. In case of firstprivate variables it may lead to an extra allocas generation for private copies even if the variable is passed by value into outlined function and could be used directly as private copy. llvm-svn: 322393
* Make internal/private GVs implicitly dso_local.Rafael Espindola2018-01-111-0/+1
| | | | | | | | | | | | | | | | While updating clang tests for having clang set dso_local I noticed that: - There are *a lot* of tests to update. - Many of the updates are redundant. They are redundant because a GV is "obviously dso_local". This patch starts formalizing that a bit by requiring that internal and private GVs be dso_local too. Since they all are, we don't have to print dso_local to the textual representation, making it a bit more compact and easier to read. llvm-svn: 322318
* 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. llvm-svn: 322136
* Wire up GCOV to the new pass managerDavid Blaikie2018-01-091-15/+24
| | | | | | | | | | GCOV in the old pass manager also strips debug info (if debug info is disabled/only produced for profiling anyway) after the GCOV pass runs. I think the strip pass hasn't been ported to the new pass manager, so it might take me a little while to wire that up. llvm-svn: 322126
OpenPOWER on IntegriCloud