summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGExpr.cpp
AgeCommit message (Collapse)Author
2016-11-16Improve handling of __FUNCTION__ and other predefined expression for ↵Mehdi Amini
Objective-C Blocks Instead of always displaying the mangled name, try to do better and get something closer to regular functions. Recommit r287039 (that was reverted in r287039) with a tweak to be more generic, and test fixes! Differential Revision: https://reviews.llvm.org/D26522 llvm-svn: 287085
2016-11-15Revert "Improve handling of __FUNCTION__ and other predefined expression for ↵Mehdi Amini
Objective-C Blocks" This reverts commit r287039, tests are broken. llvm-svn: 287043
2016-11-15Improve handling of __FUNCTION__ and other predefined expression for ↵Mehdi Amini
Objective-C Blocks Instead of always displaying the mangled name, try to do better and get something closer to regular functions. Differential Revision: https://reviews.llvm.org/D26522 llvm-svn: 287039
2016-11-07[OPENMP] Fixed codegen for __real/__imag expressions in atomicAlexey Bataev
constructs. For __real/__imag unary expressions clang emits lvalue with the associated type from the original complex expression, but not the underlying builtin integer or float type. This causes crash in codegen for atomic constructs, if __real/__imag expression are used in atomic constructs. llvm-svn: 286129
2016-11-07[OPENMP] Fixed capturing of VLA variables.Alexey Bataev
After some changes in codegen capturing of VLA variables in OpenMP regions was broken, causing compiler crash. Patch fixes this issue. llvm-svn: 286103
2016-11-07Revert "[OPENMP] Fixed capturing of VLA variables."Diana Picus
This reverts commit r286098 because the modified test breaks on many of the buildbots. llvm-svn: 286102
2016-11-07[OPENMP] Fixed capturing of VLA variables.Alexey Bataev
After some changes in codegen capturing of VLA variables in OpenMP regions was broken, causing compiler crash. Patch fixes this issue. llvm-svn: 286098
2016-10-26Refactor call emission to package the function pointer together withJohn McCall
abstract information about the callee. NFC. The goal here is to make it easier to recognize indirect calls and trigger additional logic in certain cases. That logic will come in a later patch; in the meantime, I felt that this was a significant improvement to the code. llvm-svn: 285258
2016-10-18[CodeGen][ObjC] Do not call objc_storeStrong when initializing aAkira Hatanaka
constexpr variable. When compiling a constexpr NSString initialized with an objective-c string literal, CodeGen emits objc_storeStrong on an uninitialized alloca, which causes a crash. This patch folds the code in EmitScalarInit into EmitStoreThroughLValue and fixes the crash by calling objc_retain on the string instead of using objc_storeStrong. rdar://problem/28562009 Differential Revision: https://reviews.llvm.org/D25547 llvm-svn: 284516
2016-10-04[ubsan] Disable bounds-check for flexible array ivarsVedant Kumar
This eliminates a class of false positives for -fsanitize=array-bounds on instrumented ObjC projects. Differential Revision: https://reviews.llvm.org/D22227 llvm-svn: 283249
2016-09-29Switch to a different workaround for unimplementability of P0145R3 in MS ABIs.Richard Smith
Instead of ignoring the evaluation order rule, ignore the "destroy parameters in reverse construction order" rule for the small number of problematic cases. This only causes incorrect behavior in the rare case where both parameters to an overloaded operator <<, >>, ->*, &&, ||, or comma are of class type with non-trivial destructor, and the program is depending on those parameters being destroyed in reverse construction order. We could do a little better here by reversing the order of parameter destruction for those functions (and reversing the argument evaluation order for all direct calls, not just those with operator syntax), but that is not a complete solution to the problem, as the same situation can be reached by an indirect function call. Approach reviewed off-line by rnk. llvm-svn: 282777
2016-09-28Re-commit r282556, reverted in r282564, with a fix to CallArgList::addFrom toRichard Smith
function correctly when targeting MS ABIs (this appears to have never mattered prior to this change). Update test case to always cover both 32-bit and 64-bit Windows ABIs, since they behave somewhat differently from each other here. Update test case to also cover operators , && and ||, which it appears are also affected by P0145R3 (they're not explicitly called out by the design document, but this is the emergent behavior of the existing wording). Original commit message: P0145R3 (C++17 evaluation order tweaks): evaluate the right-hand side of assignment and compound-assignment operators before the left-hand side. (Even if it's an overloaded operator.) This completes the implementation of P0145R3 + P0400R0 for all targets except Windows, where the evaluation order guarantees for <<, >>, and ->* are unimplementable as the ABI requires the function arguments are evaluated from right to left (because parameter destructors are run from left to right in the callee). llvm-svn: 282619
2016-09-28Revert r282556. This change made several bots unhappy.Richard Smith
llvm-svn: 282564
2016-09-27P0145R3 (C++17 evaluation order tweaks): evaluate the right-hand side ofRichard Smith
assignment and compound-assignment operators before the left-hand side. (Even if it's an overloaded operator.) This completes the implementation of P0145R3 + P0400R0 for all targets except Windows, where the evaluation order guarantees for <<, >>, and ->* are unimplementable as the ABI requires the function arguments are evaluated from right to left (because parameter destructors are run from left to right in the callee). llvm-svn: 282556
2016-09-27Remove default argument from lambda to appease old MSVC.Richard Smith
llvm-svn: 282464
2016-09-26P0145R3 (C++17 evaluation order tweaks): consistently emit the LHS of arrayRichard Smith
subscripting before the RHS, regardless of which is the base and which is the index. llvm-svn: 282453
2016-09-13Update Clang for D20147 ("DebugInfo: New metadata representation for global ↵Peter Collingbourne
variables.") Differential Revision: http://reviews.llvm.org/D20415 llvm-svn: 281285
2016-09-09Update clang for D21514. NFCAmaury Sechet
Summary: As per title. Reviewers: ahatanak, bkramer, whitequark, mehdi_amini, void Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D21515 llvm-svn: 281018
2016-08-15P0217R3: code generation support for decomposition declarations.Richard Smith
llvm-svn: 278642
2016-07-28[OpenCL] Generate opaque type for sampler_t and function call for the ↵Yaxun Liu
initializer Currently Clang use int32 to represent sampler_t, which have been a source of issue for some backends, because in some backends sampler_t cannot be represented by int32. They have to depend on kernel argument metadata and use IPA to find the sampler arguments and global variables and transform them to target specific sampler type. This patch uses opaque pointer type opencl.sampler_t* for sampler_t. For each use of file-scope sampler variable, it generates a function call of __translate_sampler_initializer. For each initialization of function-scope sampler variable, it generates a function call of __translate_sampler_initializer. Each builtin library can implement its own __translate_sampler_initializer(). Since the real sampler type tends to be architecture dependent, allowing it to be initialized by a library function simplifies backend design. A typical implementation of __translate_sampler_initializer could be a table lookup of real sampler literal values. Since its argument is always a literal, the returned pointer is known at compile time and easily optimized to finally become some literal values directly put into image read instructions. This patch is partially based on Alexey Sotkin's work in Khronos Clang (https://github.com/KhronosGroup/SPIR/commit/3d4eec61623502fc306e8c67c9868be2b136e42b). Differential Revision: https://reviews.llvm.org/D21567 llvm-svn: 277024
2016-07-08[CodeGen] Use llvm::Type::getVectorNumElements instead of casting to ↵Craig Topper
llvm::VectorType and calling getNumElements. This is equivalent and shorter. llvm-svn: 274823
2016-07-01[Temporary, Lifetime] Add lifetime marks for temporariesTim Shen
With all MaterializeTemporaryExprs coming with a ExprWithCleanups, it's easy to add correct lifetime.end marks into the right RunCleanupsScope. Differential Revision: http://reviews.llvm.org/D20499 llvm-svn: 274385
2016-06-24CodeGen: Update Clang to use the new type metadata.Peter Collingbourne
Differential Revision: http://reviews.llvm.org/D21054 llvm-svn: 273730
2016-06-14Update clang for D20348Peter Collingbourne
Differential Revision: http://reviews.llvm.org/D20339 llvm-svn: 272710
2016-05-24[MS Volatile] Don't make volatile loads/stores to underaligned objects atomicDavid Majnemer
Underaligned atomic LValues require libcalls which MSVC doesn't have. MSVC doesn't seem to consider such operations as requiring a barrier anyway. This fixes PR27843. llvm-svn: 270576
2016-05-13[ObjC][CodeGen] Remove an assert that is no longer correct.Akira Hatanaka
clang asserts when compiling the following code because r231508 made changes to promote constant temporary arrays and records to globals with constant initializers: std::vector<NSString*> strs = {@"a", @"b"}; This commit changes the code to return early if the object returned by createReferenceTemporary is a global variable with an initializer. rdar://problem/25504992 rdar://problem/25955179 Differential Revision: http://reviews.llvm.org/D20045 llvm-svn: 269385
2016-05-12[ubsan] Add -fsanitize-undefined-strip-path-components=NFilipe Cabecinhas
Summary: This option allows the user to control how much of the file name is emitted by UBSan. Tuning this option allows one to save space in the resulting binary, which is helpful for restricted execution environments. With a positive N, UBSan skips the first N path components. With a negative N, UBSan only keeps the last N path components. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19666 llvm-svn: 269309
2016-05-02Fix argument expansion of reference fields of structsReid Kleckner
r268261 made Clang "expand" more struct arguments on Windows. It removed the check for 'RD->isCLike()', which was preventing us from attempting to expand structs with reference type fields. Our expansion code was attempting to load and pass each field of the type in turn. We were accidentally doing one to many loads on reference type fields. On the function prologue side, we can use EmitLValueForFieldInitialization, which obviously gets the address of the field. On the call side, I tweaked EmitRValueForField directly, since this is the only use of this method. Fixes PR27607 llvm-svn: 268321
2016-04-11Remove redundant conditions of the form (A || (!A && B)) -> (A || B)Benjamin Kramer
Found by cppcheck! PR27286 PR27287 PR27288 PR27289 llvm-svn: 265918
2016-04-08revert SVN r265702, r265640Saleem Abdulrasool
Revert the two changes to thread CodeGenOptions into the TargetInfo allocation and to fix the layering violation by moving CodeGenOptions into Basic. Code Generation is arguably not particularly "basic". This addresses Richard's post-commit review comments. This change purely does the mechanical revert and will be followed up with an alternate approach to thread the desired information into TargetInfo. llvm-svn: 265806
2016-04-07Basic: move CodeGenOptions from FrontendSaleem Abdulrasool
This is a mechanical move of CodeGenOptions from libFrontend to libBasic. This fixes the layering violation introduced earlier by threading CodeGenOptions into TargetInfo. It should also fix the modules based self-hosting builds. NFC. llvm-svn: 265702
2016-03-15[cfi] Don't emit checks for disabled CFI kinds.Evgeniy Stepanov
In the cross-DSO CFI mode clang emits __cfi_check_fail that handles errors triggered from other modules with targets in the current module. With this change, __cfi_check_fail will handle errors for CFI kinds that are not enabled in the current module as if they have the trapping behaviour (-fsanitize-trap=...). This fixes a bug where some combinations of -fsanitize* flags may result in a link failure due to a missing sanitizer runtime library for the diagnostic calls in __cfi_check_fail. llvm-svn: 263578
2016-03-13Remove compile time PreserveName in favor of a runtime cc1 ↵Mehdi Amini
-discard-value-names option Summary: This flag is enabled by default in the driver when NDEBUG is set. It is forwarded on the LLVMContext to discard all value names (but GlobalValue) for performance purpose. This an improved version of D18024 Reviewers: echristo, chandlerc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18127 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 263394
2016-03-12Temporarily revert these patches:Eric Christopher
commit 60d9845f6a037122d9be9a6d92d4de617ef45b04 Author: Mehdi Amini <mehdi.amini@apple.com> Date: Fri Mar 11 18:48:02 2016 +0000 Fix clang crash: when CodeGenAction is initialized without a context, use the member and not the parameter From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263273 91177308-0d34-0410-b5e6-96231b3b80d8 commit af7ce3bf04a75ad5124b457b805df26006bd215b Author: Mehdi Amini <mehdi.amini@apple.com> Date: Fri Mar 11 17:32:58 2016 +0000 Fix build: use -> with pointers and not . Silly typo. From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263267 91177308-0d34-0410-b5e6-96231b3b80d8 commit d0eea119192814954e7368c77d0dc5a9eeec1fbb Author: Mehdi Amini <mehdi.amini@apple.com> Date: Fri Mar 11 17:15:44 2016 +0000 Remove compile time PreserveName switch based on NDEBUG Summary: Following r263086, we are now relying on a flag on the Context to discard Value names in release builds. Reviewers: chandlerc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18024 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263257 91177308-0d34-0410-b5e6-96231b3b80d8 until we can fix the Release builds. This reverts commits 263257, 263267, 263273 llvm-svn: 263320
2016-03-11Remove compile time PreserveName switch based on NDEBUGMehdi Amini
Summary: Following r263086, we are now relying on a flag on the Context to discard Value names in release builds. Reviewers: chandlerc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18024 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 263257
2016-03-11Preserve ExtParameterInfos into CGFunctionInfo.John McCall
As part of this, make the function-arrangement interfaces a little simpler and more semantic. NFC. llvm-svn: 263191
2016-02-04[OPENMP 4.0] Fixed support of array sections/array subscripts.Alexey Bataev
Codegen for array sections/array subscripts worked only for expressions with arrays as base. Patch fixes codegen for bases with pointer/reference types. llvm-svn: 259776
2016-02-03[cfi] Safe handling of unaddressable vtable pointers (clang).Evgeniy Stepanov
Avoid crashing when printing diagnostics for vtable-related CFI errors. In diagnostic mode, the frontend does an additional check of the vtable pointer against the set of all known vtable addresses and lets the runtime handler know if it is safe to inspect the vtable. http://reviews.llvm.org/D16823 llvm-svn: 259716
2016-01-25Fix use of constexpr std::pair that's not in C++11.Evgeniy Stepanov
llvm-svn: 258749
2016-01-25[cfi] Cross-DSO CFI diagnostic mode (clang part)Evgeniy Stepanov
* Runtime diagnostic data for cfi-icall changed to match the rest of cfi checks * Layout of all CFI diagnostic data changed to put Kind at the beginning. There is no ABI stability promise yet. * Call cfi_slowpath_diag instead of cfi_slowpath when needed. * Emit __cfi_check_fail function, which dispatches a CFI check faliure according to trap/recover settings of the current module. * A tiny driver change to match the way the new handlers are done in compiler-rt. llvm-svn: 258745
2016-01-16Introduce -fsanitize-stats flag.Peter Collingbourne
This is part of a new statistics gathering feature for the sanitizers. See clang/docs/SanitizerStats.rst for further info and docs. Differential Revision: http://reviews.llvm.org/D16175 llvm-svn: 257971
2016-01-14CodeGen: Only emit CFI unrelated cast checks for bit casts.Peter Collingbourne
We were previously emitting them for no-op casts (e.g. implicit casts to const). llvm-svn: 257738
2016-01-13[Bugfix] Fix ICE on constexpr vector splat.George Burgess IV
In {CG,}ExprConstant.cpp, we weren't treating vector splats properly. This patch makes us treat splats more properly. Additionally, this patch adds a new cast kind which allows a bool->int cast to result in -1 or 0, instead of 1 or 0 (for true and false, respectively), so we can sanely model OpenCL bool->int casts in the AST. Differential Revision: http://reviews.llvm.org/D14877 llvm-svn: 257559
2015-12-15Cross-DSO control flow integrity (Clang part).Evgeniy Stepanov
Clang-side cross-DSO CFI. * Adds a command line flag -f[no-]sanitize-cfi-cross-dso. * Links a runtime library when enabled. * Emits __cfi_slowpath calls is bitset test fails. * Emits extra hash-based bitsets for external CFI checks. * Sets a module flag to enable __cfi_check generation during LTO. This mode does not yet support diagnostics. llvm-svn: 255694
2015-11-23Preserve exceptions information during calls code generation.Samuel Antao
This patch changes the generation of CGFunctionInfo to contain the FunctionProtoType if it is available. This enables the code generation for call instructions to look into this type for exception information and therefore generate better quality IR - it will not create invoke instructions for functions that are know not to throw. llvm-svn: 253926
2015-11-14Clarify and elaborate the conditions on which we're checking targetEric Christopher
features for calls. llvm-svn: 253117
2015-11-12Provide a frontend based error for always_inline functions that requireEric Christopher
target features that the caller function doesn't provide. This matches the existing backend failure to inline functions that don't have matching target features - and diagnoses earlier in the case of always_inline. Fix up a few test cases that were, in fact, invalid if you tried to generate code from the backend with the specified target features and add a couple of tests to illustrate what's going on. This should fix PR25246. llvm-svn: 252834
2015-11-06CodeGen: Remove implicit ilist iterator conversions, NFCDuncan P. N. Exon Smith
Make ilist iterator conversions explicit in clangCodeGen. Eventually I'll remove them everywhere. llvm-svn: 252358
2015-10-22Define weak and __weak to mean ARC-style weak references, even in MRC.John McCall
Previously, __weak was silently accepted and ignored in MRC mode. That makes this a potentially source-breaking change that we have to roll out cautiously. Accordingly, for the time being, actual support for __weak references in MRC is experimental, and the compiler will reject attempts to actually form such references. The intent is to eventually enable the feature by default in all non-GC modes. (It is, of course, incompatible with ObjC GC's interpretation of __weak.) If you like, you can enable this feature with -Xclang -fobjc-weak but like any -Xclang option, this option may be removed at any point, e.g. if/when it is eventually enabled by default. This patch also enables the use of the ARC __unsafe_unretained qualifier in MRC. Unlike __weak, this is being enabled immediately. Since variables are essentially __unsafe_unretained by default in MRC, the only practical uses are (1) communication and (2) changing the default behavior of by-value block capture. As an implementation matter, this means that the ObjC ownership qualifiers may appear in any ObjC language mode, and so this patch removes a number of checks for getLangOpts().ObjCAutoRefCount that were guarding the processing of these qualifiers. I don't expect this to be a significant drain on performance; it may even be faster to just check for these qualifiers directly on a type (since it's probably in a register anyway) than to do N dependent loads to grab the LangOptions. rdar://9674298 llvm-svn: 251041
2015-10-20[DEBUG INFO] Emit debug info for type used in explicit cast only.Alexey Bataev
Currently debug info for types used in explicit cast only is not emitted. It happened after a patch for better alignment handling. This patch fixes this bug. Differential Revision: http://reviews.llvm.org/D13582 llvm-svn: 250795