platform/upstream/llvm.git
6 years ago[YAML] Add support for non-printable characters
Francis Visoiu Mistrih [Mon, 18 Dec 2017 17:38:03 +0000 (17:38 +0000)]
[YAML] Add support for non-printable characters

LLVM IR function names which disable mangling start with '\01'
(https://www.llvm.org/docs/LangRef.html#identifiers).

When an identifier like "\01@abc@" gets dumped to MIR, it is quoted, but
only with single quotes.

http://www.yaml.org/spec/1.2/spec.html#id2770814:

"The allowed character range explicitly excludes the C0 control block
allowed), the surrogate block #xD800-#xDFFF, #xFFFE, and #xFFFF."

http://www.yaml.org/spec/1.2/spec.html#id2776092:

"All non-printable characters must be escaped.
[...]
Note that escape sequences are only interpreted in double-quoted scalars."

This patch adds support for printing escaped non-printable characters
between double quotes if needed.

Should also fix PR31743.

Differential Revision: https://reviews.llvm.org/D41290

llvm-svn: 320996

6 years agoAdd a test.
Rafael Espindola [Mon, 18 Dec 2017 17:36:28 +0000 (17:36 +0000)]
Add a test.

This changed in r315658, but it was missing a test.

llvm-svn: 320995

6 years agoFix the reference to the now renamed member of TBAAStructField
Ivan A. Kosarev [Mon, 18 Dec 2017 16:50:11 +0000 (16:50 +0000)]
Fix the reference to the now renamed member of TBAAStructField

See https://reviews.llvm.org/D39956 for details.

llvm-svn: 320994

6 years ago[IR] Add MDBuilder helpers for the new TBAA metadata format
Ivan A. Kosarev [Mon, 18 Dec 2017 16:49:39 +0000 (16:49 +0000)]
[IR] Add MDBuilder helpers for the new TBAA metadata format

The new helpers are supposed to be used in clang to generate TBAA
information in the new format proposed in this thread:

http://lists.llvm.org/pipermail/llvm-dev/2017-November/118748.html

Differential Revision: https://reviews.llvm.org/D39956

llvm-svn: 320993

6 years ago[AArch64][SVE] Asm: Improve diagnostics further when +sve is not specified
Sander de Smalen [Mon, 18 Dec 2017 16:48:53 +0000 (16:48 +0000)]
[AArch64][SVE] Asm: Improve diagnostics further when +sve is not specified

Summary: Patch [4/4] in a series to add parsing of predicates and properly parse SVE ZIP1/ZIP2 instructions. This patch further improves diagnostic messages for when the SVE feature is not specified.

Reviewers: rengolin, fhahn, olista01, echristo, efriedma

Reviewed By: fhahn

Subscribers: sdardis, aemerson, javed.absar, tschuett, llvm-commits, kristof.beyls

Differential Revision: https://reviews.llvm.org/D40363

llvm-svn: 320992

6 years agoReland "[mips] Fix the target specific instruction verifier"
Simon Dardis [Mon, 18 Dec 2017 15:56:40 +0000 (15:56 +0000)]
Reland "[mips] Fix the target specific instruction verifier"

Fix an off by one error in the bounds checking for 'dinsu' and update
the ranges in the test comments so that they are accurate.

This version has the correct commit message.

Reviewers: atanasyan

Differential Revision: https://reviews.llvm.org/D41183

llvm-svn: 320991

6 years ago[asan] Add interceptor for printf_chk
Maxim Ostapenko [Mon, 18 Dec 2017 15:31:26 +0000 (15:31 +0000)]
[asan] Add interceptor for printf_chk

There could be a situation when a specific DSO was built with FORTIFY_SOURCE option. In case asan-ed binary link against that DSO,
libasan can't handle the possible memory error because it does not have interceptors for spinrtf_chk, snprintf_chk, vprintf_chk,
vsnprintf_chk, __fprintf_chk functions. Let's interceptors for them.

Patch by Denis Khalikov.

Differential Revision: https://reviews.llvm.org/D40951

llvm-svn: 320990

6 years ago[Memcpy Loop Lowering] Remove the fixed int8 lowering.
Sean Fertile [Mon, 18 Dec 2017 15:31:14 +0000 (15:31 +0000)]
[Memcpy Loop Lowering] Remove the fixed int8 lowering.

Switch over to the lowering that uses target supplied operand types.

Differential Revision: https://reviews.llvm.org/D41201

llvm-svn: 320989

6 years ago[clangd] Update documentation page with new features, instructions
Marc-Andre Laperle [Mon, 18 Dec 2017 14:59:01 +0000 (14:59 +0000)]
[clangd] Update documentation page with new features, instructions

Summary:
- Some features were implemented so mark them as such.
- Add installation instructions (LLVM debian packages)

Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewers: jkorous-apple

Reviewed By: jkorous-apple

Subscribers: jkorous-apple, klimek, ilya-biryukov, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D41306

llvm-svn: 320988

6 years ago[ELF] Optimize Arm PLT sequences
Peter Smith [Mon, 18 Dec 2017 14:46:27 +0000 (14:46 +0000)]
[ELF] Optimize Arm PLT sequences

A more efficient PLT sequence can be used when the distance between the
.plt and the end of the .plt.got is less than 128 Megabytes, which is
frequently true. We fall back to the old sequence when the offset is larger
than 128 Megabytes. This gives us an alternative to forcing the longer
entries with --long-plt as we gracefully fall back to it as needed.

See ELF for the ARM Architecture Appendix A for details of the PLT sequence.

Differential Revision: https://reviews.llvm.org/D41246

llvm-svn: 320987

6 years ago[TableGen][AsmMatcherEmitter] Only choose specific diagnostic for enabled instruction
Sander de Smalen [Mon, 18 Dec 2017 14:34:24 +0000 (14:34 +0000)]
[TableGen][AsmMatcherEmitter] Only choose specific diagnostic for enabled instruction

Summary:
When emitting a diagnostic for an invalid operand, a specific diagnostic
should only be reported when the instruction being matched is actually
enabled by the feature flags.

Patch [3/4] in a series to add parsing of predicates and properly parse SVE
ZIP1/ZIP2 instructions. This patch fixes bogus diagnostic messages for when
the SVE feature is not specified.

Reviewers: rengolin, craig.topper, olista01, sdardis, stoklund

Reviewed By: olista01, sdardis

Subscribers: fhahn, javed.absar, llvm-commits

Differential Revision: https://reviews.llvm.org/D40362

llvm-svn: 320986

6 years agoFix regression in jModulesInfo packet handling
Pavel Labath [Mon, 18 Dec 2017 14:31:44 +0000 (14:31 +0000)]
Fix regression in jModulesInfo packet handling

The recent UUID cleanups exposed a bug in the parsing code for the
jModulesInfo response, which was passing wrong value for the second
argument to UUID::SetFromStringRef (it passed the length of the string,
whereas the correct value should be the number of decoded bytes we
expect to receive).

This was not picked up by tests, because they test with 16-byte uuids,
for which the function happens to do the right thing even if the length
does not match (if the length does not match, the function does not
update m_num_uuid_bytes member, but that member is already 16 to begin
with).

I fix that and add a test with 20-byte uuid to catch if this regresses.
I have also added more safeguards into the parsing code to fail if we
cannot parse the entire uuid field we recieve. While testing the latter
part, I noticed that the "negative" jModulesInfo tests were succeeding
because we were sending malformed json (and not because the json
contents was invalid), so I make those tests a bit more robuts as well.

llvm-svn: 320985

6 years agollgs: Propagate the environment when launching the inferior from command line
Pavel Labath [Mon, 18 Dec 2017 14:31:39 +0000 (14:31 +0000)]
llgs: Propagate the environment when launching the inferior from command line

Summary:
We were failing to propagate the environment when lldb-server was
started with a pre-loaded process
(e.g.: lldb-server gdbserver -- inferior --inferior_args)

This patch makes sure the environment is propagated. Instead of adding a
new GDBRemoteCommunicationServerLLGS::SetLaunchEnvironment function to
complement SetLaunchArgs and SetLaunchFlags, I replace these with a
more generic SetLaunchInfo, which can be used to set any launch-related
property.

The accompanying test also verifies that the server correctly terminates
the connection after sending the exit packet (specifically, that it does
not send the exit packet twice).

Reviewers: clayborg, eugene

Subscribers: lldb-commits, mgorny

Differential Revision: https://reviews.llvm.org/D41070

llvm-svn: 320984

6 years ago[LVI] Support for ashr in LVI
Max Kazantsev [Mon, 18 Dec 2017 14:23:30 +0000 (14:23 +0000)]
[LVI] Support for ashr in LVI

Enhance LVI to analyze the ‘ashr’ binary operation. This leverages the infrastructure in ConstantRange for the ashr operation.

Patch by Surya Kumari Jangala!

Differential Revision: https://reviews.llvm.org/D40886

llvm-svn: 320983

6 years agoRevert r320978 "No -fsanitize=function warning when calling noexcept function through...
Stephan Bergmann [Mon, 18 Dec 2017 13:51:48 +0000 (13:51 +0000)]
Revert r320978 "No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17"

At least <http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/
builds/6013/steps/annotate/logs/stdio> complains about
__ubsan::__ubsan_handle_function_type_mismatch_abort (compiler-rt
lib/ubsan/ubsan_handlers.cc) returning now despite being declared 'noreturn', so
looks like a different approach is needed for the function_type_mismatch check
to be called also in cases that may ultimately succeed.

llvm-svn: 320982

6 years agoRevert r320977 "No -fsanitize=function warning when calling noexcept function through...
Stephan Bergmann [Mon, 18 Dec 2017 13:51:46 +0000 (13:51 +0000)]
Revert r320977 "No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17"

At least <http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/
builds/6013/steps/annotate/logs/stdio> complains about
__ubsan::__ubsan_handle_function_type_mismatch_abort (compiler-rt
lib/ubsan/ubsan_handlers.cc) returning now despite being declared 'noreturn', so
looks like a different approach is needed for the function_type_mismatch check
to be called also in cases that may ultimately succeed.

llvm-svn: 320981

6 years ago[ARM GlobalISel] Fix G_(UN)MERGE_VALUES handling after r319524
Diana Picus [Mon, 18 Dec 2017 13:22:28 +0000 (13:22 +0000)]
[ARM GlobalISel] Fix G_(UN)MERGE_VALUES handling after r319524

r319524 has made more G_MERGE_VALUES/G_UNMERGE_VALUES pairs legal than
are supported by the rest of the pipeline. Restrict that to only the
cases that we can currently handle: packing 32-bit values into 64-bit
ones, when we have hardware FP.

llvm-svn: 320980

6 years agoConstexprify LaneBitmask factory methods.
Benjamin Kramer [Mon, 18 Dec 2017 13:20:26 +0000 (13:20 +0000)]
Constexprify LaneBitmask factory methods.

This avoids global constructors when they're used in a global constant.

llvm-svn: 320979

6 years agoNo -fsanitize=function warning when calling noexcept function through non-noexcept...
Stephan Bergmann [Mon, 18 Dec 2017 13:05:42 +0000 (13:05 +0000)]
No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17

As discussed in the mail thread <https://groups.google.com/a/isocpp.org/forum/
#!topic/std-discussion/T64_dW3WKUk> "Calling noexcept function throug non-
noexcept pointer is undefined behavior?", such a call should not be UB.
However, Clang currently warns about it.

There is no cheap check whether two function type_infos only differ in noexcept,
so pass those two type_infos as additional data to the function_type_mismatch
handler (with the optimization of passing a null "static callee type" info when
that is already noexcept, so the additional check can be avoided anyway).  For
the Itanium ABI (which appears to be the only one that happens to be used on
platforms that support -fsanitize=function, and which appears to only record
noexcept information for pointer-to-function type_infos, not for function
type_infos themselves), we then need to check the mangled names for occurrence
of "Do" representing "noexcept".

This is the cfe part of a patch covering both cfe and compiler-rt.

Differential Revision: https://reviews.llvm.org/D40720

llvm-svn: 320978

6 years agoNo -fsanitize=function warning when calling noexcept function through non-noexcept...
Stephan Bergmann [Mon, 18 Dec 2017 13:05:41 +0000 (13:05 +0000)]
No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17

As discussed in the mail thread <https://groups.google.com/a/isocpp.org/forum/
#!topic/std-discussion/T64_dW3WKUk> "Calling noexcept function throug non-
noexcept pointer is undefined behavior?", such a call should not be UB.
However, Clang currently warns about it.

There is no cheap check whether two function type_infos only differ in noexcept,so pass those two type_infos as additional data to the function_type_mismatch
handler (with the optimization of passing a null "static callee type" info when that is already noexcept, so the additional check can be avoided anyway).  For
the Itanium ABI (which appears to be the only one that happens to be used on
platforms that support -fsanitize=function, and which appears to only record
noexcept information for pointer-to-function type_infos, not for function
type_infos themselves), we then need to check the mangled names for occurrence
of "Do" representing "noexcept".

This is the compiler-rt part of a patch covering both cfe and compiler-rt.

Differential Revision: https://reviews.llvm.org/D40720

llvm-svn: 320977

6 years ago[ConstantRange] Support for ashr in ConstantRange computation
Max Kazantsev [Mon, 18 Dec 2017 13:01:32 +0000 (13:01 +0000)]
[ConstantRange] Support for ashr in ConstantRange computation

Extend the ConstantRange implementation to compute the range of possible values resulting from an arithmetic right shift operation.
There will be a follow up patch to leverage this constant range infrastructure in LazyValueInfo.

Patch by Surya Kumari Jangala!

Differential Revision: https://reviews.llvm.org/D40881

llvm-svn: 320976

6 years agoRevert "[mips] Fix the target specific instruction verifier"
Simon Dardis [Mon, 18 Dec 2017 12:30:34 +0000 (12:30 +0000)]
Revert "[mips] Fix the target specific instruction verifier"

This reverts commit r320974. The commit message lacked the Differential Revison: line.

llvm-svn: 320975

6 years ago[mips] Fix the target specific instruction verifier
Simon Dardis [Mon, 18 Dec 2017 12:24:17 +0000 (12:24 +0000)]
[mips] Fix the target specific instruction verifier

Fix an off by one error in the bounds checking for 'dinsu' and update
the ranges in the test comments so that they are accurate.

Reviewers: atanasyan

https://reviews.llvm.org/D41183

llvm-svn: 320974

6 years ago[AArch64][SVE] Asm: Add ZIP1/ZIP2 instructions (predicate/data vectors)
Sander de Smalen [Mon, 18 Dec 2017 11:29:59 +0000 (11:29 +0000)]
[AArch64][SVE] Asm: Add ZIP1/ZIP2 instructions (predicate/data vectors)

Summary: Patch [2/4] in a series to add parsing of predicates and properly parse SVE ZIP1/ZIP2 instructions.

Reviewers: rengolin, kristof.beyls, fhahn, mcrosier, evandro

Reviewed By: fhahn

Subscribers: aemerson, javed.absar, llvm-commits, tschuett

Differential Revision: https://reviews.llvm.org/D40361

llvm-svn: 320973

6 years ago[clangd] in VSCode client, filter extensions properly and only accept file: URIs
Sam McCall [Mon, 18 Dec 2017 11:29:45 +0000 (11:29 +0000)]
[clangd] in VSCode client, filter extensions properly and only accept file: URIs

Summary:
The filtering wasn't previously working as intended - the string list is
interpreted as a list of editor modes, not file extensions.
(It happens to mostly work as "c" and "cpp" are the names of modes, but we're
missing objective-c)

The file: restriction is new - clangd needs to be able to convert URI<->path
in order to determine how to build.

Reviewers: hokein

Subscribers: klimek, ilya-biryukov, cfe-commits

Differential Revision: https://reviews.llvm.org/D41343

llvm-svn: 320972

6 years ago[X86] Use {{.*}} instead of hardcoded %1 in knot test.
Martin Bohme [Mon, 18 Dec 2017 11:29:21 +0000 (11:29 +0000)]
[X86] Use {{.*}} instead of hardcoded %1 in knot test.

This makes the test more resilient and consistent with the other tests
introduced in r320919.

llvm-svn: 320971

6 years ago[AArch64][SVE] Asm: Add SVE predicate register definitions and parsing support
Sander de Smalen [Mon, 18 Dec 2017 11:26:34 +0000 (11:26 +0000)]
[AArch64][SVE] Asm: Add SVE predicate register definitions and parsing support

Summary: Patch [1/4] in a series to add parsing of predicates and properly parse SVE ZIP1/ZIP2 instructions.

Reviewers: rengolin, kristof.beyls, fhahn, mcrosier, evandro, echristo, efriedma

Reviewed By: fhahn

Subscribers: aemerson, javed.absar, llvm-commits, tschuett

Differential Revision: https://reviews.llvm.org/D40360

llvm-svn: 320970

6 years agoFix FreeBSD build broken by r320966
Pavel Labath [Mon, 18 Dec 2017 11:05:28 +0000 (11:05 +0000)]
Fix FreeBSD build broken by r320966

llvm-svn: 320969

6 years ago[ThinLTO] Remove unused code
Eugene Leviant [Mon, 18 Dec 2017 10:53:45 +0000 (10:53 +0000)]
[ThinLTO] Remove unused code

This is a re-commit of r320464, after patch for gold plugin
was landed.

llvm-svn: 320968

6 years agoAdd LLVMObject dependency to our ObjectFileELF plugin
Pavel Labath [Mon, 18 Dec 2017 10:51:03 +0000 (10:51 +0000)]
Add LLVMObject dependency to our ObjectFileELF plugin

llvm-svn: 320967

6 years agoReduce x86 register context boilerplate.
Pavel Labath [Mon, 18 Dec 2017 10:50:59 +0000 (10:50 +0000)]
Reduce x86 register context boilerplate.

Summary:
The x86 FPR struct was defined as a struct containing a union between
two members: XSAVE and FXSAVE. This patch makes FPR a union directly to
remove one layer of indirection when trying to access the members.

The initial layout of these two structs is identical, which is
recognised by the fact that XSAVE has FXSAVE as its first member, so we
also considered removing one more layer and leave FPR identical to XSAVE
struct, but stopped short of doing that, as the FPR may be used to store
different layouts in the future (e.g., ones generated by the FSAVE
instruction).

Reviewers: clayborg, krytarowski

Subscribers: emaste, lldb-commits

Differential Revision: https://reviews.llvm.org/D41245

llvm-svn: 320966

6 years agoAArch64: work around how Cyclone handles "movi.2d vD, #0".
Tim Northover [Mon, 18 Dec 2017 10:36:00 +0000 (10:36 +0000)]
AArch64: work around how Cyclone handles "movi.2d vD, #0".

For Cylone, the instruction "movi.2d vD, #0" is executed incorrectly in some rare
circumstances. Work around the issue conservatively by avoiding the instruction entirely.

This patch changes CodeGen so that problematic instructions are never
generated, and the AsmParser so that an equivalent instruction is used (with a
warning).

llvm-svn: 320965

6 years ago[TargetLibraryInfo] Discard library functions with incorrectly sized integers
Igor Laevsky [Mon, 18 Dec 2017 10:31:58 +0000 (10:31 +0000)]
[TargetLibraryInfo] Discard library functions with incorrectly sized integers

Differential Revision: https://reviews.llvm.org/D41184

llvm-svn: 320964

6 years ago[ARM] Adjust test checks
Sam Parker [Mon, 18 Dec 2017 10:08:03 +0000 (10:08 +0000)]
[ARM] Adjust test checks

Correct the CHECK-LABELS of a couple of dag combine tests.

llvm-svn: 320963

6 years ago[DAGCombine] Move AND nodes to multiple load leaves
Sam Parker [Mon, 18 Dec 2017 10:04:27 +0000 (10:04 +0000)]
[DAGCombine] Move AND nodes to multiple load leaves

Search from AND nodes to find whether they can be propagated back to
loads, so that the AND and load can be combined into a narrow load.
We search through OR, XOR and other AND nodes and all bar one of the
leaves are required to be loads or constants. The exception node then
needs to be masked off meaning that the 'and' isn't removed, but the
loads(s) are narrowed still.

Differential Revision: https://reviews.llvm.org/D41177

llvm-svn: 320962

6 years agoNPL: Clean up handling of inferior exit
Pavel Labath [Mon, 18 Dec 2017 09:44:29 +0000 (09:44 +0000)]
NPL: Clean up handling of inferior exit

Summary:
lldb-server was sending the "exit" packet (W??) twice. This happened
because it was handling both the pre-exit (PTRACE_EVENT_EXIT) and
post-exit (WIFEXITED) as exit events. We had some code which was trying
to detect when we've already sent the exit packet, but this stopped
working quite a while ago.

