summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
Commit message (Collapse)AuthorAgeFilesLines
...
* [OPENMP] Small refactoring of EmitOMPSimdLoop helper routine.Alexander Musman2014-10-072-17/+18
| | | | | | | | | 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
* Using an explicit cast to work around MSVC 2013 not picking the conversion ↵Aaron Ballman2014-10-061-1/+1
| | | | | | operator as expected. NFC, should fix the MSVC build bots. llvm-svn: 219116
* Add FIXME/notes to the future.David Blaikie2014-10-061-0/+5
| | | | llvm-svn: 219104
* DebugInfo: Don't include implicit special members in the list of class membersDavid Blaikie2014-10-061-18/+17
| | | | | | | | By leaving these members out of the member list, we avoid them being emitted into type unit definitions - while still allowing the definition/declaration to be injected into the compile unit as expected. llvm-svn: 219101
* DebugInfo: Don't include member function template specializations in the ↵David Blaikie2014-10-061-10/+0
| | | | | | | | | | list of class members By leaving these members out of the member list, we avoid them being emitted into type unit definitions - while still allowing the definition/declaration to be injected into the compile unit as expected. llvm-svn: 219100
* MS ABI: Implement thread_local for global variablesDavid Majnemer2014-10-058-98/+194
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Emit @llvm.assume for non-parameter lvalue align_value-attribute loadsHal Finkel2014-10-041-3/+41
| | | | | | | | | | | | | | | | | | | | | We already add the align parameter attribute for function parameters that have the align_value attribute (or those with a typedef type having that attribute), which is an important special case, but does not handle pointers with value alignment assumptions that come into scope in any other way. To handle the general case, emit an @llvm.assume-based alignment assumption whenever we load the pointer-typed lvalue of an align_value-attributed variable (except for function parameters, which we already deal with at entry). I'll also note that this is more general than Intel's described support in: https://software.intel.com/en-us/articles/data-alignment-to-assist-vectorization which states that the compiler inserts __assume_aligned directives in response to align_value-attributed variables only for function parameters and for the initializers of local variables. I think that we can make the optimizer deal with this more-general scheme (which could lead to a lot of calls to @llvm.assume inside of loop bodies, for example), but if not, I'll rework this to be less aggressive. llvm-svn: 219052
* CFE Knob for: Add a thread-model knob for lowering atomics on baremetal & ↵Jonathan Roelofs2014-10-031-0/+5
| | | | | | | | single threaded systems http://reviews.llvm.org/D4985 llvm-svn: 219027
* Add getOpenMPSimdDefaultAlignment for PowerPCHal Finkel2014-10-031-0/+12
| | | | | | | | | | | | When the aligned clause of an OpenMP simd pragma is not provided with an explicit alignment, a target-dependent default must be used. This adds such a default of PPC targets. This will become slightly more complicated when BG/Q support is added (because then it will depend on the type). For now, 16 is a correct value for all systems, and covers Altivec and VSX vectors. llvm-svn: 218994
* Initial support for the align_value attributeHal Finkel2014-10-021-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds support for the align_value attribute. This attribute is supported by Intel's compiler (versions 14.0+), and several of my HPC users have requested support in Clang. It specifies an alignment assumption on the values to which a pointer points, and is used by numerical libraries to encourage efficient generation of vector code. Of course, we already have an aligned attribute that can specify enhanced alignment for a type, so why is this additional attribute important? The problem is that if you want to specify that an input array of T is, say, 64-byte aligned, you could try this: typedef double aligned_double attribute((aligned(64))); void foo(aligned_double *P) { double x = P[0]; // This is fine. double y = P[1]; // What alignment did those doubles have again? } the access here to P[1] causes problems. P was specified as a pointer to type aligned_double, and any object of type aligned_double must be 64-byte aligned. But if P[0] is 64-byte aligned, then P[1] cannot be, and this access causes undefined behavior. Getting round this problem requires a lot of awkward casting and hand-unrolling of loops, all of which is bad. With the align_value attribute, we can accomplish what we'd like in a well defined way: typedef double *aligned_double_ptr attribute((align_value(64))); void foo(aligned_double_ptr P) { double x = P[0]; // This is fine. double y = P[1]; // This is fine too. } This attribute does not create a new type (and so it not part of the type system), and so will only "propagate" through templates, auto, etc. by optimizer deduction after inlining. This seems consistent with Intel's implementation (thanks to Alexey for confirming the various Intel-compiler behaviors). As a final note, I would have chosen to call this aligned_value, not align_value, for better naming consistency with the aligned attribute, but I think it would be more useful to users to adopt Intel's name. llvm-svn: 218910
* Add __sync_fetch_and_nand (again)Hal Finkel2014-10-021-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to GCC 4.4, __sync_fetch_and_nand was implemented as: { tmp = *ptr; *ptr = ~tmp & value; return tmp; } but this was changed in GCC 4.4 to be: { tmp = *ptr; *ptr = ~(tmp & value); return tmp; } in response to this change, support for sync_fetch_and_nand (and sync_nand_and_fetch) was removed in r99522 in order to avoid miscompiling code depending on the old semantics. However, at this point: 1. Many years have passed, and the amount of code relying on the old semantics is likely smaller. 2. Through the work of many contributors, all LLVM backends have been updated such that "atomicrmw nand" provides the newer GCC 4.4+ semantics (this process was complete July of 2014 (added to the release notes in r212635). 3. The lack of this intrinsic is now a needless impediment to porting codes from GCC to Clang (I've now seen several examples of this). It is true, however, that we still set GNUC_MINOR to 2 (corresponding to GCC 4.2). To compensate for this, and to address the original concern regarding code relying on the old semantics, I've added a warning that specifically details the fact that the semantics have changed and that we provide the newer semantics. Fixes PR8842. llvm-svn: 218905
* [x32/NaCl] Check if method pointers straddle an eightbyte to classify HiJan Wen Voung2014-10-021-3/+18
| | | | | | | | | | | | | | | | | | | | Summary: Currently, with struct my_struct { int x; method_ptr y; }; a call to foo(my_struct s) may end up dropping the last 4 bytes of the method pointer for x86_64 NaCl and x32. When checking Has64BitPointers, also check if the method pointer straddles an eightbyte boundary and classify Hi as well as Lo if needed. Test Plan: test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp Reviewers: dschuff, pavel.v.chupin Subscribers: jfb Differential Revision: http://reviews.llvm.org/D5555 llvm-svn: 218889
* Reapply "InstrProf: Update for the LLVM API change in r218879"Justin Bogner2014-10-023-15/+7
| | | | | | | | Reapplying now that r218887 is in. This reverts commit r218882, reapplying r218880. llvm-svn: 218888
* Revert "InstrProf: Update for the LLVM API change in r218879"Justin Bogner2014-10-023-7/+15
| | | | | | | | r218879 has been reverted for now, this needs to go to match. This reverts commit r218880. llvm-svn: 218882
* InstrProf: Update for the LLVM API change in r218879Justin Bogner2014-10-023-15/+7
| | | | llvm-svn: 218880
* Emit lifetime.start / lifetime.end markers for unnamed temporary objects.Arnaud A. de Grandmaison2014-10-025-32/+124
| | | | | | | This will give more information to the optimizers so that they can reuse stack slots and reduce stack usage. llvm-svn: 218865
* DIBuilder: Encapsulate DIExpression's element typeDuncan P. N. Exon Smith2014-10-011-18/+16
| | | | | | | Update for corresponding LLVM API change for `DIBuilder::createExpression()`. llvm-svn: 218798
* Update CGDebugInfo to the updated API in LLVM.Adrian Prantl2014-10-011-21/+25
| | | | | | | | | | Complex address expressions are no longer part of DIVariable, but rather an extra argument to the debug intrinsics. http://reviews.llvm.org/D4919 rdar://problem/17994491 llvm-svn: 218788
* Reverting r218777 while investigating buildbot breakage.Adrian Prantl2014-10-011-25/+21
| | | | | | "Update CGDebugInfo to the updated API in LLVM." llvm-svn: 218781
* Update CGDebugInfo to the updated API in LLVM.Adrian Prantl2014-10-011-21/+25
| | | | | | | | | | Complex address expressions are no longer part of DIVariable, but rather an extra argument to the debug intrinsics. http://reviews.llvm.org/D4919 rdar://problem/17994491 llvm-svn: 218777
* Adds 'override' to overriding methods. NFC.Fariborz Jahanian2014-10-011-1/+1
| | | | | | These were uncoveredby my yet undelivered patch. llvm-svn: 218774
* [OPENMP] Loop collapsing and codegen for 'omp simd' directive.Alexander Musman2014-10-012-3/+203
| | | | | | | | | | | | | 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
* InstrProf: Avoid repeated linear searches in a hot pathJustin Bogner2014-10-011-51/+33
| | | | | | | | | | | | | | | | | | | | | | When generating coverage regions, we were doing a linear search through the existing regions in order to try to merge related ones. Most of the time this would find what it was looking for in a small number of steps and it wasn't a big deal, but in cases with many regions and few mergeable ones this leads to an absurd compile time regression. This changes the coverage mapping logic to do a single sort and then merge as we go, which is a bit simpler and about 100 times faster. I've also added FIXMEs on a couple of behaviours that seem a little suspect, while keeping them behaving as they were - I'll look into these soon. The test changes here are mostly tedious reorganization, because the ordering of regions we output has become slightly (but not completely) more consistent from the almost completely arbitrary ordering we got before. llvm-svn: 218738
* InstrProf: Hide SourceMappingRegion's internals (NFC)Justin Bogner2014-10-011-12/+31
| | | | | | | | This struct has some members that are accessed directly and others that need accessors, but it's all just public. This is confusing, so I've changed it to a class and made more members private. llvm-svn: 218737
* InstrProf: Remove an unused member (NFC)Justin Bogner2014-09-301-6/+3
| | | | llvm-svn: 218697
* [OPENMP] Codegen of the ‘aligned’ clause for the ‘omp simd’ directive.Alexander Musman2014-09-303-10/+62
| | | | | | Differential Revision: http://reviews.llvm.org/D5499 llvm-svn: 218660
* Use ClangToLLVMArgsMapping in CodeGenTypes::GetFunctionType(). NFC.Alexey Samsonov2014-09-292-183/+200
| | | | | | | | | | | This is the last piece of CGCall code that had implicit assumptions about the order in which Clang arguments are translated to LLVM ones (positions of inalloca argument, sret, this, padding arguments etc.) Now all of this data is encapsulated in ClangToLLVMArgsMapping. If this information would be required somewhere else, this class can be moved to a separate header or pulled into CGFunctionInfo. llvm-svn: 218634
* Introduce CGFunctionInfo::getNumRequiredArgs(). NFC.Alexey Samsonov2014-09-292-23/+11
| | | | | | Save the callers from necessity to special-case on variadic functions. llvm-svn: 218625
* Speedup ClangToLLVMArgMapping construction. NFC.Alexey Samsonov2014-09-291-6/+18
| | | | | | | | Add a method to calculate the number of arguments given QualType expnads to. Use this method in ClangToLLVMArgMapping calculation. This number may be cached in CodeGenTypes for efficiency, if needed. llvm-svn: 218623
* Refactor ABIArgInfo::Expand implementation (NFC).Alexey Samsonov2014-09-291-120/+155
| | | | | | | | Hoist the logic which determines the way QualType is expanded into a separate method. Remove a bunch of copy-paste and simplify getTypesFromArgs() / ExpandTypeFromArgs() / ExpandTypeToArgs() methods. llvm-svn: 218615
* Fix bug 20116 - http://llvm.org/bugs/show_bug.cgi?id=20116Alexey Bataev2014-09-291-10/+9
| | | | | | | | Fixes incorrect codegen when devirtualization is aborted due to covariant return types. Differential Revision: http://reviews.llvm.org/D5321 llvm-svn: 218602
* Remove dead code from DIBuilderJyoti Allur2014-09-291-3/+3
| | | | llvm-svn: 218593
* CodeGen: Don't crash when initializing pointer-to-member fields in basesDavid Majnemer2014-09-281-10/+26
| | | | | | | | | | | | | | | | | Clang uses two types to talk about a C++ class, the NonVirtualBaseLLVMType and the LLVMType. Previously, we would allow one of these to be packed and the other not. This is problematic. If both don't agree on a common subset of fields, then routines like getLLVMFieldNo will point to the wrong field. Solve this by copying the 'packed'-ness of the complete type to the non-virtual subobject. For this to work, we need to take into account the non-virtual subobject's size and alignment when we are computing the layout of the complete object. This fixes PR21089. llvm-svn: 218577
* Small fix for bug 18635.Alexander Musman2014-09-261-7/+8
| | | | | | | | (clang crashed in CodeGen in llvm::Module::getNamedValue on thread_local std::unique_ptr<int>). Differential Revision: http://reviews.llvm.org/D5353 llvm-svn: 218503
* Support the assume_aligned function attributeHal Finkel2014-09-261-54/+71
| | | | | | | | | In addition to __builtin_assume_aligned, GCC also supports an assume_aligned attribute which specifies the alignment (and optional offset) of a function's return value. Here we implement support for the assume_aligned attribute by making use of the @llvm.assume intrinsic. llvm-svn: 218500
* CGBuiltin: Use frem instruction rather than libcall to implement fmodJan Vesely2014-09-261-0/+8
| | | | | | | | AFAICT the semantics of frem match libm's fmod. Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu> Reviewed-by: Tom Stellard <tom@stellard.net> llvm-svn: 218488
* Include debug info for types referenced only via explicit cast expressions.David Blaikie2014-09-243-0/+15
| | | | | | | | | | | | | | | | | | | | | | | Most of the debug info emission is powered essentially from function definitions - if we emit the definition of a function, we emit the types of its parameters, the members of those types, and so on and so forth. For types that aren't referenced even indirectly due to this - because they only appear in temporary expressions, not in any named variable, we need to explicitly emit/add them as is done here. This is not the only case of such code, and we might want to consider handling "void func(void*); ... func(new T());" (currently debug info for T is not emitted) at some point, though GCC doesn't. There's a much broader solution to these issues, but it's a lot of work for possibly marginal gain (but might help us improve the default -fno-standalone-debug behavior to be even more aggressive in some places). See the original review thread for more details. Patch by jyoti allur (jyoti.yalamanchili@gmail.com)! Differential Revision: http://reviews.llvm.org/D2498 llvm-svn: 218390
* Revert "Don't use comdats for initializers on platforms that don't support it"Reid Kleckner2014-09-234-12/+2
| | | | | | | | | On further investigation, COMDATs should work with .ctors, and the issue I was hitting probably reproduces with .init_array. This reverts commit r218287. llvm-svn: 218313
* [OPENMP] Parsing/Sema of directive omp parallel for simdAlexander Musman2014-09-233-0/+9
| | | | llvm-svn: 218299
* Don't use comdats for initializers on platforms that don't support itReid Kleckner2014-09-234-2/+12
| | | | | | | | | In particular, pre-.init_array ELF uses the .ctors section mechanism. MinGW COFF also uses .ctors, now that I think about it. Therefore, restrict this optimization to the two platforms that are currently known to work: ELF with .init_array and COFF with .CRT$XCU. llvm-svn: 218287
* [mips] Correct alignment of vectors passed in varargs for the O32 ABI.Daniel Sanders2014-09-221-1/+2
| | | | | | | | | | | | | | | | | | | Summary: Vectors are normally 16-byte aligned, however the O32 ABI enforces a maximum alignment of 8-bytes since the base of the stack is 8-byte aligned. Previously, this was enforced on the caller side, but not on the callee side. This fixes the output of OpenCL's printf when given vectors. Reviewers: atanasyan Reviewed By: atanasyan Subscribers: llvm-commits, pekka.jaaskelainen Differential Revision: http://reviews.llvm.org/D5433 llvm-svn: 218248
* removed unicode symbols from comments.Alexey Bataev2014-09-222-13/+13
| | | | llvm-svn: 218244
* [OPENMP] Codegen for 'omp critical' directive.Alexey Bataev2014-09-223-5/+118
| | | | | | | | | | | This patch adds codegen for constructs: #pragma omp critical [name] <body> It generates global variable ".gomp_critical_user_[name].var" of type int32[8]. Then it generates library call "kmpc_critical(loc, gtid, .gomp_critical_user_[name].var)", code for <body> statement and final call "kmpc_end_critical(loc, gtid, .gomp_critical_user_[name].var)". Differential Revision: http://reviews.llvm.org/D5202 llvm-svn: 218239
* Fix ctor/dtor aliases losing 'dllexport' (for Itanium ABI)Dario Domizioli2014-09-193-1/+17
| | | | | | | This patch makes sure that the dllexport attribute is transferred to the alias when such alias is created. It only affects the Itanium ABI because for the MSVC ABI a workaround is in place to not generate aliases of dllexport ctors/dtors. A new CodeGenModule function is provided, CodeGenModule::setAliasAttributes, to factor the code for transferring attributes to aliases. llvm-svn: 218159
* In the Itanium ABI, move stuff to the comdat of variables with static init.Rafael Espindola2014-09-191-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clang can already handle ------------------------------------------- struct S { static const int x; }; template<typename T> struct U { static const int k; }; template<typename T> const int U<T>::k = T::x; const int S::x = 42; extern const int *f(); const int *g() { return &U<S>::k; } int main() { return *f() + U<S>::k; } const int *f() { return &U<S>::k; } ------------------------------------------- since r217264 which puts the .inint_array section in the same COMDAT as the variable. This patch allows the linker to more easily delete some dead code and data by putting the guard variable and init function in the same COMDAT. This is a fixed version of r218089. llvm-svn: 218141
* [OPENMP] Initial parsing/sema analysis of 'target' directive.Alexey Bataev2014-09-193-0/+8
| | | | llvm-svn: 218110
* Don't use the third field of llvm.global_ctors for MachO.Rafael Espindola2014-09-193-2/+16
| | | | | | | | | | The field is defined as: If the third field is present, non-null, and points to a global variable or function, the initializer function will only run if the associated data from the current module is not discarded. And without COMDATs we can't implement that. llvm-svn: 218097
* Revert "Put more stuff in the comdat used for variables with static init."Rafael Espindola2014-09-194-23/+0
| | | | | | | This reverts commit r218089. It looks like it was causing issues on COFF. llvm-svn: 218094
* Put more stuff in the comdat used for variables with static init.Rafael Espindola2014-09-184-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clang can already handle ------------------------------------------- struct S { static const int x; }; template<typename T> struct U { static const int k; }; template<typename T> const int U<T>::k = T::x; const int S::x = 42; extern const int *f(); const int *g() { return &U<S>::k; } int main() { return *f() + U<S>::k; } const int *f() { return &U<S>::k; } ------------------------------------------- since r217264 which puts the .inint_array section in the same COMDAT as the variable. This patch allows the linker to more easily delete some dead code and data by putting the guard variable and init function in the same COMDAT. llvm-svn: 218089
* MS ABI: Don't ICE for pointers to pointers to members of incomplete classesDavid Majnemer2014-09-185-14/+31
| | | | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud