summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang][ARC] Add ARCTargetInfoTatyana Krasnukha2018-11-271-0/+133
| | | | | | | | Based-on-patch-by: Pete Couperus <petecoup@synopsys.com> Differential Revision: https://reviews.llvm.org/D53100 llvm-svn: 347699
* Don't speculatively emit VTTs for classes unless we are able to correctly ↵Richard Smith2018-11-271-2/+40
| | | | | | | | | | | | | | | | | | emit references to all the functions they will (directly or indirectly) reference. Summary: This fixes a miscompile where we'd emit a VTT for a class that ends up referencing an inline virtual member function that we can't actually emit a body for (because we never instantiated it in the current TU), which in a corner case of a corner case can lead to link errors. Reviewers: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54768 llvm-svn: 347692
* Revert r347417 "Re-Reinstate 347294 with a fix for the failures."Hans Wennborg2018-11-277-67/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This caused a miscompile in Chrome (see crbug.com/908372) that's illustrated by this small reduction: static bool f(int *a, int *b) { return !__builtin_constant_p(b - a) || (!(b - a)); } int arr[] = {1,2,3}; bool g() { return f(arr, arr + 3); } $ clang -O2 -S -emit-llvm a.cc -o - g() should return true, but after r347417 it became false for some reason. This also reverts the follow-up commits. r347417: > Re-Reinstate 347294 with a fix for the failures. > > Don't try to emit a scalar expression for a non-scalar argument to > __builtin_constant_p(). > > Third time's a charm! r347446: > The result of is.constant() is unsigned. r347480: > A __builtin_constant_p() returns 0 with a function type. r347512: > isEvaluatable() implies a constant context. > > Assume that we're in a constant context if we're asking if the expression can > be compiled into a constant initializer. This fixes the issue where a > __builtin_constant_p() in a compound literal was diagnosed as not being > constant, even though it's always possible to convert the builtin into a > constant. r347531: > A "constexpr" is evaluated in a constant context. Make sure this is reflected > if a __builtin_constant_p() is a part of a constexpr. llvm-svn: 347656
* Revert "[clang][slh] add attribute for speculative load hardening"Zola Bridges2018-11-271-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | until I figure out why the build is failing or timing out *************************** Summary: The prior diff had to be reverted because there were two tests that failed. I updated the two tests in this diff clang/test/Misc/pragma-attribute-supported-attributes-list.test clang/test/SemaCXX/attr-speculative-load-hardening.cpp LLVM IR already has an attribute for speculative_load_hardening. Before this commit, when a user passed the -mspeculative-load-hardening flag to Clang, every function would have this attribute added to it. This Clang attribute will allow users to opt into SLH on a function by function basis. This can be applied to functions and Objective C methods. Reviewers: chandlerc, echristo, kristof.beyls, aaron.ballman Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54915 This reverts commit a5b3c232d1e3613f23efbc3960f8e23ea70f2a79. (r347617) llvm-svn: 347628
* [clang][slh] add attribute for speculative load hardeningZola Bridges2018-11-271-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The prior diff had to be reverted because there were two tests that failed. I updated the two tests in this diff clang/test/Misc/pragma-attribute-supported-attributes-list.test clang/test/SemaCXX/attr-speculative-load-hardening.cpp ----- Summary from Previous Diff (Still Accurate) ----- LLVM IR already has an attribute for speculative_load_hardening. Before this commit, when a user passed the -mspeculative-load-hardening flag to Clang, every function would have this attribute added to it. This Clang attribute will allow users to opt into SLH on a function by function basis. This can be applied to functions and Objective C methods. Reviewers: chandlerc, echristo, kristof.beyls, aaron.ballman Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54915 llvm-svn: 347617
* Revert "[clang][slh] add attribute for speculative load hardening"Zola Bridges2018-11-261-4/+0
| | | | | | This reverts commit 801eaf91221ba6dd6996b29ff82659ad6359e885. llvm-svn: 347588
* [clang][slh] add attribute for speculative load hardeningZola Bridges2018-11-261-0/+4
| | | | | | | | | | | | | | | | | | Summary: LLVM IR already has an attribute for speculative_load_hardening. Before this commit, when a user passed the -mspeculative-load-hardening flag to Clang, every function would have this attribute added to it. This Clang attribute will allow users to opt into SLH on a function by function basis. This can be applied to functions and Objective C methods. Reviewers: chandlerc, echristo Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54555 llvm-svn: 347586
* [OPENMP][NVPTX]Emit default locations with the correct Exec|RuntimeAlexey Bataev2018-11-262-15/+47
| | | | | | | | | | | modes. If the region is inside target|teams|distribute region, we can emit the locations with the correct info for execution mode and runtime mode. Patch adds this ability to the NVPTX codegen to help the optimizer to produce better code. llvm-svn: 347583
* [AArch64] Add aarch64_vector_pcs function attribute to ClangSander de Smalen2018-11-262-0/+5
| | | | | | | | | | | | | | | | | | | | This is the Clang patch to complement the following LLVM patches: https://reviews.llvm.org/D51477 https://reviews.llvm.org/D51479 More information describing the vector ABI and procedure call standard can be found here: https://developer.arm.com/products/software-development-tools/\ hpc/arm-compiler-for-hpc/vector-function-abi Patch by Kerry McLaughlin. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D54425 llvm-svn: 347571
* [CodeGen] translate MS rotate builtins to LLVM funnel-shift intrinsicsSanjay Patel2018-11-251-40/+10
| | | | | | | | | | | | | | This was originally part of: D50924 and should resolve PR37387: https://bugs.llvm.org/show_bug.cgi?id=37387 ...but it was reverted because some bots using a gcc host compiler would crash for unknown reasons with this included in the patch. Trying again now to see if that's still a problem. llvm-svn: 347527
* A __builtin_constant_p() returns 0 with a function type.Bill Wendling2018-11-221-1/+1
| | | | llvm-svn: 347480
* The result of is.constant() is unsigned.Bill Wendling2018-11-221-1/+1
| | | | llvm-svn: 347446
* [OPENMP][NVPTX]Emit default locations as constant with undefined mode.Alexey Bataev2018-11-214-9/+50
| | | | | | | | | | | | For the NVPTX target default locations should be emitted as constants + additional info must be emitted in the reserved_2 field of the ident_t structure. The 1st bit controls the execution mode and the 2nd bit controls use of the lightweight runtime. The combination of the bits for Non-SPMD mode + lightweight runtime represents special undefined mode, used outside of the target regions for orphaned directives or functions. Should allow and additional optimization inside of the target regions. llvm-svn: 347425
* Re-Reinstate 347294 with a fix for the failures.Bill Wendling2018-11-217-30/+67
| | | | | | | | | Don't try to emit a scalar expression for a non-scalar argument to __builtin_constant_p(). Third time's a charm! llvm-svn: 347417
* Revert r347364 again, the fix was incomplete.Nico Weber2018-11-217-67/+30
| | | | llvm-svn: 347389
* Reinstate 347294 with a fix for the failures.Bill Wendling2018-11-207-30/+67
| | | | | | | EvaluateAsInt() is sometimes called in a constant context. When that's the case, we need to specify it as so. llvm-svn: 347364
* Revert 347294, it turned many bots on lab.llvm.org:8011/console red.Nico Weber2018-11-201-20/+0
| | | | llvm-svn: 347314
* Use is.constant intrinsic for __builtin_constant_pBill Wendling2018-11-201-0/+20
| | | | | | | | | | | | | | | | Summary: A __builtin_constant_p may end up with a constant after inlining. Use the is.constant intrinsic if it's a variable that's in a context where it may resolve to a constant, e.g., an argument to a function after inlining. Reviewers: rsmith, shafik Subscribers: jfb, kristina, cfe-commits, nickdesaulniers, jyknight Differential Revision: https://reviews.llvm.org/D54355 llvm-svn: 347294
* [Coverage] Fix PR39258: support coverage regions that start deeper than they endVedant Kumar2018-11-191-11/+42
| | | | | | | | | | | popRegions used to assume that the start location of a region can't be nested deeper than the end location, which is not always true. Patch by Orivej Desh! Differential Revision: https://reviews.llvm.org/D53244 llvm-svn: 347262
* [clang][CodeGen] Implicit Conversion Sanitizer: discover the world of ↵Roman Lebedev2018-11-191-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CompoundAssign operators Summary: As reported by @regehr (thanks!) on twitter (https://twitter.com/johnregehr/status/1057681496255815686), we (me) has completely forgot about the binary assignment operator. In AST, it isn't represented as separate `ImplicitCastExpr`'s, but as a single `CompoundAssignOperator`, that does all the casts internally. Which means, out of these two, only the first one is diagnosed: ``` auto foo() { unsigned char c = 255; c = c + 1; return c; } auto bar() { unsigned char c = 255; c += 1; return c; } ``` https://godbolt.org/z/JNyVc4 This patch does handle the `CompoundAssignOperator`: ``` int main() { unsigned char c = 255; c += 1; return c; } ``` ``` $ ./bin/clang -g -fsanitize=integer /tmp/test.c && ./a.out /tmp/test.c:3:5: runtime error: implicit conversion from type 'int' of value 256 (32-bit, signed) to type 'unsigned char' changed the value to 0 (8-bit, unsigned) #0 0x2392b8 in main /tmp/test.c:3:5 #1 0x7fec4a612b16 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x22b16) #2 0x214029 in _start (/build/llvm-build-GCC-release/a.out+0x214029) ``` However, the pre/post increment/decrement is still not handled. Reviewers: rsmith, regehr, vsk, rjmccall, #sanitizers Reviewed By: rjmccall Subscribers: mclow.lists, cfe-commits, regehr Tags: #clang, #sanitizers Differential Revision: https://reviews.llvm.org/D53949 llvm-svn: 347258
* [DebugInfo] DISubprogram flags get their own flags word. NFC.Paul Robinson2018-11-191-18/+30
| | | | | | | | | | | | | This will hold flags specific to subprograms. In the future we could potentially free up scarce bits in DIFlags by moving subprogram-specific flags from there to the new flags word. This patch does not change IR/bitcode formats, that will be done in a follow-up. Differential Revision: https://reviews.llvm.org/D54597 llvm-svn: 347239
* [OpenMP] Check target architecture supports unified shared memory for ↵Patrick Lyster2018-11-194-50/+118
| | | | | | requires directive. Differential Review: https://reviews.llvm.org/D54493 llvm-svn: 347214
* [Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to ↵Calixte Denizet2018-11-171-0/+2
| | | | | | | | | | | | | | | | | | filter the files to instrument with gcov (after revert https://reviews.llvm.org/rL346659) Summary: the previous patch (https://reviews.llvm.org/rC346642) has been reverted because of test failure under windows. So this patch fix the test cfe/trunk/test/CodeGen/code-coverage-filter.c. Reviewers: marco-c Reviewed By: marco-c Subscribers: cfe-commits, sylvestre.ledru Differential Revision: https://reviews.llvm.org/D54600 llvm-svn: 347144
* Sink BuryPointer from Clang into LLVM for reuse thereDavid Blaikie2018-11-171-0/+1
| | | | llvm-svn: 347141
* Fix unused variable warning.David L. Jones2018-11-171-0/+2
| | | | llvm-svn: 347133
* [OPENMP][NVPTX]Emit correct reduction code for teams/parallelAlexey Bataev2018-11-162-165/+246
| | | | | | | | | | | reductions. Fixed previously committed code for the reduction support in teams/parallel constructs taking into account new design of the NVPTX support in the compiler. Teams reduction are not fully functional yet, it is going to be fixed in the following patches. llvm-svn: 347081
* [codeview] Expose -gcodeview-ghash for global type hashingReid Kleckner2018-11-161-0/+3
| | | | | | | | | | | | | | | | | | | | | Summary: Experience has shown that the functionality is useful. It makes linking optimized clang with debug info for me a lot faster, 20s to 13s. The type merging phase of PDB writing goes from 10s to 3s. This removes the LLVM cl::opt and replaces it with a metadata flag. After this change, users can do the following to use ghash: - add -gcodeview-ghash to compiler flags - replace /DEBUG with /DEBUG:GHASH in linker flags Reviewers: zturner, hans, thakis, takuto.ikuta Subscribers: aprantl, hiraditya, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D54370 llvm-svn: 347072
* [OpenCL] Enable address spaces for references in C++Anastasia Stulova2018-11-161-1/+8
| | | | | | | | | | | | | Added references to the addr spaces deduction and enabled CL2.0 features (program scope variables and storage class qualifiers) to work in C++ mode too. Fixed several address space conversion issues in CodeGen for references. Differential Revision: https://reviews.llvm.org/D53764 llvm-svn: 347059
* Fix warning about unused variable [NFC]Mikael Holmen2018-11-151-2/+2
| | | | llvm-svn: 346950
* CGDecl::emitStoresForConstant fix synthesized constant's nameJF Bastien2018-11-151-19/+47
| | | | | | | | | | | | Summary: The name of the synthesized constants for constant initialization was using mangling for statics, which isn't generally correct and (in a yet-uncommitted patch) causes the mangler to assert out because the static ends up trying to mangle function parameters and this makes no sense. Instead, mangle to `"__const." + FunctionName + "." + DeclName`. Reviewers: rjmccall Subscribers: dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D54055 llvm-svn: 346915
* [OpenCL] Fix invalid address space generation for clk_event_tAlexey Sotkin2018-11-141-1/+3
| | | | | | | | | | | | | | | | | | Summary: Addrspace(32) was generated when putting 0 in clk_event_t * event_ret parameter for enqueue_kernel function. Patch by Viktoria Maksimova Reviewers: Anastasia, yaxunl, AlexeySotkin Reviewed By: Anastasia, AlexeySotkin Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53809 llvm-svn: 346838
* [Clang] - Add '-gsplit-dwarf[=split,=single]' version for '-gsplit-dwarf' ↵George Rimar2018-11-142-4/+8
| | | | | | | | | | | | | | | | | | | | option. The DWARF5 specification says(Appendix F.1): "The sections that do not require relocation, however, can be written to the relocatable object (.o) file but ignored by the linker or they can be written to a separate DWARF object (.dwo) file that need not be accessed by the linker." The first part describes a single file split DWARF feature and there is no way to trigger this behavior atm. Fortunately, no many changes are required to keep *.dwo sections in a .o, the patch does that. Differential revision: https://reviews.llvm.org/D52296 llvm-svn: 346837
* DebugInfo: Add a driver flag for DWARF debug_ranges base address specifier use.David Blaikie2018-11-131-1/+2
| | | | | | | | | | | | | | | Summary: This saves a lot of relocations in optimized object files (at the cost of some cost/increase in linked executable bytes), but gold's 32 bit gdb-index support has a bug ( https://sourceware.org/bugzilla/show_bug.cgi?id=21894 ) so we can't switch to this unconditionally. (& even if it weren't for that bug, one might argue that some users would want to optimize in one direction or the other - prioritizing object size or linked executable size) Differential Revision: https://reviews.llvm.org/D54243 llvm-svn: 346789
* [NFC] Move storage of dispatch-version to GlobalDeclErich Keane2018-11-1317-110/+121
| | | | | | | | | | | | | | | | | | | As suggested by Richard Smith, and initially put up for review here: https://reviews.llvm.org/D53341, this patch removes a hack that was used to ensure that proper target-feature lists were used when emitting cpu-dispatch (and eventually, target-clones) implementations. As a part of this, the GlobalDecl object is proliferated to a bunch more locations. Originally, this was put up for review (see above) to get acceptance on the approach, though discussion with Richard in San Diego showed he approved of the approach taken here. Thus, I believe this is acceptable for Review-After-commit Differential Revision: https://reviews.llvm.org/D53341 Change-Id: I0a0bd673340d334d93feac789d653e03d9f6b1d5 llvm-svn: 346757
* Revert rL346644, rL346642: the added test ↵Calixte Denizet2018-11-121-2/+0
| | | | | | test/CodeGen/code-coverage-filter.c is failing under windows llvm-svn: 346659
* [Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to ↵Calixte Denizet2018-11-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | filter the files to instrument with gcov Summary: These options are taking regex separated by colons to filter files. - if both are empty then all files are instrumented - if -fprofile-filter-files is empty then all the filenames matching any of the regex from exclude are not instrumented - if -fprofile-exclude-files is empty then all the filenames matching any of the regex from filter are instrumented - if both aren't empty then all the filenames which match any of the regex in filter and which don't match all the regex in filter are instrumented - this patch is a follow-up of https://reviews.llvm.org/D52033 Reviewers: marco-c, vsk Reviewed By: marco-c, vsk Subscribers: cfe-commits, sylvestre.ledru Differential Revision: https://reviews.llvm.org/D52034 llvm-svn: 346642
* [CodeGen][CXX]: Fix no_destroy CG bug under specific circumstancesKristina Brooks2018-11-121-0/+9
| | | | | | | | | | | | | | | | | | Summary: Class with no user-defined destructor that has an inherited member that has a non-trivial destructor and a non-default constructor will attempt to emit a destructor despite being marked as __attribute((no_destroy)) in which case it would trigger an assertion due to an incorrect assumption. In addition this adds missing test coverage for IR generation for no_destroy. (Note that here use of no_destroy is synonymous with its global flag counterpart `-fno-c++-static-destructors` being enabled) Differential Revision: https://reviews.llvm.org/D54344 llvm-svn: 346628
* Pass the function type instead of the return type to FunctionDecl::CreateJonas Devlieghere2018-11-116-90/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix places where the return type of a FunctionDecl was being used in place of the function type FunctionDecl::Create() takes as its T parameter the type of function that should be created, not the return type. Passing in the return type looks to have been copypasta'd around a bit, but the number of correct usages outweighs the incorrect ones so I've opted for keeping what T is the same and fixing up the call sites instead. This fixes a crash in Clang when attempting to compile the following snippet of code with -fblocks -fsanitize=function -x objective-c++ (my original repro case): void g(void(^)()); void f() { __block int a = 0; g(^(){ a++; }); } as well as the following which only requires -fsanitize=function -x c++: void f(char * buf) { __builtin_os_log_format(buf, ""); } Patch by: Ben (bobsayshilol) Differential revision: https://reviews.llvm.org/D53263 llvm-svn: 346601
* [clang]: Fix misapplied patch in 346582.Kristina Brooks2018-11-101-1/+1
| | | | llvm-svn: 346583
* Correct naming conventions and 80 col rule violation in CGDeclCXX.cpp. NFC.Kristina Brooks2018-11-101-16/+17
| | | | | | Differential Revision: https://reviews.llvm.org/D54373 llvm-svn: 346582
* Revert "Revert rL346454: Fix a use-after-free introduced by r344915."Adrian Prantl2018-11-091-1/+1
| | | | | | This un-reverts commit 346454 with a relaxed CHECK for Windows. llvm-svn: 346556
* [OPENMP][NVPTX]Extend number of constructs executed in SPMD mode.Alexey Bataev2018-11-091-45/+65
| | | | | | | | | If the statements between target|teams|distribute directives does not require execution in master thread, like constant expressions, null statements, simple declarations, etc., such construct can be xecuted in SPMD mode. llvm-svn: 346551
* Revert rL346454: Fix a use-after-free introduced by r344915.Simon Pilgrim2018-11-091-1/+1
| | | | | | | | | | | | | | r344915 added a call to ApplyDebugLocation to the sanitizer check function emitter. Some of the sanitizers are emitted in the function epilogue though and the LexicalScopeStack is emptied out before. By detecting this situation and early-exiting from ApplyDebugLocation the fallback location is used, which is equivalent to the return location. rdar://problem/45859802 ........ Causes EXPENSIVE_CHECKS build bot failures: http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win llvm-svn: 346549
* Use the correct address space when bitcasting func pointer to int pointerDylan McKay2018-11-091-1/+5
| | | | | | | | | | | | | | | | | | | | When we cast a function pointer to an int pointer, at some pointer later it gets bitcasted back to a function and called. In backends that have a nonzero program memory address space specified in the data layout, the old code would lose the address space data. When LLVM later attempted to generate the bitcast from i8* to i8(..)* addrspace(1), it would fail because the pointers are not in the same address space. With this patch, the address space of the function will carry on to the address space of the i8* pointer. This is because all function pointers in Harvard architectures need to be assigned to the correct address space. This has no effect to any in-tree backends except AVR. llvm-svn: 346548
* Fix a nondeterminism in the debug info for VLA size expressions.Adrian Prantl2018-11-092-5/+14
| | | | | | | | | | | The artificial variable describing the array size is supposed to be called "__vla_expr", but this was implemented by retrieving the name of the associated alloca, which isn't a reliable source for the name, since nonassert compilers may drop names from LLVM IR. rdar://problem/45924808 llvm-svn: 346542
* Use the correct address space when emitting the ctor function listDylan McKay2018-11-091-2/+3
| | | | | | | | | | | | | | | | | This patch modifies clang so that, if compiling for a target that explicitly specifies a nonzero program memory address space, the constructor list global will have the same address space as the functions it contains. AVR is the only in-tree backend which has a nonzero program memory address space. Without this, the IR verifier would always fail if a constructor was used on a Harvard architecture backend. This has no functional change to any in-tree backends except AVR. llvm-svn: 346520
* [OPENMP][NVPTX]Allow to use shared memory for theAlexey Bataev2018-11-092-56/+100
| | | | | | | | | | target|teams|distribute variables. If the total size of the variables, declared in target|teams|distribute regions, is less than the maximal size of shared memory available, the buffer is allocated in the shared memory. llvm-svn: 346507
* Compound literals, enums, et al require const exprBill Wendling2018-11-095-0/+22
| | | | | | | | | | | | | | | | | | Summary: Compound literals, enums, file-scoped arrays, etc. require their initializers and size specifiers to be constant. Wrap the initializer expressions in a ConstantExpr so that we can easily check for this later on. Reviewers: rsmith, shafik Reviewed By: rsmith Subscribers: cfe-commits, jyknight, nickdesaulniers Differential Revision: https://reviews.llvm.org/D53921 llvm-svn: 346455
* Fix a use-after-free introduced by r344915.Adrian Prantl2018-11-091-1/+1
| | | | | | | | | | | | r344915 added a call to ApplyDebugLocation to the sanitizer check function emitter. Some of the sanitizers are emitted in the function epilogue though and the LexicalScopeStack is emptied out before. By detecting this situation and early-exiting from ApplyDebugLocation the fallback location is used, which is equivalent to the return location. rdar://problem/45859802 llvm-svn: 346454
* Fix bitcast to address space cast for coerced load/stores Yaxun Liu2018-11-081-4/+4
| | | | | | | | | | | Coerced load/stores through memory do not take into account potential address space differences when it creates its bitcasts. Patch by David Salinas. Differential Revision: https://reviews.llvm.org/D53780 llvm-svn: 346413
OpenPOWER on IntegriCloud