This never really caused any problems in practice because the client
automatically closes the connection after receiving the first packet, so
the only effect of this was some warning messages about extra packets
from the lldb-server test suite, which were ignored because they didn't
fail the test.

The new test suite will be stricter about this, so I fix this issue
ignoring the first event. I think this is the correct behavior, as the
inferior is not really dead at that point, so it's premature to send the
exit packet.

There isn't an actual test yet which would verify the exit behavior, but
in my next patch I will add a test which will also test this
functionality.

Reviewers: eugene

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D41069

llvm-svn: 320961

6 years ago[NFC][CodeGen][ExpandMemCmp] Fix documentation.
Clement Courbet [Mon, 18 Dec 2017 07:32:48 +0000 (07:32 +0000)]
[NFC][CodeGen][ExpandMemCmp] Fix documentation.

llvm-svn: 320960

6 years ago[X86] Use mattr instead of mcpu in some of the cost model tests.
Craig Topper [Mon, 18 Dec 2017 07:21:58 +0000 (07:21 +0000)]
[X86] Use mattr instead of mcpu in some of the cost model tests.

Based on the names of the check lines, features seems more appropriate that cpu.

Spotted while prototyping my patch to make 512-bit vectors illegal on SKX sometimes.

llvm-svn: 320959

6 years ago[SROA] Disable non-whole-alloca splits by default
Hiroshi Inoue [Mon, 18 Dec 2017 06:47:37 +0000 (06:47 +0000)]
[SROA] Disable non-whole-alloca splits by default

This patch introduce a switch to control splitting of non-whole-alloca slices with default off.
The switch will be default on again after fixing an issue reported in PR35657.

llvm-svn: 320958

6 years ago[X86] Fix mistake that I made when splitting up the setOperationAction calls recently.
Craig Topper [Mon, 18 Dec 2017 04:50:05 +0000 (04:50 +0000)]
[X86] Fix mistake that I made when splitting up the setOperationAction calls recently.

The block I moved things that need BWI and 512-bit or VLX is incorrectly qualified with just hasBWI || hasVLX. Here I've qualified it with hasBWI && (hasAVX512 || hasVLX) where the hasAVX512 will be replaced with allowing 512-bit vectors in an upcoming patch.

llvm-svn: 320957

6 years ago[CGP] Fix the handling select inst in complex addressing mode
Serguei Katkov [Mon, 18 Dec 2017 04:25:07 +0000 (04:25 +0000)]
[CGP] Fix the handling select inst in complex addressing mode

When we put the value in select placeholder we must pass
the value through simplification tracker due to the value might
be already simplified and erased.

This is a fix for PR35658.

Reviewers: john.brawn, uabelho
Reviewed By: john.brawn
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D41251

llvm-svn: 320956

6 years ago[x86] add tests for finite libcall lowering (PR35672); NFC
Sanjay Patel [Mon, 18 Dec 2017 00:38:45 +0000 (00:38 +0000)]
[x86] add tests for finite libcall lowering (PR35672); NFC

llvm-svn: 320955

6 years agoRefactor overridden methods iteration to avoid double lookups.
Benjamin Kramer [Sun, 17 Dec 2017 23:52:45 +0000 (23:52 +0000)]
Refactor overridden methods iteration to avoid double lookups.

Convert most uses to range-for loops. No functionality change intended.

llvm-svn: 320954

6 years agoRe-commit "Properly handle multi-element and dynamically sized allocas in getPointerD...
Bjorn Steinbrink [Sun, 17 Dec 2017 21:20:16 +0000 (21:20 +0000)]
Re-commit "Properly handle multi-element and dynamically sized allocas in getPointerDereferenceableBytes()""

llvm-clang-x86_64-expensive-checks-win is still broken, so the failure
seems unrelated.

llvm-svn: 320953

6 years ago[testsuite] Un-XFAIL the global variables tests.
Davide Italiano [Sun, 17 Dec 2017 18:58:27 +0000 (18:58 +0000)]
[testsuite] Un-XFAIL the global variables tests.

<rdar://problem/28725399>

Differential Revision: https://reviews.llvm.org/D41312

llvm-svn: 320952

6 years ago[X86] Add test cases that show cases where buildvector of extract and inserts should...
Craig Topper [Sun, 17 Dec 2017 18:31:36 +0000 (18:31 +0000)]
[X86] Add test cases that show cases where buildvector of extract and inserts should be turned into fmsubadd.

This is a follow up to the fmaddsub support added in r320950. Hopefully in the future we can fix lowering to handle this fmsubadd too.

llvm-svn: 320951

6 years ago[X86] Make the code that creates fmaddsub from build_vector of extracts and inserts...
Craig Topper [Sun, 17 Dec 2017 18:23:45 +0000 (18:23 +0000)]
[X86] Make the code that creates fmaddsub from build_vector of extracts and inserts functional and add tests.

Summary:
We had no tests for this and we couldn't do the optimization because of a bad use count check. We need to know how many non-undef pieces of the build vector were filled in and ensure our use count is equal to that. But on the shuffle combine version we need the use count to be 2.

The missing coverage was noticed during the review of D40335.

Reviewers: RKSimon, zvi, spatel

Reviewed By: RKSimon

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D41133

llvm-svn: 320950

6 years ago[X86] Regenerate truncated rotation tests + add missing 32-bit checks
Simon Pilgrim [Sun, 17 Dec 2017 18:20:42 +0000 (18:20 +0000)]
[X86] Regenerate truncated rotation tests + add missing 32-bit checks

llvm-svn: 320949

6 years ago[WebAssembly] Move code for copying of data segment relocation. NFC.
Sam Clegg [Sun, 17 Dec 2017 17:52:01 +0000 (17:52 +0000)]
[WebAssembly] Move code for copying of data segment relocation. NFC.

This is a preparetory change for function gc which also
requires relocations to be copied in ranges like this.

Differential Revision: https://reviews.llvm.org/D41313

llvm-svn: 320948

6 years agouse uint32_t
Sam Clegg [Sun, 17 Dec 2017 17:50:07 +0000 (17:50 +0000)]
use uint32_t

llvm-svn: 320947

6 years ago[WebAssembly] Export some more info on wasm funtions
Sam Clegg [Sun, 17 Dec 2017 17:50:07 +0000 (17:50 +0000)]
[WebAssembly] Export some more info on wasm funtions

Summary:
These fields are useful for lld's gc-sections support

Also remove an unused field.

Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish

Differential Revision: https://reviews.llvm.org/D41320

llvm-svn: 320946

6 years agoRevert "Properly handle multi-element and dynamically sized allocas in getPointerDere...
Bjorn Steinbrink [Sun, 17 Dec 2017 15:16:58 +0000 (15:16 +0000)]
Revert "Properly handle multi-element and dynamically sized allocas in getPointerDereferenceableBytes()"

This reverts commit 217067d5179882de9deb60d2e866befea4c126e7.

Fails on llvm-clang-x86_64-expensive-checks-win

llvm-svn: 320945

