summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* [OPENMP] Fix directive kind on stand-alone target data directives, NFC.Alexey Bataev2018-01-091-1/+1
| | | | llvm-svn: 322112
* Track in the AST whether the operand to a UnaryOperator can overflow and ↵Aaron Ballman2018-01-093-29/+27
| | | | | | then use that logic when evaluating constant expressions and emitting codegen. llvm-svn: 322074
* Added Control Flow Protection FlagOren Ben Simhon2018-01-092-1/+16
| | | | | | | | | | 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
* 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. llvm-svn: 322052
* [X86] Replace cvt*2mask intrinsics with native IR using 'icmp slt X, ↵Craig Topper2018-01-081-4/+27
| | | | | | zeroinitializer. llvm-svn: 322038
* Implement Attribute Target MultiVersioningErich Keane2018-01-084-24/+265
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [OPENMP] Fix debug info for outlined functions in NVPTX + add more tests.Alexey Bataev2018-01-081-4/+4
| | | | | | | Fixed name of emitted outlined functions in NVPTX target + extra tests for the debug info. llvm-svn: 322022
* 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. llvm-svn: 322008
* Emit Function IDs table for Control Flow GuardAdrian McCarthy2018-01-081-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. Differential Revision: https://reviews.llvm.org/D40531 llvm-svn: 322005
* [CodeGen] Fix TBAA info for accesses to members of base classesIvan A. Kosarev2018-01-081-2/+6
| | | | | | | | | | | Resolves: Bug 35724 - regression (r315984): fatal error: error in backend: Broken function found (Did not see access type in access path!) https://bugs.llvm.org/show_bug.cgi?id=35724 Differential Revision: https://reviews.llvm.org/D41547 llvm-svn: 321999
* [Driver] Add flag enabling the function stack size section that was added in ↵Sean Eveson2018-01-081-0/+1
| | | | | | | | | | r319430 Adds the -fstack-size-section flag to enable the .stack_sizes section. The flag defaults to on for the PS4 triple. Differential Revision: https://reviews.llvm.org/D40712 llvm-svn: 321992
* Simplify the internal API for checking whether swiftcall passes a type ↵John McCall2018-01-073-19/+16
| | | | | | indirectly and expose that API externally. llvm-svn: 321957
* Add support for a limited subset of TS 18661-3 math builtins.Benjamin Kramer2018-01-061-0/+2
| | | | | | | | | | | | | | | | | These just overloads for _Float128. They're supported by GCC 7 and used by glibc. APFloat support is already there so just add the overloads. __builtin_copysignf128 __builtin_fabsf128 __builtin_huge_valf128 __builtin_inff128 __builtin_nanf128 __builtin_nansf128 This is the same support that GCC has, according to the documentation, but limited to _Float128. llvm-svn: 321948
* No -fsanitize=function warning when calling noexcept function through ↵Stephan Bergmann2018-01-053-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | non-noexcept pointer in C++17 As discussed in the mail thread <https://groups.google.com/a/isocpp.org/forum/ #!topic/std-discussion/T64_dW3WKUk> "Calling noexcept function throug non- noexcept pointer is undefined behavior?", such a call should not be UB. However, Clang currently warns about it. This change removes exception specifications from the function types recorded for -fsanitize=function, both in the functions themselves and at the call sites. That means that calling a non-noexcept function through a noexcept pointer will also not be flagged as UB. In the review of this change, that was deemed acceptable, at least for now. (See the "TODO" in compiler-rt test/ubsan/TestCases/TypeCheck/Function/function.cpp.) To remove exception specifications from types, the existing internal ASTContext::getFunctionTypeWithExceptionSpec was made public, and some places otherwise unrelated to this change have been adapted to call it, too. This is the cfe part of a patch covering both cfe and compiler-rt. Differential Revision: https://reviews.llvm.org/D40720 llvm-svn: 321859
* Debug Info: Support DW_AT_calling_convention on composite types.Adrian Prantl2018-01-051-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | This implements the DWARF 5 feature described at http://www.dwarfstd.org/ShowIssue.php?issue=141215.1 This allows a consumer to understand whether a composite data type is trivially copyable and thus should be passed by value instead of by reference. The canonical example is being able to distinguish the following two types: // S is not trivially copyable because of the explicit destructor. struct S { ~S() {} }; // T is a POD type. struct T { ~T() = default; }; <rdar://problem/36034993> Differential Revision: https://reviews.llvm.org/D41039 llvm-svn: 321845
* [OPENMP] Fix casting in NVPTX support library.Alexey Bataev2018-01-041-37/+49
| | | | | | | | If the reduction required shuffle in the NVPTX codegen, we may need to cast the reduced value to the integer type. This casting was implemented incorrectly and may cause compiler crash. Patch fixes this problem. llvm-svn: 321818
* [OPENMP] Add debug info for generated functions.Alexey Bataev2018-01-044-115/+136
| | | | | | | Most of the generated functions for the OpenMP were generated with disabled debug info. Patch fixes this for better user experience. llvm-svn: 321816
* [CGBuiltin] Handle unsigned mul overflow properly (PR35750)Vedant Kumar2018-01-031-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | r320902 fixed the IRGen for some types of checked multiplications. It did not handle unsigned overflow correctly in the case where the signed operand is negative (PR35750). Eli pointed out that on overflow, the result must be equal to the unique value that is equivalent to the mathematically-correct result modulo two raised to the k power, where k is the number of bits in the result type. This patch fixes the specialized IRGen from r320902 accordingly. Testing: Apart from check-clang, I modified the test harness from r320902 to validate the results of all multiplications -- not just the ones which don't overflow: https://gist.github.com/vedantk/3eb9c88f82e5c32f2e590555b4af5081 llvm.org/PR35750, rdar://34963321 Differential Revision: https://reviews.llvm.org/D41717 llvm-svn: 321771
* [OpenMP] Initial implementation of code generation for pragma 'target teams ↵Carlo Bertolli2018-01-033-11/+58
| | | | | | | | | | distribute parallel for' on host https://reviews.llvm.org/D41709 This patch includes code generation and testing for offloading when target device is host. llvm-svn: 321759
* -gmodules: Emit debug info for implicit module imports via #include.Adrian Prantl2018-01-031-0/+5
| | | | | | | | | | | | When a type is only used as a template parameter and that type is the only type imported from another #include'd module, no skeleton CU for that module is generated, so a consumer doesn't know where to find the type definition. By emitting an import declaration, we can force a skeleton CU to be generated for each imported module. rdar://problem/36266156 llvm-svn: 321754
* Simplify code (NFC)Adrian Prantl2018-01-031-3/+2
| | | | llvm-svn: 321750
* [WinEH] Allow for multiple terminatepadsReid Kleckner2018-01-023-14/+52
| | | | | | | | | Fixes verifier errors with Windows EH and OpenMP, which injects a terminate scope around parallel blocks. Fixes PR35778 llvm-svn: 321676
* Revert "ASan+operator new[]: Fix operator new[] cookie poisoning"Filipe Cabecinhas2018-01-021-1/+2
| | | | | | | | This reverts r321645. I missed a compiler-rt test that needs updating. llvm-svn: 321647
* ASan+operator new[]: Fix operator new[] cookie poisoningFilipe Cabecinhas2018-01-021-2/+1
| | | | | | | | | | | | | | | | | | Summary: The C++ Itanium ABI says: No cookie is required if the new operator being used is ::operator new[](size_t, void*). We should only avoid poisoning the cookie if we're calling this operator, not others. This is dealt with before the call to InitializeArrayCookie. Reviewers: rjmccall, kcc, rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D41301 llvm-svn: 321645
* [OPENMP] Support for -fopenmp-simd option with compilation of simd loopsAlexey Bataev2017-12-298-16/+1007
| | | | | | | | | only. Added support for -fopenmp-simd option that allows compilation of simd-based constructs without emission of OpenMP runtime calls. llvm-svn: 321560
* -fsanitize=vptr warnings on bad static types in dynamic_cast and typeidStephan Bergmann2017-12-283-8/+27
| | | | | | | | | | ...when such an operation is done on an object during con-/destruction. This is the cfe part of a patch covering both cfe and compiler-rt. Differential Revision: https://reviews.llvm.org/D40295 llvm-svn: 321519
* [OPENMP] Support for `depend` clauses on `target data update`.Alexey Bataev2017-12-273-72/+254
| | | | | | Added codegen for `depend` clauses on `target data update` directives. llvm-svn: 321493
* [OpenMP] Further adjustments of nvptx runtime functionsJonas Hahnfeld2017-12-271-11/+20
| | | | | | | | Pass in default value of 1, similar to previous commit r318836. Differential Revision: https://reviews.llvm.org/D41012 llvm-svn: 321486
* [x86][icelake][bitalg]Coby Tayree2017-12-271-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | added bitalg feature recognition added intrinsics support for bitalg instructions _mm512_popcnt_epi16 _mm512_mask_popcnt_epi16 _mm512_maskz_popcnt_epi16 _mm512_popcnt_epi8 _mm512_mask_popcnt_epi8 _mm512_maskz_popcnt_epi8 _mm512_mask_bitshuffle_epi64_mask _mm512_bitshuffle_epi64_mask _mm256_popcnt_epi16 _mm256_mask_popcnt_epi16 _mm256_maskz_popcnt_epi16 _mm128_popcnt_epi16 _mm128_mask_popcnt_epi16 _mm128_maskz_popcnt_epi16 _mm256_popcnt_epi8 _mm256_mask_popcnt_epi8 _mm256_maskz_popcnt_epi8 _mm128_popcnt_epi8 _mm128_mask_popcnt_epi8 _mm128_maskz_popcnt_epi8 _mm256_mask_bitshuffle_epi32_mask _mm256_bitshuffle_epi32_mask _mm128_mask_bitshuffle_epi16_mask _mm128_bitshuffle_epi16_mask matching a similar work on the backend (D40222) Differential Revision: https://reviews.llvm.org/D41564 llvm-svn: 321483
* [CodeGen] Represent array members in new-format TBAA type descriptorsIvan A. Kosarev2017-12-221-0/+4
| | | | | | | | | | | | | Now that in the new TBAA format we allow access types to be of any object types, including aggregate ones, it becomes critical to specify types of all sub-objects such aggregates comprise as their members. In order to meet this requirement, this patch enables generation of field descriptors for members of array types. Differential Revision: https://reviews.llvm.org/D41399 llvm-svn: 321352
* [CodeGen] Support generation of TBAA info in the new formatIvan A. Kosarev2017-12-221-3/+14
| | | | | | | | | | Now that the MDBuilder helpers generating TBAA type and access descriptors in the new format are in place, we can teach clang to use them when requested. Differential Revision: https://reviews.llvm.org/D41394 llvm-svn: 321351
* [X86] Allow _mm_prefetch (both the header implementation and the builtin) to ↵Craig Topper2017-12-211-2/+3
| | | | | | | | accept bit 2 which is supposed to indicate the prefetched addresses will be written to Add the appropriate _MM_HINT_ET0/ET1 defines to match gcc. llvm-svn: 321325
* Delete dead code.Adrian Prantl2017-12-211-1/+0
| | | | llvm-svn: 321321
* Revert "[CodeGen] Fix crash when a function taking transparent union is ↵Volodymyr Sapsai2017-12-211-5/+5
| | | | | | | | | | | | redeclared." This reverts commit r321296. It caused performance regressions FAIL: imp.execution_time FAIL: 2007-01-04-KNR-Args.execution_time FAIL: sse_expandfft.execution_time FAIL: sse_stepfft.execution_time llvm-svn: 321306
* [AArch64] Enable fp16 data type for the Builtin for AArch64 only.Abderrazek Zaafrani2017-12-212-24/+37
| | | | | | Differential Revision: https:://reviews.llvm.org/D41360 llvm-svn: 321301
* Revert "Fix for PR32990"Reid Kleckner2017-12-211-33/+9
| | | | | | | | | | | | 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
* [CodeGen] Fix crash when a function taking transparent union is redeclared.Volodymyr Sapsai2017-12-211-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. The fix is in checking for the trivial case if ABIArgInfo type matches with parameter declaration type. It exposed inconsistency that we check hasScalarEvaluationKind for different types in EmitParmDecl and EmitFunctionProlog, and comment says they should match. 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 Differential Revision: https://reviews.llvm.org/D41311 llvm-svn: 321296
* [AARch64] Add ARMv8.2-A FP16 vector intrinsicsAbderrazek Zaafrani2017-12-213-7/+179
| | | | | | | | Putting back the code that was reverted few weeks ago. Differential Revision: https://reviews.llvm.org/D34161 llvm-svn: 321294
* [CodeGen] Fix access sizes in new-format TBAA tagsIvan A. Kosarev2017-12-211-1/+3
| | | | | | | | | | | | The new format requires to specify both the type of the access and its size. This patch fixes setting access sizes for TBAA tags that denote accesses to structure members. This fix affects all future TBAA metadata tests for the new format, so I guess we don't need any special tests for this fix. Differential Revision: https://reviews.llvm.org/D41452 llvm-svn: 321250
* Fix for PR32990Erich Keane2017-12-211-9/+33
| | | | | | | | | 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
* [ubsan] Diagnose noreturn functions which returnVedant Kumar2017-12-215-17/+45
| | | | | | | | | | | | | | | | | | Diagnose 'unreachable' UB when a noreturn function returns. 1. Insert a check at the end of functions marked noreturn. 2. A decl may be marked noreturn in the caller TU, but not marked in the TU where it's defined. To diagnose this scenario, strip away the noreturn attribute on the callee and insert check after calls to it. Testing: check-clang, check-ubsan, check-ubsan-minimal, D40700 rdar://33660464 Differential Revision: https://reviews.llvm.org/D40698 llvm-svn: 321231
* [hwasan] Implement -fsanitize-recover=hwaddress.Evgeniy Stepanov2017-12-201-1/+5
| | | | | | | | | | | | Summary: Very similar to AddressSanitizer, with the exception of the error type encoding. Reviewers: kcc, alekseyshl Subscribers: cfe-commits, kubamracek, llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D41417 llvm-svn: 321203
* [Complex] Don't use __div?c3 when building with fast-math.Florian Hahn2017-12-201-8/+29
| | | | | | | | | | | | Summary: Plant an inline version of "((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd))" instead. Patch by Paul Walker. Reviewed By: hfinkel Differential Revision: https://reviews.llvm.org/D40299 llvm-svn: 321183
* Silence a bunch of implicit fallthrough warningsAdrian Prantl2017-12-196-26/+26
| | | | llvm-svn: 321115
* [Coverage] Fix use-after free in coverage emissionEli Friedman2017-12-191-1/+5
| | | | | | | | | | | 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
* Fix the reference to the now renamed member of TBAAStructFieldIvan A. Kosarev2017-12-181-1/+1
| | | | | | See https://reviews.llvm.org/D39956 for details. llvm-svn: 320994
* Revert r320978 "No -fsanitize=function warning when calling noexcept ↵Stephan Bergmann2017-12-181-6/+2
| | | | | | | | | | | | | function through non-noexcept pointer in C++17" At least <http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/ builds/6013/steps/annotate/logs/stdio> complains about __ubsan::__ubsan_handle_function_type_mismatch_abort (compiler-rt lib/ubsan/ubsan_handlers.cc) returning now despite being declared 'noreturn', so looks like a different approach is needed for the function_type_mismatch check to be called also in cases that may ultimately succeed. llvm-svn: 320982
* No -fsanitize=function warning when calling noexcept function through ↵Stephan Bergmann2017-12-181-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | non-noexcept pointer in C++17 As discussed in the mail thread <https://groups.google.com/a/isocpp.org/forum/ #!topic/std-discussion/T64_dW3WKUk> "Calling noexcept function throug non- noexcept pointer is undefined behavior?", such a call should not be UB. However, Clang currently warns about it. There is no cheap check whether two function type_infos only differ in noexcept, so pass those two type_infos as additional data to the function_type_mismatch handler (with the optimization of passing a null "static callee type" info when that is already noexcept, so the additional check can be avoided anyway). For the Itanium ABI (which appears to be the only one that happens to be used on platforms that support -fsanitize=function, and which appears to only record noexcept information for pointer-to-function type_infos, not for function type_infos themselves), we then need to check the mangled names for occurrence of "Do" representing "noexcept". This is the cfe part of a patch covering both cfe and compiler-rt. Differential Revision: https://reviews.llvm.org/D40720 llvm-svn: 320978
* Refactor overridden methods iteration to avoid double lookups.Benjamin Kramer2017-12-171-1/+1
| | | | | | Convert most uses to range-for loops. No functionality change intended. llvm-svn: 320954
* [Driver, CodeGen] pass through and apply -fassociative-mathSanjay Patel2017-12-161-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are 2 parts to getting the -fassociative-math command-line flag translated to LLVM FMF: 1. In the driver/frontend, we accept the flag and its 'no' inverse and deal with the interactions with other flags like -ffast-math -fno-signed-zeros -fno-trapping-math. This was mostly already done - we just need to translate the flag as a codegen option. The test file is complicated because there are many potential combinations of flags here. Note that we are matching gcc's behavior that requires 'nsz' and no-trapping-math. 2. In codegen, we map the codegen option to FMF in the IR builder. This is simple code and corresponding test. For the motivating example from PR27372: float foo(float a, float x) { return ((a + x) - x); } $ ./clang -O2 27372.c -S -o - -ffast-math -fno-associative-math -emit-llvm | egrep 'fadd|fsub' %add = fadd nnan ninf nsz arcp contract float %0, %1 %sub = fsub nnan ninf nsz arcp contract float %add, %2 So 'reassoc' is off as expected (and so is the new 'afn' but that's a different patch). This case now works as expected end-to-end although the underlying logic is still wrong: $ ./clang -O2 27372.c -S -o - -ffast-math -fno-associative-math | grep xmm addss %xmm1, %xmm0 subss %xmm1, %xmm0 We're not done because the case where 'reassoc' is set is ignored by optimizer passes. Example: $ ./clang -O2 27372.c -S -o - -fassociative-math -fno-signed-zeros -fno-trapping-math -emit-llvm | grep fadd %add = fadd reassoc float %0, %1 $ ./clang -O2 27372.c -S -o - -fassociative-math -fno-signed-zeros -fno-trapping-math | grep xmm addss %xmm1, %xmm0 subss %xmm1, %xmm0 Differential Revision: https://reviews.llvm.org/D39812 llvm-svn: 320920
OpenPOWER on IntegriCloud