This extends the blocks support to support blocks with a dynamically linked
blocks runtime. The previous code generation would work only for static builds
of the blocks runtime. Mark the block "isa" pointers and functions as dllimport
if no explicit declaration marked with __declspec(dllexport) is found. This
additional check allows for the use of the functionality in the runtime library
if desired.
Yaxun Liu [Sat, 28 May 2016 19:09:01 +0000 (19:09 +0000)]
[OpenCL] Add the default header file opencl-c.h for OpenCL C language
OpenCL has large number of "builtin" functions ("builtin" in the sense of OpenCL spec) which are defined in header files. To compile OpenCL kernels using these builtin functions, a header file is needed.
This header file is based on the Khronos implementation (https://github.com/KhronosGroup/SPIR/blob/spirv-1.0/lib/Headers/opencl.h) with heavy refactoring.
Diagnostics that happen during driver time do not have color output support
unless -fcolor-diagonostic is explicitly passed into the driver. This is not a
problem for cc1 since dianostic arguments are properly handled and color is
enabled by default if the terminal supports it.
Make the driver behave like CC1. There are tests that already check for these
flags, but for the color itself there's no sensible way to test it.
Dehao Chen [Fri, 27 May 2016 16:14:35 +0000 (16:14 +0000)]
Add instcombine pass if sampleprofile pass is enabled.
Summary: Sample profile pass need to have instcombine pass. A related change is http://reviews.llvm.org/D17742. But we should not explicitly add dependency between to non-analysis passes. So we add the dependency here.
Simon Dardis [Fri, 27 May 2016 15:13:31 +0000 (15:13 +0000)]
[mips] Compact branch policy setting.
This patch adds the commandline option -mcompact-branches={never,optimal,always),
which controls how LLVM generates compact branches for MIPSR6 targets. By default,
the compact branch policy is 'optimal' where LLVM will generate the most
appropriate branch for any situation. The 'never' and 'always' policy will disable
or always generate compact branches wherever possible respectfully.
Daniel Sanders [Fri, 27 May 2016 14:30:23 +0000 (14:30 +0000)]
[mips] Kill 'support' for untested EABI.
Summary:
There are no llvm backend tests* for EABI and no EABI buildbots. There were only
three clang tests, all of which checked that -mabi=eabi was passed to the
assembler.
*There is a single backend test that specifies EABI but it actually tests MIPS16.
Daniel Sanders [Fri, 27 May 2016 11:51:02 +0000 (11:51 +0000)]
[mips] Fold MipsTargetInfoBase subclasses into MipsTargetInfoBase and rename to MipsTargetInfo. NFC
Summary:
This unifies mips/mipsel and mips64/mips64el into a single class so that we can
later support O32 on mips64/mips64el and N32/N64 on mips/mipsel (when an
appropriate CPU selected).
David Majnemer [Fri, 27 May 2016 02:06:19 +0000 (02:06 +0000)]
[CodeGen] Don't crash when sizeof(long) != 4 for some intrins
_InterlockedIncrement and _InterlockedDecrement have 'long' in their
prototypes. We assumed 'long' was the same size as an i32 which is
incorrect for other targets.
Richard Smith [Thu, 26 May 2016 20:23:13 +0000 (20:23 +0000)]
Produce better pretty stack traces from crashes in template instantiation: add
pretty stack trace entries for all cases where we instantiate the definition of
something, and include the fully-qualified name with template arguments in the
name of the instantiated entity.
Also make explicit instantiation decls not apply to nested classes when
targeting MSVC. That dll attributes are not inherited by inner classes
might be the explanation for MSVC's behaviour here.
Samuel Antao [Thu, 26 May 2016 18:30:22 +0000 (18:30 +0000)]
[OpenMP] Codegen for target update directive.
Summary: This patch implements the code generation for the `target update` directive. The implemntation relies on the logic already in place for target data standalone directives, i.e. target enter/exit data.
Samuel Antao [Thu, 26 May 2016 17:30:50 +0000 (17:30 +0000)]
[OpenMP] Parsing and sema support for target update directive
Summary:
This patch is to add parsing and sema support for `target update` directive. Support for the `to` and `from` clauses will be added by a different patch. This patch also adds support for other clauses that are already implemented upstream and apply to `target update`, e.g. `device` and `if`.
This patch is based on the original post by Kelvin Li.
Samuel Antao [Thu, 26 May 2016 16:53:38 +0000 (16:53 +0000)]
[OpenMP] Add support for the 'private pointer' flag to signal variables captured in target regions and used in first-private clauses.
Summary: If a variable is implicitly mapped (doesn't show in a map clause), the runtime library has to be informed if the corresponding capture shows up in first-private clause, so that the storage previously allocated in the device is used. This patch adds the support for that.
Samuel Antao [Thu, 26 May 2016 16:48:10 +0000 (16:48 +0000)]
[OpenMP] Adjust map type bits according to latest spec and use zero size array sections for pointers.
Summary: This patch changes the bits used to specify the map types according to the latest version of the libomptarget document and add the support for zero size array section when pointers are being implicitly mapped. This completes the missing new 4.5 map semantics.
Summary:
Leaking a stack address via a static variable refers to it in the diagnostic as a 'global'. This patch corrects the diagnostic for static variables.
Olivier Goffart [Thu, 26 May 2016 12:55:34 +0000 (12:55 +0000)]
Fix crash while parsing variable template with variadic template arguments
It is only a crash if the compiler optimize for this!=nullptr because
LocalInstantiationScope::getPartiallySubstitutedPack checks if 'this' is null
(This is crashing when clang is compiled with GCC6)
If '-fopenmp' option is provided '-fopenmp-version=' allows to control,
which version of OpenMP must be supported. Currently it affects only the
value of _OPENMP define.
Alexey Bataev [Thu, 26 May 2016 04:56:05 +0000 (04:56 +0000)]
[OPENMP] Set '_OPENMP' macro to '201511' value to reflect support for
OpenMP 4.5.
According to OpenMP 4.5 the _OPENMP macro name is defined to have the decimal value yyyymm where yyyy and mm are the year and month designations of the version of the OpenMP API that the implementation supports. Clang supports OpenMP 4.5 so updated value of _OPENMP macro to 201511.
[Sema] Use the failure bits introduced by r270781.
r270781 introduced the ability to track whether or not we might have
had unmodeled side-effects during constant expression evaluation. This
patch makes the constexpr evaluator use that tracking.
[Sema] Note when we encounter a problem in ExprConstant.
Currently, the constexpr evaluator is very conservative about unmodeled
side-effects when we're evaluating an expression in a mode that allows
such side-effects.
This patch makes us note when we might have actually encountered an
unmodeled side-effect, which allows us to be more accurate when we know
an unmodeled side-effect couldn't have occurred.
This patch has been split into two commits; this one primarily
introduces the bits necessary to track whether we might have potentially
hit such a side-effect. The one that actually does the tracking (which
boils down to more or less a rename of keepEvaluatingAfterFailure to
noteFailure) is coming soon.
Hal Finkel [Wed, 25 May 2016 22:08:27 +0000 (22:08 +0000)]
[CGDebugInfo] Modify the preferred expression location for member calls.
If the callee has a valid location (not all do), then use that. Otherwise, fall
back to the starting location. This makes sure that the debug info for calls
points to the call (not the start of the expression providing the object on
which the member function is being called).
For example, given this:
f->foo()->bar();
we don't want both calls to point to the 'f', but rather to the 'foo()' and
the 'bar()'.
Richard Smith [Wed, 25 May 2016 22:06:25 +0000 (22:06 +0000)]
Fix rejects-valid on constexpr function that accesses a not-yet-defined 'extern
const' variable. That variable might be defined as 'constexpr', so we cannot
prove that a use of it could never be a constant expression.
Hal Finkel [Wed, 25 May 2016 21:53:24 +0000 (21:53 +0000)]
Add a loop's debug location to its llvm.loop metadata
Getting accurate locations for loops is important, because those locations are
used by the frontend to generate optimization remarks. Currently, optimization
remarks for loops often appear on the wrong line, often the first line of the
loop body instead of the loop itself. This is confusing because that line might
itself be another loop, or might be somewhere else completely if the body was
an inlined function call. This happens because of the way we find the loop's
starting location. First, we look for a preheader, and if we find one, and its
terminator has a debug location, then we use that. Otherwise, we look for a
location on an instruction in the loop header.
The fallback heuristic is not bad, but will almost always find the beginning of
the body, and not the loop statement itself. The preheader location search
often fails because there's often not a preheader, and even when there is a
preheader, depending on how it was formed, it sometimes carries the location of
some preceeding code.
I don't see any good theoretical way to fix this problem. On the other hand,
this seems like a straightforward solution: Put the debug location in the
loop's llvm.loop metadata. When emitting debug information, this commit causes
us to add the debug location as an operand to each loop's llvm.loop metadata.
Thus, we now generate this metadata for all loops (not just loops with
optimization hints) when we're otherwise generating debug information.
The remark test case changes depend on the companion LLVM commit r270771.
Nico Weber [Wed, 25 May 2016 14:15:08 +0000 (14:15 +0000)]
Fix mangled name of method with ns_consumed parameters.
When a function/method use a parameter with "ns_consumed" attribute,
ensure that the mangled name is the same whether -fobjc-arc is used
or not.
Since "ns_consumed" attribute is generally used to inform ARC that
a function/method does sink the reference, it mean it is usually
implemented in a compilation unit compiled without -fobjc-arc but
used form a compilation unit compiled with it.
Originally found while trying to use "ns_consumed" attribute in an
Objective-C++ file in Chromium (http://crbug.com/599980) where it
caused a linker error.
Regression introduced by revision 262278 (previously the attribute
was incorrectly not part of the mangled name).
Patch from Sylvain Defresne <sdefresne@chromium.org>!
http://reviews.llvm.org/D20113
Renato Golin [Wed, 25 May 2016 12:36:31 +0000 (12:36 +0000)]
Revert "[AArch64] Using new TargetParser in Clang"
This reverts commit r270688 and r270689. The issue is not a random order, but a
different order for some targets and others (prob. Linux vs Darwin). Reverting until
we have a better fix.
Denis Zobnin [Wed, 25 May 2016 11:32:42 +0000 (11:32 +0000)]
[ms][dll] #26935 Defining a dllimport function should cause it to be exported
If we have some function with dllimport attribute and then we have the function
definition in the same module but without dllimport attribute we should add
dllexport attribute to this function definition.
The same should be done for variables.
Example:
struct __declspec(dllimport) C3 {
~C3();
};
C3::~C3() {;} // we should export this definition.
Bob Wilson [Wed, 25 May 2016 05:41:57 +0000 (05:41 +0000)]
arc-repeated-use-of-weak should not warn about IBOutlet properties
Revision r211132 was supposed to disable -Warc-repeated-use-of-weak for
Objective-C properties marked with the IBOutlet attribute. Those properties
are supposed to be weak but they are only accessed from the main thread
so there is no risk of asynchronous updates setting them to nil. That
combination makes -Warc-repeated-use-of-weak very noisy. The previous
change only handled one kind of access to weak IBOutlet properties.
Instead of trying to add checks for all the different kinds of property
accesses, this patch removes the previous special case check and adds a
check at the point where the diagnostic is reported. rdar://21366461
Craig Topper [Wed, 25 May 2016 05:26:23 +0000 (05:26 +0000)]
[X86] Update test cases to make sure storeu builtins use the storeu instrinsics. We were previously matching on other stores in the IR from this being an -O0 test.
We should probably look into making the storeu builtins just emit a normal store with an alignment of 1.
Hans Wennborg [Tue, 24 May 2016 20:40:51 +0000 (20:40 +0000)]
[Driver] Add support for -finline-functions and /Ob2 flags
-finline-functions and /Ob2 are currently ignored by Clang. The only way to
enable inlining is to use the global O flags, which also enable other options,
or to emit LLVM bitcode using Clang, then running opt by hand with the inline
pass.
This patch allows to simply use the -finline-functions flag (same as GCC) or
/Ob2 in clang-cl mode to enable inlining without other optimizations.
This is the first patch of a serie to improve support for the /Ob flags.
Summary:
Following patch D19265 which enable software floating point support in the Sparc backend, this patch enables the option to be enabled in the front-end using the -msoft-float option.
The user should ensure a library (such as the builtins from Compiler-RT) that includes the software floating point routines is provided.
Alexey Bataev [Tue, 24 May 2016 07:40:12 +0000 (07:40 +0000)]
[OPENMP] Fixed codegen for firstprivate vars in standalone worksharing
directives.
If firstprivate variable is is captured by value in outlined region and then used as firstprivate variable in inner worksharing directive, the copy for this firstprivate variable was not created. Fixed this bug.
Dmitry Polukhin [Tue, 24 May 2016 06:37:14 +0000 (06:37 +0000)]
[MSVC2015] dllexport for defaulted special class members
Clang doesn't dllexport defaulted special member function defaulted
inside class but does it if they defaulted outside class. MSVC doesn't
make any distinction where they were defaulted. Also MSVC 2013 and 2015
export different set of members. MSVC2015 doesn't emit trivial defaulted
x-tors but does emit copy assign operator.
The statement constructed an anonymous structure which was typedefed. The
anonymous structure has internal linkage, and that would cause an error when
building with modules. Give the type declaration a tag name to address the
error when building with modules.
Simon Pilgrim [Mon, 23 May 2016 22:13:02 +0000 (22:13 +0000)]
[X86][SSE] Replace lossless i32/f32 to f64 conversion intrinsics with generic IR
Both the (V)CVTDQ2PD(Y) (i32 to f64) and (V)CVTPS2PD(Y) (f32 to f64) conversion instructions are lossless and can be safely represented as generic __builtin_convertvector calls instead of x86 intrinsics without affecting final codegen.
This patch removes the clang builtins and their use in the sse2/avx headers - a future patch will deal with removing the llvm intrinsics, but that will require a bit more work.