6 years agoRevert "Treat sret arguments as being dereferenceable in getPointerDereferenceableByt...
Bjorn Steinbrink [Sun, 17 Dec 2017 15:16:51 +0000 (15:16 +0000)]
Revert "Treat sret arguments as being dereferenceable in getPointerDereferenceableBytes()"

This reverts commit 8b7a7660a3904b2088bc594311bcea2c651def08.

I didn't mean to commit this.

llvm-svn: 320944

6 years agoTreat sret arguments as being dereferenceable in getPointerDereferenceableBytes()
Bjorn Steinbrink [Sun, 17 Dec 2017 15:11:52 +0000 (15:11 +0000)]
Treat sret arguments as being dereferenceable in getPointerDereferenceableBytes()

llvm-svn: 320943

6 years ago[ASTImporter] Support importing FunctionTemplateDecl and CXXDependentScopeMemberExpr
Aleksei Sidorin [Sun, 17 Dec 2017 14:16:17 +0000 (14:16 +0000)]
[ASTImporter] Support importing FunctionTemplateDecl and CXXDependentScopeMemberExpr

* Also introduces ImportTemplateArgumentListInfo facility (A. Sidorin)

Patch by Peter Szecsi!

Differential Revision: https://reviews.llvm.org/D38692

llvm-svn: 320942

6 years agoRemove superfluous break after a return. NFCI.
Simon Pilgrim [Sun, 17 Dec 2017 11:01:33 +0000 (11:01 +0000)]
Remove superfluous break after a return. NFCI.

llvm-svn: 320941

6 years ago[X86DomainReassignment] Store legal domains in a std::bitset instead of using a Small...
Craig Topper [Sun, 17 Dec 2017 03:16:23 +0000 (03:16 +0000)]
[X86DomainReassignment] Store legal domains in a std::bitset instead of using a SmallVector that really only ever has one element as a set.

llvm-svn: 320940

6 years agoProperly handle byval arguments in getPointerDereferenceableBytes()
Bjorn Steinbrink [Sun, 17 Dec 2017 02:37:42 +0000 (02:37 +0000)]
Properly handle byval arguments in getPointerDereferenceableBytes()

Summary:
For byval arguments, the number of dereferenceable bytes is equal to
the size of the pointee, not the pointer.

Reviewers: hfinkel, rnk

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D41305

llvm-svn: 320939

6 years agoProperly handle multi-element and dynamically sized allocas in getPointerDereferencea...
Bjorn Steinbrink [Sun, 17 Dec 2017 01:54:25 +0000 (01:54 +0000)]
Properly handle multi-element and dynamically sized allocas in getPointerDereferenceableBytes()

Reviewers: hfinkel, rnk

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D41288

llvm-svn: 320938

6 years ago[X86] Use extract_vector_elt instead of X86ISD::VEXTRACT for isel of vXi1 extractions.
Craig Topper [Sun, 17 Dec 2017 01:35:48 +0000 (01:35 +0000)]
[X86] Use extract_vector_elt instead of X86ISD::VEXTRACT for isel of vXi1 extractions.

llvm-svn: 320937

6 years ago[X86] Canonicalize extract_vector_elt from vXi1 to always return MVT::i32.
Craig Topper [Sun, 17 Dec 2017 01:35:47 +0000 (01:35 +0000)]
[X86] Canonicalize extract_vector_elt from vXi1 to always return MVT::i32.

This allows us to remove some isel patterns that allowed MVT::i8 result type.

llvm-svn: 320936

6 years ago[X86] Don't create X86ISD::VEXTRACT nodes directly. Use EXTRACT_VECTOR_ELT and allow...
Craig Topper [Sun, 17 Dec 2017 01:35:44 +0000 (01:35 +0000)]
[X86] Don't create X86ISD::VEXTRACT nodes directly. Use EXTRACT_VECTOR_ELT and allow that to be legaized to VEXTRACT.

I think we can remove the VEXTRACT node completely and use a canonicalized EXTRACT_VECTOR_ELT instead. This is a first step.

llvm-svn: 320935

6 years agoFix unused variable warning.
Simon Pilgrim [Sat, 16 Dec 2017 23:37:51 +0000 (23:37 +0000)]
Fix unused variable warning.

llvm-svn: 320934

6 years ago[X86][AVX] lowerVectorShuffleAsBroadcast - aggressively peek through BITCASTs
Simon Pilgrim [Sat, 16 Dec 2017 23:32:18 +0000 (23:32 +0000)]
[X86][AVX] lowerVectorShuffleAsBroadcast - aggressively peek through BITCASTs

Assuming we can safely adjust the broadcast index for the new type to keep it suitably aligned, then peek through BITCASTs when looking for the broadcast source.

Fixes PR32007

llvm-svn: 320933

6 years ago[X86][AVX] Use extract128BitVector helper. NFCI.
Simon Pilgrim [Sat, 16 Dec 2017 23:09:57 +0000 (23:09 +0000)]
[X86][AVX] Use extract128BitVector helper. NFCI.

llvm-svn: 320932

6 years ago[sanitizer] Define __sanitizer_clockid_t on FreeBSD
Kostya Kortchinsky [Sat, 16 Dec 2017 23:01:14 +0000 (23:01 +0000)]
[sanitizer] Define __sanitizer_clockid_t on FreeBSD

Summary:
https://reviews.llvm.org/D41121 broke the FreeBSD build due to that type not
being defined on FreeBSD. As far as I can tell, it is an int, but I do not have
a way to test the change.

Reviewers: alekseyshl, kparzysz

Reviewed By: kparzysz

Subscribers: kparzysz, emaste, kubamracek, krytarowski, #sanitizers, llvm-commits

Differential Revision: https://reviews.llvm.org/D41325

llvm-svn: 320931

6 years ago[X86][AVX] Fix failed broadcast fold
Simon Pilgrim [Sat, 16 Dec 2017 22:57:17 +0000 (22:57 +0000)]
[X86][AVX] Fix failed broadcast fold

Strip excess BITCASTs from EXTRACT_SUBVECTOR input

llvm-svn: 320930

6 years ago[Memcpy Loop Lowering] Only calculate residual size/bytes copied when needed.
Sean Fertile [Sat, 16 Dec 2017 22:41:39 +0000 (22:41 +0000)]
[Memcpy Loop Lowering] Only calculate residual size/bytes copied when needed.

If the loop operand type is int8 then there will be no residual loop for the
unknown size expansion. Dont create the residual-size and bytes-copied values
when they are not needed.

llvm-svn: 320929

6 years ago[X86] Don't pass a zero input to the passthru operand of getVectorMaskingNode/getScal...
Craig Topper [Sat, 16 Dec 2017 21:12:24 +0000 (21:12 +0000)]
[X86] Don't pass a zero input to the passthru operand of getVectorMaskingNode/getScalarMaskingNode when its going to emit an ISD::OR/ISD::AND. NFCI

In those cases, the pass thru operand of the methods isn't used. The calls to the scalar version were passing a MVT::i1 zero, which is an illegal type at the stage this code runs.

llvm-svn: 320928

