summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
* Don't rely on implicit CallSite construction.Benjamin Kramer2015-04-101-1/+1
| | | | llvm-svn: 234600
* [OPENMP] Codegen for 'reduction' clause in 'parallel' directive.Alexey Bataev2015-04-104-131/+592
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Emit a code for reduction clause. Next code should be emitted for reductions: static kmp_critical_name lock = { 0 }; void reduce_func(void *lhs[<n>], void *rhs[<n>]) { ... *(Type<i> *)lhs[i] = RedOp<i>(*(Type<i> *)lhs[i], *(Type<i> *)rhs[i]); ... } ... void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n> - 1]}; switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>)) { case 1: ... <LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]); ... __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>); break; case 2: ... Atomic(<LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i])); ... break; default: ; } Reduction variables are a kind of a private variables, they have private copies, but initial values are chosen in accordance with the reduction operation. Differential Revision: http://reviews.llvm.org/D8915 llvm-svn: 234583
* Remove threshold for inserting lifetime markers for named temporariesArnaud A. de Grandmaison2015-04-107-34/+100
| | | | | | | | | | | | | | | | | | | Now that TailRecursionElimination has been fixed with r222354, the threshold on size for lifetime marker insertion can be removed. This only affects named temporary though, as the patch for unnamed temporaries is still in progress. My previous commit (r222993) was not handling debuginfo correctly, but this could only be seen with some asan tests. Basically, lifetime markers are just instrumentation for the compiler's usage and should not affect debug information; however, the cleanup infrastructure was assuming it contained only destructors, i.e. actual code to be executed, and was setting the breakpoint for the end of the function to the closing '}', and not the return statement, in order to show some destructors have been called when leaving the function. This is wrong when the cleanups are only lifetime markers, and this is now fixed. llvm-svn: 234581
* [OPENMP] Fixed cleanup of OpenMP code.Alexey Bataev2015-04-101-28/+15
| | | | llvm-svn: 234575
* [OPENMP] Fixing troubles with lambdas in cleanups.Alexey Bataev2015-04-101-20/+23
| | | | llvm-svn: 234572
* [OPENMP] Fixed incompatibility with MSVC, NFC.Alexey Bataev2015-04-101-8/+17
| | | | llvm-svn: 234568
* [OPENMP] Refactoring of codegen for OpenMP directives.Alexey Bataev2015-04-104-359/+480
| | | | | | | Refactored API of OpenMPRuntime for compatibility with combined directives. Differential Revision: http://reviews.llvm.org/D8859 llvm-svn: 234564
* Revert r234532 for a bit, it very likely caused http://crbug.com/475768Nico Weber2015-04-104-166/+133
| | | | llvm-svn: 234563
* [CodeGen] Do a more principled fix for PR231653, always use the inner type.Benjamin Kramer2015-04-091-10/+9
| | | | | | | We were still using the MaterializeTemporaryExpr's type to check if the transform is legal. Always use the inner Expr type. llvm-svn: 234543
* Update for LLVM api changes.Rafael Espindola2015-04-091-9/+4
| | | | llvm-svn: 234536
* [SEH] Outline finally blocks using the new variable capture supportReid Kleckner2015-04-094-133/+166
| | | | | | | | | | | | | | | WinEHPrepare was going to have to pattern match the control flow merge and split that the old lowering used, and that wasn't really feasible. Now we can teach WinEHPrepare to pattern match this, which is much simpler: %fp = call i8* @llvm.frameaddress(i32 0) call void @func(iN [01], i8* %fp) This prototype happens to match the prototype used by the Win64 SEH personality function, so this is really simple. llvm-svn: 234532
* [CodeGen] When promoting a reference temporary to a global use the inner ↵Benjamin Kramer2015-04-091-3/+4
| | | | | | | | | type to fold it. The MaterializeTemporaryExpr can have a different type than the inner expression, miscompiling the constant. PR23165. llvm-svn: 234499
* Process the -freciprocal-math optimization flag (PR20912)Sanjay Patel2015-04-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | The driver currently accepts but ignores the -freciprocal-math flag. This patch passes the flag through and enables 'arcp' fast-math-flag generation in IR. Note that this change does not actually enable the optimization for any target. The reassociation optimization that this flag specifies was implemented by http://reviews.llvm.org/D6334 : http://llvm.org/viewvc/llvm-project?view=revision&revision=222510 Because the optimization is done in the backend rather than IR, the backend must be modified to understand instruction-level fast-math-flags or a new function-level attribute must be created. Also note that -freciprocal-math is independent of any target-specific usage of reciprocal estimate hardware instructions. That requires its own flag ('-mrecip'). https://llvm.org/bugs/show_bug.cgi?id=20912 llvm-svn: 234493
* [WinEH] Don't wrap cleanups in terminate actionsReid Kleckner2015-04-081-3/+10
| | | | | | | | _CxxFrameHandler3 calls terminate if a cleanup action throws, regardless of what bits you put in the xdata tables. There's no need to model this in the IR, since we just have to take it out later. llvm-svn: 234448
* Reland "[SEH] Implement filter capturing in CodeGen"Reid Kleckner2015-04-083-20/+133
| | | | | | | | | | | The test should be fixed. It was failing in NDEBUG builds due to a missing '*' character in a regex. In asserts builds, the pattern matched a single digit value, which became a double digit value in NDEBUG builds. Go figure. This reverts commit r234261. llvm-svn: 234447
* Revert "Fix a compiler error under MSVC"Duncan P. N. Exon Smith2015-04-071-1/+1
| | | | | | | This reverts the bandaid commit in r234308 now that I have a proper fix in LLVM as of r234326. llvm-svn: 234339
* DebugInfo: LLVM API change in r234326 for array-like tuple wrappersDuncan P. N. Exon Smith2015-04-071-9/+7
| | | | | | | | | Update a few calls to `DIBuilder` now that `MDTuple` array-wrappers don't have implicit conversions to `MDTuple*`. I may circle back and update `DIBuilder` to take arrays here, to make it easier for the callers. llvm-svn: 234327
* Fix a compiler error under MSVCTimur Iskhodzhanov2015-04-071-1/+1
| | | | | | | | | Error message was: CGDebugInfo.cpp(1047) : error C2666: 'llvm::MDTypeRefArray::operator []' : 2 overloads have similar conversions DebugInfoMetadata.h(106): could be 'llvm::MDTypeRef llvm::MDTypeRefArray::operator [](unsigned int) const' while trying to match the argument list '(llvm::DITypeArray, int)' llvm-svn: 234308
* Revert "[SEH] Implement filter capturing in CodeGen"Daniel Jasper2015-04-073-133/+20
| | | | | | | Test fails: http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/3182/ llvm-svn: 234306
* DebugInfo: Update for LLVM change in r234290Duncan P. N. Exon Smith2015-04-071-4/+4
| | | | | | The API for `DIArray` changed; use the new one. llvm-svn: 234291
* [WinEH] Don't create an alloca for unnamed catch parametersReid Kleckner2015-04-071-1/+3
| | | | | | | | The catch object parameter to llvm.eh.begincatch is optional, and can be null. We can save some ourselves the stack space, copy ctor, and dtor calls if we pass null. llvm-svn: 234264
* [SEH] Implement filter capturing in CodeGenReid Kleckner2015-04-063-20/+133
| | | | | | | | | | | | | | | While capturing filters aren't very common, we'd like to outline __finally blocks in the frontend to simplify -O0 EH preparation and reduce code size. Finally blocks are usually have captures, and this is the first step towards that. Currently we don't support capturing 'this' or VLAs. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D8825 llvm-svn: 234261
* CGDebugInfo: Stop using DIDescriptor::is*() and auto-castingDuncan P. N. Exon Smith2015-04-061-41/+45
| | | | | | | The clang edition of r234255: use built-in `isa<>`, `dyn_cast<>`, etc., and only build `DIDescriptor`s from pointers that are correctly typed. llvm-svn: 234256
* DebugInfo: Use DILexicalBlockFile::getContext() over getScope()Duncan P. N. Exon Smith2015-04-061-1/+1
| | | | | | | | `getScope()` passes the scope back through a `DILexicalBlock` even though the underlying pointer may be an incompatible `MDSubprogram`. Just use `getContext()` directly. llvm-svn: 234245
* Don't crash when passing a non-existent file to -fprofile-instr-use=.Nico Weber2015-04-061-2/+2
| | | | | | Fixes a regression from r229434. llvm-svn: 234141
* clang-format my last commitDavid Blaikie2015-04-0511-81/+97
| | | | | | (sorry, keep forgetting that) llvm-svn: 234129
* [opaque pointer type] More GEP API migrationsDavid Blaikie2015-04-0520-170/+189
| | | | | | | Looks like the VTable code in particular will need some work to pass around the pointee type explicitly. llvm-svn: 234128
* [opaque pointer type] More GEP API migrationsDavid Blaikie2015-04-043-13/+17
| | | | llvm-svn: 234109
* [opaque pointer type] more GEP API migrationsDavid Blaikie2015-04-047-31/+34
| | | | llvm-svn: 234097
* [MS ABI] A pointer-to-function cannot be caught as a pointer-to-voidDavid Majnemer2015-04-041-3/+4
| | | | | | | | Don't assume that all pointers are convertible to void pointer. Instead correctly respect [conv.ptr]p2; only allow pointer types with an object pointee type to be caught as pointer-to-void. llvm-svn: 234090
* [opaque pointer type] Explicitly specify some types for GEPDavid Blaikie2015-04-031-4/+5
| | | | | | | Not all of them (there's still a fallback for this specific function that omits the type parameter) but it's some I bothered to do now. llvm-svn: 234063
* [i386 ABI] expand small C like structs in C++, just like how we handle smallManman Ren2015-04-031-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | C structs. This comes up when we have a function that takes a struct and is defined in a C++ file and used in a C file. Before this commit, we will generate byval for C++ and will expand the struct for C, thus causing difference at IR level. We will use bitcast of function type at the callsite, which causes the inliner to not inline the function. This commit changes how we handle small C like structs at IR level, but at backend, we should generate the same argument passing before and after the commit. Note that the condition for expanding is still over conservative. We should be able to expand type that is spelled with “class” and types that are not C-like. But this commit fixes the inconsistent argument passing between C/C++. Reviewed by John. rdar://20121030 llvm-svn: 234033
* [opaque pointer type] Explicitly specify type to CreateGEPDavid Blaikie2015-04-031-2/+2
| | | | llvm-svn: 234032
* [opaque pointer type] Update for GEP API changes in LLVMDavid Blaikie2015-04-028-40/+51
| | | | | | | | | | Now the GEP constant utility functions require the type to be explicitly passed (since eventually the pointer type will be opaque and not convey the required type information). For now callers can still pass nullptr (though none were needed here in Clang, which is nice) if convenienc/necessary, but eventually that will be disallowed as well. llvm-svn: 233937
* Implement CFI type checks for non-virtual calls.Peter Collingbourne2015-04-024-10/+21
| | | | | | | | | | | | This uses the same class metadata currently used for virtual call and cast checks. The new flag is -fsanitize=cfi-nvcall. For consistency, the -fsanitize=cfi-vptr flag has been renamed -fsanitize=cfi-vcall. Differential Revision: http://reviews.llvm.org/D8756 llvm-svn: 233874
* [SystemZ] Support transactional execution on zEC12Ulrich Weigand2015-04-012-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The zEC12 provides the transactional-execution facility. This is exposed to users via a set of builtin routines on other compilers. This patch adds clang support to enable those builtins. In partciular, the patch: - enables the transactional-execution feature by default on zEC12 - allows to override presence of that feature via the -mhtm/-mno-htm options - adds a predefined macro __HTM__ if the feature is enabled - adds support for the transactional-execution GCC builtins - adds Sema checking to verify the __builtin_tabort abort code - adds the s390intrin.h header file (for GCC compatibility) - adds s390 sections to the htmintrin.h and htmxlintrin.h header files Since this is first use of target-specific intrinsics on the platform, the patch creates the include/clang/Basic/BuiltinsSystemZ.def file and hooks it up in TargetBuiltins.h and lib/Basic/Targets.cpp. An associated LLVM patch adds the required LLVM IR intrinsics. For reference, the transactional-execution instructions are documented in the z/Architecture Principles of Operation for the zEC12: http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/download/DZ9ZR009.pdf The associated builtins are documented in the GCC manual: http://gcc.gnu.org/onlinedocs/gcc/S_002f390-System-z-Built-in-Functions.html The htmxlintrin.h intrinsics provided for compatibility with the IBM XL compiler are documented in the "z/OS XL C/C++ Programming Guide". llvm-svn: 233804
* [MS ABI] Disregard restrictive exception specificationsDavid Majnemer2015-04-011-0/+8
| | | | | | | | | | | MSVC treats all non-empty exception specifications the same way: all exceptions are permitted. The .xdata tables provide a way to efficiently lower exception specifications *but* this probably has to be implemented as a catch-all/rethrow mechanism instead of the Itanium way. This fixes PR23092. llvm-svn: 233787
* [Objective-C metadata patch]. Patch to allocate one more space for Fariborz Jahanian2015-03-311-1/+7
| | | | | | Protocol objects in OBJC2. rdar://20286356 llvm-svn: 233766
* DebugInfo: Use new LLVM API for DebugLocDuncan P. N. Exon Smith2015-03-303-3/+3
| | | | | | | Use the new API for `DebugLoc` added in r233573 before the old one disappears. llvm-svn: 233589
* [PPC] Move argument range checks for HTM and crypto builtins to SemaKit Barton2015-03-301-113/+0
| | | | | | | | | | | The argument range checks for the HTM and Crypto builtins were implemented in CGBuiltin.cpp, not in Sema. This change moves them to the appropriate location in SemaChecking.cpp. It requires the creation of a new method in the Sema class to do checks for PPC-specific builtins. http://reviews.llvm.org/D8672 llvm-svn: 233586
* [SystemZ] Fix some ABI corner casesUlrich Weigand2015-03-301-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Running the GCC's inter-compiler ABI compatibility test suite uncovered a couple of errors in clang's SystemZ ABI implementation. These all affect only rare corner cases: - Short vector types GCC synthetic vector types defined with __attribute__ ((vector_size ...)) are always passed and returned by reference. (This is not documented in the official ABI document, but is the de-facto ABI implemented by GCC.) clang would do that only for vector sizes >= 16 bytes, but not for shorter vector types. - Float-like aggregates and empty bitfields clang would consider any aggregate containing an empty bitfield as first element to be a float-like aggregate. That's obviously wrong. According to the ABI doc, the presence of an empty bitfield makes an aggregate to be *not* float-like. However, due to a bug in GCC, empty bitfields are ignored in C++; this patch changes clang to be compatible with this "feature" of GCC. - Float-like aggregates and va_arg The va_arg implementation would mis-detect some aggregates as float-like that aren't actually passed as such. This applies to aggregates that have only a single element of type float or double, but using an aligned attribute that increases the total struct size to more than 8 bytes. This error occurred because the va_arg implement used to have an copy of the float-like aggregate detection logic (i.e. it would call the isFPArgumentType routine, but not perform the size check). To simplify the logic, this patch removes the duplicated logic and instead simply checks the (possibly coerced) LLVM argument type as already determined by classifyArgumentType. llvm-svn: 233543
* [OPENMP] Codegen for 'atomic update' construct.Alexey Bataev2015-03-304-53/+246
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds atomic update codegen for the following forms of expressions: x binop= expr; x++; ++x; x--; --x; x = x binop expr; x = expr binop x; If x and expr are integer and binop is associative or x is a LHS in a RHS of the assignment expression, and atomics are allowed for type of x on the target platform atomicrmw instruction is emitted. Otherwise compare-and-swap sequence is emitted: bb: ... atomic load <x> cont: <expected> = phi [ <x>, label %bb ], [ <new_failed>, %cont ] <desired> = <expected> binop <expr> <res> = cmpxchg atomic &<x>, desired, expected <new_failed> = <res>.field1; br <res>field2, label %exit, label %cont exit: ... Differential Revision: http://reviews.llvm.org/D8536 llvm-svn: 233513
* [OPENMP] Improved codegen for implicit/explicit 'barrier' constructs.Alexey Bataev2015-03-303-17/+33
| | | | | | | Replace boolean IsExplicit parameter of OpenMPRuntime::emitBarrierCall() method by OpenMPDirectiveKind Kind for better compatibility with the runtime library. Also add processing of 'nowait' clause on worksharing directives. Differential Revision: http://reviews.llvm.org/D8659 llvm-svn: 233511
* [MS ABI] Rework .xdata HandlerType emissionDavid Majnemer2015-03-296-35/+35
| | | | | | | | | | Utilizing IMAGEREL relocations for synthetic IR constructs isn't valuable, just clutter. While we are here, simplify HandlerType names by making the numeric value for the 'adjective' part of the mangled name instead of appending '.const', etc. The old scheme made for very long global names and leads to wordy things like '.std_bad_alloc' llvm-svn: 233503
* DebugInfo: Don't call DIBuilder::retainType(nullptr)Duncan P. N. Exon Smith2015-03-271-3/+4
| | | | | | | | | | An upcoming LLVM commit will make calling `DIBuilder::retainType(nullptr)` illegal (actually, it already was, but it wasn't verified). Check for null before calling. This triggered in test/CodeGenObjC/debug-info-block-helper.m. llvm-svn: 233443
* Reapply r232888 after applying a fix for -msse4 code generation.Eric Christopher2015-03-251-0/+21
| | | | | | | As a note, any target that uses fake target features via command line options will have similar problems. llvm-svn: 233227
* Fix addrspace when emitting constructors of static local variablesJingyue Wu2015-03-251-0/+23
| | | | | | | | | | | | | | | | | | | | Summary: Due to CUDA's implicit address space casting, the type of a static local variable may be more specific (i.e. with address space qualifiers) than the type expected by the constructor. Emit an addrspacecast in that case. Test Plan: Clang used to crash on the added test. Reviewers: nlewycky, pcc, eliben, rsmith Reviewed By: eliben, rsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8575 llvm-svn: 233208
* Add Hardware Transactional Memory (HTM) SupportKit Barton2015-03-251-0/+85
| | | | | | | | | | | | | | | | | | | | | | | | This patch adds Hardware Transaction Memory (HTM) support supported by ISA 2.07 (POWER8). The intrinsic support is based on GCC one [1], with both 'PowerPC HTM Low Level Built-in Functions' and 'PowerPC HTM High Level Inline Functions' implemented. Along with builtins a new driver switch is added to enable/disable HTM instruction support (-mhtm) and a header with common definitions (mostly to parse the TFHAR register value). The HTM switch also sets a preprocessor builtin HTM. The HTM usage requires a recently newer kernel with PPC HTM enabled. Tested on powerpc64 and powerpc64le. This is send along a llvm patch to enabled the builtins and option switch. [1] https://gcc.gnu.org/onlinedocs/gcc/PowerPC-Hardware-Transactional-Memory-Built-in-Functions.html Phabricator Review: http://reviews.llvm.org/D8248 llvm-svn: 233205
* InstrProf: Handle whitespace and comments at the ends of macrosJustin Bogner2015-03-251-4/+4
| | | | | | | | | | | | | | | When we try to find the end loc for a token, we have to re-lex the token. This was running into a problem when we'd store the end loc of a macro's coverage region, since we wouldn't actually be at the beginning of a token when we tried to re-lex it, leading us to do silly things (and eventually assert) when whitespace or comments followed. This pushes our use of getPreciseTokenLocEnd earlier, so that we won't call it when it doesn't make sense to. It also removes an unnecessary adjustment by 1 that was working around this problem in some cases. llvm-svn: 233169
* [CodeGen] Support native half inc/dec amounts.Ahmed Bougacha2015-03-241-1/+6
| | | | | | | | We previously defaulted to long double, but it's also possible to have a half inc/dec amount, when LangOpts NativeHalfType is set. Currently, that's only true for OpenCL. llvm-svn: 233135
OpenPOWER on IntegriCloud