aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.h
AgeCommit message (Collapse)AuthorFilesLines
2014-11-10Propagate SanitizerKind into CodeGenFunction::EmitCheck() call.Alexey Samsonov1-11/+1
Make sure CodeGenFunction::EmitCheck() knows which sanitizer it emits check for. Make CheckRecoverableKind enum an implementation detail and move it away from header. Currently CheckRecoverableKind is determined by the type of sanitizer ("unreachable" and "return" are unrecoverable, "vptr" is always-recoverable, all the rest are recoverable). This will change in future if we allow to specify which sanitizers are recoverable, and which are not by -fsanitize-recover= flag. No functionality change. llvm-svn: 221635
2014-10-31Silence a warning from MSVC "14" by making an enum unsignedReid Kleckner1-2/+2
It says there is a narrowing conversion when we assign it to an unsigned 3 bit bitfield. Also, use unsigned instead of size_t for the Size field of the struct in question. Otherwise they won't run together in MSVC or clang-cl. llvm-svn: 221019
2014-10-31MS ABI: Properly call global delete when invoking virtual destructorsDavid Majnemer1-0/+8
Summary: The Itanium ABI approach of using offset-to-top isn't possible with the MS ABI, it doesn't have that kind of information lying around. Instead, we do the following: - Call the virtual deleting destructor with the "don't delete the object flag" set. The virtual deleting destructor will return a pointer to 'this' adjusted to the most derived class. - Call the global delete using the adjusted 'this' pointer. Reviewers: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5996 llvm-svn: 220993
2014-10-30Get rid of SanitizerOptions::Disabled global. NFC.Alexey Samsonov1-1/+1
SanitizerOptions is not even a POD now, so having global variable of this type, is not nice. Instead, provide a regular constructor and clear() method, and let each CodeGenFunction has its own copy of SanitizerOptions it uses. llvm-svn: 220920
2014-10-29Improved capturing variable-length array types in CapturedStmt.Alexey Bataev1-1/+2
An updated implemnentation of VLA types capturing based on previously committed solution for Lambdas. This version captures the whole VLA type instead of particular variables which are part of VLA size expression and allows to use previusly calculated size of VLA type in captured regions. Required for OpenMP. Differential Revision: http://reviews.llvm.org/D5099 llvm-svn: 220850
2014-10-28Objective-C. revert patch for rdar://17554063.Fariborz Jahanian1-2/+1
llvm-svn: 220812
2014-10-21Fixing the MSVC build by removing friendship with CodeGenFunction; NFC.Aaron Ballman1-1/+0
llvm-svn: 220293
2014-10-21[OPENMP] Codegen for 'private' clause in 'parallel' directive.Alexey Bataev1-0/+3
This patch generates some helper variables which used as a private copies of the corresponding original variables inside an OpenMP 'parallel' directive. These generated variables are initialized by default (with the default constructor, if any). In outlined function references to original variables are replaced by the references to these private helper variables. At the end of the initialization of the private variables and implicit barier is set by calling __kmpc_barrier(...) runtime function to be sure that all threads were initialized using original values of the variables. Differential Revision: http://reviews.llvm.org/D4752 llvm-svn: 220262
2014-10-16Insert poisoned paddings between fields in C++ classes so that ↵Kostya Serebryany1-0/+1
AddressSanitizer can find intra-object-overflow bugs Summary: The general approach is to add extra paddings after every field in AST/RecordLayoutBuilder.cpp, then add code to CTORs/DTORs that poisons the paddings (CodeGen/CGClass.cpp). Everything is done under the flag -fsanitize-address-field-padding. The blacklist file (-fsanitize-blacklist) allows to avoid the transformation for given classes or source files. See also https://code.google.com/p/address-sanitizer/wiki/IntraObjectOverflow Test Plan: run SPEC2006 and some of the Chromium tests with -fsanitize-address-field-padding Reviewers: samsonov, rnk, rsmith Reviewed By: rsmith Subscribers: majnemer, cfe-commits Differential Revision: http://reviews.llvm.org/D5687 llvm-svn: 219961
2014-10-15Moving CGF::EmitAlignmentAssumption to IRBuilderHal Finkel1-1/+4
The functionality contained in CodeGenFunction::EmitAlignmentAssumption has been moved to IRBuilder (so that it can also be used by LLVM-level code). Remove this now-duplicate implementation in favor of the IRBuilder code. llvm-svn: 219877
2014-10-13Sanitize upcasts and conversion to virtual base.Alexey Samsonov1-3/+10
This change adds UBSan check to upcasts. Namely, when we perform derived-to-base conversion, we: 1) check that the pointer-to-derived has suitable alignment and underlying storage, if this pointer is non-null. 2) if vptr-sanitizer is enabled, and we perform conversion to virtual base, we check that pointer-to-derived has a matching vptr. llvm-svn: 219642
2014-10-10Unfriend CGOpenMPRegionInfo so it can go into an anonymous namespace.Benjamin Kramer1-1/+0
Also remove some unnecessary virtual keywords. NFC. llvm-svn: 219497
2014-10-10Code reformatting and improvement for OpenMP.Alexey Bataev1-0/+4
Moved CGOpenMPRegionInfo from CGOpenMPRuntime.h to CGOpenMPRuntime.cpp file and reworked the code for this change. Also added processing of ThreadID variable passed as an argument in outlined functions in parallel and task directives. llvm-svn: 219490
2014-10-10Code improvements in OpenMP CodeGen.Alexey Bataev1-44/+63
This patch makes class OMPPrivateScope a common class for all private variables. Reworked processing of firstprivate variables (now it is based on OMPPrivateScope too). llvm-svn: 219486
2014-10-10Revert r218865 because it introduced PR21236, a crash in codegen emitting ↵Nick Lewycky1-27/+0
the try block. llvm-svn: 219470
2014-10-10Promote null pointer constants used as arguments to variadic functionsReid Kleckner1-1/+3
Make it possible to pass NULL through variadic functions on 64-bit Windows targets. The Visual C++ headers define NULL to 0, when they should define it to 0LL on Win64 so that NULL is a pointer-sized integer. Fixes PR20949. Reviewers: thakis, rsmith Differential Revision: http://reviews.llvm.org/D5480 llvm-svn: 219456
2014-10-09[OPENMP] 'omp teams' directive basic support.Alexey Bataev1-0/+1
Includes parsing and semantic analysis for 'omp teams' directive support from OpenMP 4.0. Adds additional analysis to 'omp target' directive with 'omp teams' directive. llvm-svn: 219385
2014-10-08[OPENMP] Codegen for 'firstprivate' clause.Alexey Bataev1-0/+13
This patch generates some helper variables that used as private copies of the corresponding original variables inside an OpenMP 'parallel' directive. These generated variables are initialized by copy using values of the original variables (with the copy constructor, if any). For arrays, initializator is generated for single element and in the codegen procedure this initial value is automatically propagated between all elements of the private copy. In outlined function, references to original variables are replaced by the references to these private helper variables. At the end of the initialization of the private variables an implicit barier is generated by calling __kmpc_barrier(...) runtime function to be sure that all threads were initialized using original values of the variables. Differential Revision: http://reviews.llvm.org/D5140 llvm-svn: 219306
2014-10-08Revert commit r219297.Alexey Bataev1-13/+0
Still troubles with OpenMP/parallel_firstprivate_codegen.cpp (now in ARM buildbots). llvm-svn: 219298
2014-10-08[OPENMP] Codegen for 'firstprivate' clause.Alexey Bataev1-0/+13
This patch generates some helper variables that used as private copies of the corresponding original variables inside an OpenMP 'parallel' directive. These generated variables are initialized by copy using values of the original variables (with the copy constructor, if any). For arrays, initializator is generated for single element and in the codegen procedure this initial value is automatically propagated between all elements of the private copy. In outlined function, references to original variables are replaced by the references to these private helper variables. At the end of the initialization of the private variables an implicit barier is generated by calling __kmpc_barrier(...) runtime function to be sure that all threads were initialized using original values of the variables. Differential Revision: http://reviews.llvm.org/D5140 llvm-svn: 219297
2014-10-08Revert back r219295.Alexey Bataev1-13/+0
To fix issues with test OpenMP/parallel_firstprivate_codegen.cpp llvm-svn: 219296
2014-10-08[OPENMP] Codegen for 'firstprivate' clause.Alexey Bataev1-0/+13
This patch generates some helper variables that used as private copies of the corresponding original variables inside an OpenMP 'parallel' directive. These generated variables are initialized by copy using values of the original variables (with the copy constructor, if any). For arrays, initializator is generated for single element and in the codegen procedure this initial value is automatically propagated between all elements of the private copy. In outlined function, references to original variables are replaced by the references to these private helper variables. At the end of the initialization of the private variables an implicit barier is generated by calling __kmpc_barrier(...) runtime function to be sure that all threads were initialized using original values of the variables. Differential Revision: http://reviews.llvm.org/D5140 llvm-svn: 219295
2014-10-08Revert "[OPENMP] 'omp teams' directive basic support. Includes parsing and ↵Renato Golin1-1/+0
semantic analysis for 'omp teams' directive support from OpenMP 4.0. Adds additional analysis to 'omp target' directive with 'omp teams' directive." This reverts commit r219197 because it broke ARM self-hosting buildbots with segmentation fault errors in many tests. llvm-svn: 219289
2014-10-08Fix IRGen for referencing a static local before emitting its declReid Kleckner1-5/+0
Summary: Previously CodeGen assumed that static locals were emitted before they could be accessed, which is true for automatic storage duration locals. However, it is possible to have CodeGen emit a nested function that uses a static local before emitting the function that defines the static local, breaking that assumption. Fix it by creating the static local upon access and ensuring that the deferred function body gets emitted. We may not be able to emit the initializer properly from outside the function body, so don't try. Fixes PR18020. See also previous attempts to fix static locals in PR6769 and PR7101. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4787 llvm-svn: 219265
2014-10-07[OPENMP] 'omp teams' directive basic support.Alexey Bataev1-0/+1
Includes parsing and semantic analysis for 'omp teams' directive support from OpenMP 4.0. Adds additional analysis to 'omp target' directive with 'omp teams' directive. llvm-svn: 219197
2014-10-07[OPENMP] Small refactoring of EmitOMPSimdLoop helper routine.Alexander Musman1-3/+4
No functional changes intended. Renamed EmitOMPSimdLoop to EmitOMPInnerLoop, I plan to re-use it to emit inner loop in the future patches for CodeGen of the worksharing loop directives (omp for, omp for simd). llvm-svn: 219195
2014-10-05MS ABI: Implement thread_local for global variablesDavid Majnemer1-1/+4
Summary: This add support for the C++11 feature, thread_local global variables. The ABI Clang implements is an improvement of the MSVC ABI. Sadly, further improvements could be made but not without sacrificing ABI compatibility. The feature is implemented as follows: - All thread_local initialization routines are pointed to from the .CRT$XDU section. - All non-weak thread_local variables have their initialization routines call from a single function instead of getting their own .CRT$XDU section entry. This is done to open up optimization opportunities to the compiler. - All weak thread_local variables have their own .CRT$XDU section entry. This entry is in a COMDAT with the global variable it is initializing; this ensures that we will initialize the global exactly once. - Destructors are registered in the initialization function using __tlregdtor. Differential Revision: http://reviews.llvm.org/D5597 llvm-svn: 219074
2014-10-02Emit lifetime.start / lifetime.end markers for unnamed temporary objects.Arnaud A. de Grandmaison1-0/+27
This will give more information to the optimizers so that they can reuse stack slots and reduce stack usage. llvm-svn: 218865
2014-10-01[OPENMP] Loop collapsing and codegen for 'omp simd' directive.Alexander Musman1-0/+48
This patch implements collapsing of the loops (in particular, in presense of clause 'collapse'). It calculates number of iterations N and expressions nesessary to calculate the nested loops counters values based on new iteration variable (that goes from 0 to N-1) in Sema. It also adds Codegen for 'omp simd', which uses (and tests) this feature. Differential Revision: http://reviews.llvm.org/D5184 llvm-svn: 218743
2014-09-23[OPENMP] Parsing/Sema of directive omp parallel for simdAlexander Musman1-0/+1
llvm-svn: 218299
2014-09-19[OPENMP] Initial parsing/sema analysis of 'target' directive.Alexey Bataev1-0/+1
llvm-svn: 218110
2014-09-18MS ABI: Don't ICE for pointers to pointers to members of incomplete classesDavid Majnemer1-12/+1
CodeGen would try to come up with an LLVM IR type for a pointer to member type on the way to forming an LLVM IR type for a pointer to pointer to member type. However, if the pointer to member representation has not been locked in yet, we would not be able to come up with a pointer to member IR type. In these cases, make the pointer to member type an incomplete type. This will make the pointer to pointer to member type a pointer to an incomplete type. If the class eventually obtains an inheritance model, we will make the pointer to member type represent the actual inheritance model. Differential Revision: http://reviews.llvm.org/D5373 llvm-svn: 218084
2014-09-18Parsing/Sema of directive omp for simdAlexander Musman1-0/+1
llvm-svn: 218029
2014-09-08Implement nonnull-attribute sanitizerAlexey Samsonov1-2/+5
Summary: This patch implements a new UBSan check, which verifies that function arguments declared to be nonnull with __attribute__((nonnull)) are actually nonnull in runtime. To implement this check, we pass FunctionDecl to CodeGenFunction::EmitCallArgs (where applicable) and if function declaration has nonnull attribute specified for a certain formal parameter, we compare the corresponding RValue to null as soon as it's calculated. Test Plan: regression test suite Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits, rnk Differential Revision: http://reviews.llvm.org/D5082 llvm-svn: 217389
2014-09-07Add __builtin_assume and __builtin_assume_aligned using @llvm.assume.Hal Finkel1-0/+4
This makes use of the recently-added @llvm.assume intrinsic to implement a __builtin_assume(bool) intrinsic (to provide additional information to the optimizer). This hooks up __assume in MS-compatibility mode to mirror __builtin_assume (the semantics have been intentionally kept compatible), and implements GCC's __builtin_assume_aligned as assume((p - o) & mask == 0). LLVM now contains special logic to deal with assumptions of this form. llvm-svn: 217349
2014-09-04MS inline asm: Allow __asm blocks to set a return valueReid Kleckner1-0/+4
If control falls off the end of a function after an __asm block, MSVC assumes that the inline assembly filled the EAX and possibly EDX registers with an appropriate return value. This functionality is used in inline functions returning 64-bit integers in system headers, so we need some amount of compatibility. This is implemented in Clang by adding extra output constraints to every inline asm block, and storing the resulting output registers into the return value slot. If we see an asm block somewhere in the function body, we emit a normal epilogue instead of marking the end of the function with a return type unreachable. Normal returns in functions not using this functionality will overwrite the return value slot, and in most cases LLVM should be able to eliminate the dead stores. Fixes PR17201. Reviewed By: majnemer Differential Revision: http://reviews.llvm.org/D5177 llvm-svn: 217187
2014-08-28Kill one of EmitCallArgs overloads. NFC.Alexey Samsonov1-46/+33
llvm-svn: 216635
2014-08-27Fix some cases were ArrayRefs were being passed by reference.Craig Topper1-5/+5
llvm-svn: 216527
2014-08-25Pass actual CXXConstructExpr instead of argument iteratorsAlexey Samsonov1-2/+1
into EmitSynthesizedCXXCopyCtorCall. No functionality change. llvm-svn: 216410
2014-08-25Pass actual CallExpr instead of CallExpr-specific iteratorsAlexey Samsonov1-9/+5
into EmitCXXMemberOrOperatorCall methods. In the end we want to make declaration visible in EmitCallArgs() method, that would allow us to alter CodeGen depending on function/parameter attributes. No functionality change. llvm-svn: 216404
2014-08-22DebugInfo: Scope for condition variables more narrowly than the loop variable.David Blaikie1-1/+1
for loops introduce two scopes - one for the outer loop variable and its initialization, and another for the body of the loop, including any variable declared inside the loop condition. llvm-svn: 216288
2014-08-22CGCall: Factor out the logic mapping call arguments to LLVM IR arguments.Alexey Samsonov1-12/+9
Summary: This refactoring introduces ClangToLLVMArgMapping class, which encapsulates the information about the order in which function arguments listed in CGFunctionInfo should be passed to actual LLVM IR function, such as: 1) positions of sret, if there is any 2) position of inalloca argument, if there is any 3) position of helper padding argument for each call argument 4) positions of regular argument (there can be many if it's expanded). Simplify several related methods (ConstructAttributeList, EmitFunctionProlog and EmitCall): now they don't have to maintain iterators over the list of LLVM IR function arguments, dealing with all the sret/inalloca/this complexities, and just use expected positions of LLVM IR arguments stored in ClangToLLVMArgMapping. This may increase the running time of EmitFunctionProlog, as we have to traverse expandable arguments twice, but in further refactoring we will be able to speed up EmitCall by passing already calculated CallArgsToIRArgsMapping to ConstructAttributeList, thus avoiding traversing expandable argument there. No functionality change. Test Plan: regression test suite Reviewers: majnemer, rnk Reviewed By: rnk Subscribers: cfe-commits, rjmccall, timurrrr Differential Revision: http://reviews.llvm.org/D4938 llvm-svn: 216251
2014-08-21Pass expressions instead of argument ranges to EmitCall/EmitCXXConstructorCall.Alexey Samsonov1-12/+5
Summary: This is a first small step towards passing generic "Expr" instead of ArgBeg/ArgEnd pair into EmitCallArgs() family of methods. Having "Expr" will allow us to get the corresponding FunctionDecl and its ParmVarDecls, thus allowing us to alter CodeGen depending on the function/parameter attributes. No functionality change. Test Plan: regression test suite Reviewers: rnk Reviewed By: rnk Subscribers: aemerson, cfe-commits Differential Revision: http://reviews.llvm.org/D4915 llvm-svn: 216214
2014-08-19ext_vector IRGen. Patch to allow indexing into Fariborz Jahanian1-0/+2
ext_vector_type's 'hi/lo' components when used as lvalue. rdar://18031917 pr20697 llvm-svn: 215991
2014-08-13Header guard canonicalization, clang part.Benjamin Kramer1-2/+2
Modifications made by clang-tidy with minor tweaks. llvm-svn: 215557
2014-08-06Objective-C ARC. First patch toward generating new APIsFariborz Jahanian1-1/+2
for Objective-C's array and dictionary literals. rdar://17554063. This is wip. llvm-svn: 214983
2014-08-05Introduce f[no-]max-unknown-pointer-align=[number] optionFariborz Jahanian1-1/+6
to instruct the code generator to not enforce a higher alignment than the given number (of bytes) when accessing memory via an opaque pointer or reference. Patch reviewed by John McCall (with post-commit review pending). rdar://16254558 llvm-svn: 214911
2014-08-04Remove separator parameter from static local naming codeReid Kleckner1-1/+0
It was always set to ".", which was duplicated in a few places. llvm-svn: 214792
2014-07-26MS ABI: Use musttail for vtable thunks that pass arguments by valueReid Kleckner1-0/+4
This moves some memptr specific code into the generic thunk emission codepath. Fixes PR20053. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D4613 llvm-svn: 214004
2014-07-26Remove an extra parameter and C++11 for loop-ify this codeReid Kleckner1-2/+1
llvm-svn: 214003