6 years ago[X86] Have getVectorMaskingNode return an ISD::AND for X86ISD::VPSHUFBITQMB instead...
Craig Topper [Sat, 16 Dec 2017 21:12:23 +0000 (21:12 +0000)]
[X86] Have getVectorMaskingNode return an ISD::AND for X86ISD::VPSHUFBITQMB instead of creating a select with one input being 0.

llvm-svn: 320927

6 years ago[X86] When using vpopcntdq for ctpop of v8i16 vectors, only promote to v8i32.
Craig Topper [Sat, 16 Dec 2017 19:31:36 +0000 (19:31 +0000)]
[X86] When using vpopcntdq for ctpop of v8i16 vectors, only promote to v8i32.

Previously we promoted to v8i64, but we don't need to go all the way to 512-bits. If we have VLX we can use the 256-bit instruction. And even if we don't have VLX we can widen v8i32 to v16i32 and drop the upper half.

llvm-svn: 320926

6 years ago[libcxx] Add WebAssembly support
Sam Clegg [Sat, 16 Dec 2017 18:59:50 +0000 (18:59 +0000)]
[libcxx] Add WebAssembly support

It turns out that this is the only change required in libcxx
for it to compile with the new `wasm32-unknown-unknown-wasm`
target recently added to Clang.

Patch by Nicholas Wilson!

Differential Revision: https://reviews.llvm.org/D41073

llvm-svn: 320925

6 years ago[X86] Combine some more scheduler model entries using regular expressions.
Craig Topper [Sat, 16 Dec 2017 18:35:31 +0000 (18:35 +0000)]
[X86] Combine some more scheduler model entries using regular expressions.

We had a lot of separate 32 and 64 instructions that had the same scheduling data. This merges them into the same regular expression. This is pretty consistent with a lot of other instructions.

llvm-svn: 320924

6 years ago[X86] Use instrs instead of instregex for gather/scatter instructions in the schedule...
Craig Topper [Sat, 16 Dec 2017 18:35:29 +0000 (18:35 +0000)]
[X86] Use instrs instead of instregex for gather/scatter instructions in the scheduler models. Combine into single InstrRW entries.

The reduces the number of scheduler groups in subtarget info.

llvm-svn: 320923

6 years ago[InstCombine] Regenerate FMUL/FMA combine tests with update_test_checks.py
Simon Pilgrim [Sat, 16 Dec 2017 17:18:15 +0000 (17:18 +0000)]
[InstCombine] Regenerate FMUL/FMA combine tests with update_test_checks.py

llvm-svn: 320922

6 years ago[InstCombine] canonicalize shifty abs(): ashr+add+xor --> cmp+neg+sel
Sanjay Patel [Sat, 16 Dec 2017 16:41:17 +0000 (16:41 +0000)]
[InstCombine] canonicalize shifty abs(): ashr+add+xor --> cmp+neg+sel

We want to do this for 2 reasons:
1. Value tracking does not recognize the ashr variant, so it would fail to match for cases like D39766.
2. DAGCombiner does better at producing optimal codegen when we have the cmp+sel pattern.

More detail about what happens in the backend:
1. DAGCombiner has a generic transform for all targets to convert the scalar cmp+sel variant of abs
   into the shift variant. That is the opposite of this IR canonicalization.
2. DAGCombiner has a generic transform for all targets to convert the vector cmp+sel variant of abs
   into either an ABS node or the shift variant. That is again the opposite of this IR canonicalization.
3. DAGCombiner has a generic transform for all targets to convert the exact shift variants produced by #1 or #2
   into an ISD::ABS node. Note: It would be an efficiency improvement if we had #1 go directly to an ABS node
   when that's legal/custom.
4. The pattern matching above is incomplete, so it is possible to escape the intended/optimal codegen in a
   variety of ways.
   a. For #2, the vector path is missing the case for setlt with a '1' constant.
   b. For #3, we are missing a match for commuted versions of the shift variants.
5. Therefore, this IR canonicalization can only help get us to the optimal codegen. The version of cmp+sel
   produced by this patch will be recognized in the DAG and converted to an ABS node when possible or the
   shift sequence when not.
6. In the following examples with this patch applied, we may get conditional moves rather than the shift
   produced by the generic DAGCombiner transforms. The conditional move is created using a target-specific
   decision for any given target. Whether it is optimal or not for a particular subtarget may be up for debate.

define i32 @abs_shifty(i32 %x) {
  %signbit = ashr i32 %x, 31
  %add = add i32 %signbit, %x
  %abs = xor i32 %signbit, %add
  ret i32 %abs
}

define i32 @abs_cmpsubsel(i32 %x) {
  %cmp = icmp slt i32 %x, zeroinitializer
  %sub = sub i32 zeroinitializer, %x
  %abs = select i1 %cmp, i32 %sub, i32 %x
  ret i32 %abs
}

define <4 x i32> @abs_shifty_vec(<4 x i32> %x) {
  %signbit = ashr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
  %add = add <4 x i32> %signbit, %x
  %abs = xor <4 x i32> %signbit, %add
  ret <4 x i32> %abs
}

define <4 x i32> @abs_cmpsubsel_vec(<4 x i32> %x) {
  %cmp = icmp slt <4 x i32> %x, zeroinitializer
  %sub = sub <4 x i32> zeroinitializer, %x
  %abs = select <4 x i1> %cmp, <4 x i32> %sub, <4 x i32> %x
  ret <4 x i32> %abs
}

> $ ./opt -instcombine shiftyabs.ll -S | ./llc -o - -mtriple=x86_64 -mattr=avx
> abs_shifty:
>  movl %edi, %eax
>  negl %eax
>  cmovll %edi, %eax
>  retq
>
> abs_cmpsubsel:
>  movl %edi, %eax
>  negl %eax
>  cmovll %edi, %eax
>  retq
>
> abs_shifty_vec:
>  vpabsd %xmm0, %xmm0
>  retq
>
> abs_cmpsubsel_vec:
>  vpabsd %xmm0, %xmm0
>  retq
>
> $ ./opt -instcombine shiftyabs.ll -S | ./llc -o - -mtriple=aarch64
> abs_shifty:
>  cmp w0, #0                  // =0
>  cneg w0, w0, mi
>  ret
>
> abs_cmpsubsel:
>  cmp w0, #0                  // =0
>  cneg w0, w0, mi
>  ret
>
> abs_shifty_vec:
>  abs v0.4s, v0.4s
>  ret
>
> abs_cmpsubsel_vec:
>  abs v0.4s, v0.4s
>  ret
>
> $ ./opt -instcombine shiftyabs.ll -S | ./llc -o - -mtriple=powerpc64le
> abs_shifty:
>  srawi 4, 3, 31
>  add 3, 3, 4
>  xor 3, 3, 4
>  blr
>
> abs_cmpsubsel:
>  srawi 4, 3, 31
>  add 3, 3, 4
>  xor 3, 3, 4
>  blr
>
> abs_shifty_vec:
>  vspltisw 3, -16
>  vspltisw 4, 15
>  vsubuwm 3, 4, 3
>  vsraw 3, 2, 3
>  vadduwm 2, 2, 3
>  xxlxor 34, 34, 35
>  blr
>
> abs_cmpsubsel_vec:
>  vspltisw 3, -16
>  vspltisw 4, 15
>  vsubuwm 3, 4, 3
>  vsraw 3, 2, 3
>  vadduwm 2, 2, 3
>  xxlxor 34, 34, 35
>  blr
>

Differential Revision: https://reviews.llvm.org/D40984

llvm-svn: 320921

6 years ago[Driver, CodeGen] pass through and apply -fassociative-math
Sanjay Patel [Sat, 16 Dec 2017 16:11:17 +0000 (16:11 +0000)]
[Driver, CodeGen] pass through and apply -fassociative-math

There are 2 parts to getting the -fassociative-math command-line flag translated to LLVM FMF:

1. In the driver/frontend, we accept the flag and its 'no' inverse and deal with the
   interactions with other flags like -ffast-math -fno-signed-zeros -fno-trapping-math.
   This was mostly already done - we just need to translate the flag as a codegen option.
   The test file is complicated because there are many potential combinations of flags here.
   Note that we are matching gcc's behavior that requires 'nsz' and no-trapping-math.

2. In codegen, we map the codegen option to FMF in the IR builder. This is simple code and
   corresponding test.

For the motivating example from PR27372:

float foo(float a, float x) { return ((a + x) - x); }

$ ./clang -O2 27372.c -S -o - -ffast-math  -fno-associative-math -emit-llvm  | egrep 'fadd|fsub'
  %add = fadd nnan ninf nsz arcp contract float %0, %1
  %sub = fsub nnan ninf nsz arcp contract float %add, %2

So 'reassoc' is off as expected (and so is the new 'afn' but that's a different patch).
This case now works as expected end-to-end although the underlying logic is still wrong:

$ ./clang  -O2 27372.c -S -o - -ffast-math  -fno-associative-math | grep xmm
addss %xmm1, %xmm0
subss %xmm1, %xmm0

We're not done because the case where 'reassoc' is set is ignored by optimizer passes. Example:

$ ./clang  -O2 27372.c -S -o - -fassociative-math -fno-signed-zeros -fno-trapping-math -emit-llvm  | grep fadd
  %add = fadd reassoc float %0, %1

$ ./clang -O2  27372.c -S -o - -fassociative-math -fno-signed-zeros -fno-trapping-math | grep xmm
addss %xmm1, %xmm0
subss %xmm1, %xmm0

Differential Revision: https://reviews.llvm.org/D39812

llvm-svn: 320920

6 years ago[X86] Implement kand/kandn/kor/kxor/kxnor/knot intrinsics using native IR.
Craig Topper [Sat, 16 Dec 2017 08:26:22 +0000 (08:26 +0000)]
[X86] Implement kand/kandn/kor/kxor/kxnor/knot intrinsics using native IR.

llvm-svn: 320919

6 years ago[X86] Remove GCCBuiltin from kand/kandn/kor/kxor/kxnor/knot intrinsics so clang can...
Craig Topper [Sat, 16 Dec 2017 08:25:30 +0000 (08:25 +0000)]
[X86] Remove GCCBuiltin from kand/kandn/kor/kxor/kxnor/knot intrinsics so clang can implement with native IR.

llvm-svn: 320918

6 years ago[X86] Remove unneeded code for handling the old kunpck intrinsics.
Craig Topper [Sat, 16 Dec 2017 06:58:30 +0000 (06:58 +0000)]
[X86] Remove unneeded code for handling the old kunpck intrinsics.

llvm-svn: 320917

6 years ago[X86] Add the two files I forgot to commit in r320915.
Craig Topper [Sat, 16 Dec 2017 06:10:24 +0000 (06:10 +0000)]
[X86] Add the two files I forgot to commit in r320915.

llvm-svn: 320916

6 years ago[X86] Add builtins and tests for 128 and 256 bit vpopcntdq.
Craig Topper [Sat, 16 Dec 2017 06:02:31 +0000 (06:02 +0000)]
[X86] Add builtins and tests for 128 and 256 bit vpopcntdq.

llvm-svn: 320915

6 years agoMove Transforms/LoopVectorize/consecutive-ptr-cg-bug.ll into the X86 subdirectory
Hal Finkel [Sat, 16 Dec 2017 05:10:20 +0000 (05:10 +0000)]
Move Transforms/LoopVectorize/consecutive-ptr-cg-bug.ll into the X86 subdirectory

This test depends on X86's TTI; move into the X86 subdirectory.

llvm-svn: 320914

6 years ago[LV] Extend InstWidening with CM_Widen_Recursive
Hal Finkel [Sat, 16 Dec 2017 02:55:24 +0000 (02:55 +0000)]
[LV] Extend InstWidening with CM_Widen_Recursive

Changes to the original scalar loop during LV code gen cause the return value
of Legal->isConsecutivePtr() to be inconsistent with the return value during
legal/cost phases (further analysis and information of the bug is in D39346).
This patch is an alternative fix to PR34965 following the CM_Widen approach
proposed by Ayal and Gil in D39346. It extends InstWidening enum with
CM_Widen_Reverse to properly record the widening decision for consecutive
reverse memory accesses and, consequently, get rid of the
Legal->isConsetuviePtr() call in LV code gen. I think this is a simpler/cleaner
solution to PR34965 than the one in D39346.

Fixes PR34965.

Patch by Diego Caballero, thanks!

Differential Revision: https://reviews.llvm.org/D40742

llvm-svn: 320913

6 years agoFixed warning 'function declaration isn’t a prototype [-Werror=strict-prototypes]'
Galina Kistanova [Sat, 16 Dec 2017 02:54:17 +0000 (02:54 +0000)]
Fixed warning 'function declaration isn’t a prototype [-Werror=strict-prototypes]'

llvm-svn: 320912

6 years ago[PowerPC, AsmParser] Enable the mnemonic spell corrector
Hal Finkel [Sat, 16 Dec 2017 02:42:18 +0000 (02:42 +0000)]
[PowerPC, AsmParser] Enable the mnemonic spell corrector

r307148 added an assembly mnemonic spelling correction support and enabled it
on ARM. This enables that support on PowerPC as well.

Patch by Dmitry Venikov, thanks!

Differential Revision: https://reviews.llvm.org/D40552

llvm-svn: 320911

6 years ago[X86] Add 128 and 256-bit VPOPCNTDQ instructions. Adjust some tablegen classes LZCNT...
Craig Topper [Sat, 16 Dec 2017 02:40:28 +0000 (02:40 +0000)]
[X86] Add 128 and 256-bit VPOPCNTDQ instructions. Adjust some tablegen classes LZCNT/POPCNT.

I think when this instruction was first published it was only for a Knights CPU and thus VLX version was missing.

llvm-svn: 320910

6 years ago[LTO] Update tests for r320905
Vitaly Buka [Sat, 16 Dec 2017 02:40:20 +0000 (02:40 +0000)]
[LTO] Update tests for r320905

llvm-svn: 320909

6 years ago[VerifyDiagnosticConsumer] support -verify=<prefixes>
Hal Finkel [Sat, 16 Dec 2017 02:23:22 +0000 (02:23 +0000)]
[VerifyDiagnosticConsumer] support -verify=<prefixes>

This mimics FileCheck's --check-prefixes option.

The default prefix is "expected". That is, "-verify" is equivalent to
"-verify=expected".

The goal is to permit exercising a single test suite source file with different
compiler options producing different sets of diagnostics.  While cpp can be
combined with the existing -verify to accomplish the same goal, source is often
easier to maintain when it's not cluttered with preprocessor directives or
duplicate passages of code. For example, this patch also rewrites some existing
clang tests to demonstrate the benefit of this feature.

Patch by Joel E. Denny, thanks!

Differential Revision: https://reviews.llvm.org/D39694

llvm-svn: 320908

6 years agoRemove trailing whitespace
Vitaly Buka [Sat, 16 Dec 2017 02:12:35 +0000 (02:12 +0000)]
Remove trailing whitespace

llvm-svn: 320907

6 years ago[WebAssembly] Return ArrayRef's rather than const std::vector&
Sam Clegg [Sat, 16 Dec 2017 02:10:16 +0000 (02:10 +0000)]
[WebAssembly] Return ArrayRef's rather than const std::vector&

From working on lld I've learned this is generally the
preferred way for several reasons (e.g. more concise, improves
encapsulation).

Differential Revision: https://reviews.llvm.org/D41265

llvm-svn: 320906

6 years ago[LTO] Make processing of combined module more consistent
Vitaly Buka [Sat, 16 Dec 2017 02:10:00 +0000 (02:10 +0000)]
[LTO] Make processing of combined module more consistent

Summary:
1. Use stream 0 only for combined module. Previously if combined module was not
processes ThinLTO used the stream for own output. However small changes in input,
could trigger combined module  and shuffle outputs making life of llvm::LTO harder.

2. Always process combined module and write output to stream 0. Processing empty
combined module is cheap and allows llvm::LTO users to avoid implementing processing
which is already done in llvm::LTO.

Subscribers: mehdi_amini, inglorion, eraman, hiraditya

Differential Revision: https://reviews.llvm.org/D41267

llvm-svn: 320905

6 years ago[TextDiagnosticBuffer] Fix diagnostic note emission order
Hal Finkel [Sat, 16 Dec 2017 01:40:19 +0000 (01:40 +0000)]
[TextDiagnosticBuffer] Fix diagnostic note emission order

The frontend currently groups diagnostics from the command line according to
diagnostic level, but that places all notes last. Fix that by emitting such
diagnostics in the order they were generated.

Patch by Joel E. Denny, thanks!

Differential Revision: https://reviews.llvm.org/D40995

llvm-svn: 320904

6 years agoAdd another missing -enable-import-metadata to test
Teresa Johnson [Sat, 16 Dec 2017 01:35:36 +0000 (01:35 +0000)]
Add another missing -enable-import-metadata to test

r320895 modified a test so that it needs -enable-import-metadata which
is false by default for NDEBUG, found another place that needs this
added.

llvm-svn: 320903

6 years ago[CodeGen] Specialize mixed-sign mul-with-overflow (fix PR34920)
Vedant Kumar [Sat, 16 Dec 2017 01:28:25 +0000 (01:28 +0000)]
[CodeGen] Specialize mixed-sign mul-with-overflow (fix PR34920)

This patch introduces a specialized way to lower overflow-checked
multiplications with mixed-sign operands. This fixes link failures and
ICEs on code like this:

  void mul(int64_t a, uint64_t b) {
    int64_t res;
    __builtin_mul_overflow(a, b, &res);
  }

The generic checked-binop irgen would use a 65-bit multiplication
intrinsic here, which requires runtime support for _muloti4 (128-bit
multiplication), and therefore fails to link on i386. To get an ICE
on x86_64, change the example to use __int128_t / __uint128_t.

Adding runtime and backend support for 65-bit or 129-bit checked
multiplication on all of our supported targets is infeasible.

This patch solves the problem by using simpler, specialized irgen for
the mixed-sign case.

llvm.org/PR34920, rdar://34963321

Testing: Apart from check-clang, I compared the output from this fairly
comprehensive test driver using unpatched & patched clangs:
https://gist.github.com/vedantk/3eb9c88f82e5c32f2e590555b4af5081

Differential Revision: https://reviews.llvm.org/D41149

llvm-svn: 320902

6 years ago[SimplifyLibCalls] Inline calls to cabs when it's safe to do so
Hal Finkel [Sat, 16 Dec 2017 01:26:25 +0000 (01:26 +0000)]
[SimplifyLibCalls] Inline calls to cabs when it's safe to do so

When unsafe algerbra is allowed calls to cabs(r) can be replaced by:

  sqrt(creal(r)*creal(r) + cimag(r)*cimag(r))

Patch by Paul Walker, thanks!

Differential Revision: https://reviews.llvm.org/D40069

llvm-svn: 320901

6 years ago[LV] NFC patch for moving VP*Recipe class definitions from LoopVectorize.cpp to VPlan.h
Hal Finkel [Sat, 16 Dec 2017 01:12:50 +0000 (01:12 +0000)]
[LV] NFC patch for moving VP*Recipe class definitions from LoopVectorize.cpp to VPlan.h

This is a small step forward to move VPlan stuff to where it should belong (i.e., VPlan.*):

  1. VP*Recipe classes in LoopVectorize.cpp are moved to VPlan.h.
  2. Many of VP*Recipe::print() and execute() definitions are still left in
     LoopVectorize.cpp since they refer to things declared in LoopVectorize.cpp. To
     be moved to VPlan.cpp at a later time.
  3. InterleaveGroup class is moved from anonymous namespace to llvm namespace.
     Referencing it in anonymous namespace from VPlan.h ended up in warning.

Patch by Hideki Saito, thanks!

Differential Revision: https://reviews.llvm.org/D41045

llvm-svn: 320900

6 years agoAdd -enable-import-metadata to test
Teresa Johnson [Sat, 16 Dec 2017 01:00:48 +0000 (01:00 +0000)]
Add -enable-import-metadata to test

r320895 modified a test so that it needs -enable-import-metadata which
is false by default for NDEBUG.

llvm-svn: 320899

6 years ago[X86] Add back the assert from r320830 that was reverted in r320850
Craig Topper [Sat, 16 Dec 2017 00:33:16 +0000 (00:33 +0000)]
[X86] Add back the assert from r320830 that was reverted in r320850

Hopefully r320864 has fixed the offending case that failed the assert.

llvm-svn: 320898

6 years agoFix NDEBUG build problem in r320895
Teresa Johnson [Sat, 16 Dec 2017 00:29:31 +0000 (00:29 +0000)]
Fix NDEBUG build problem in r320895

Fix incorrect placement of #endif causing NDEBUG build failures.

llvm-svn: 320897