platform/upstream/llvm.git
6 years ago[llvm-mca] Pass the InstrBuilder to the constructor of Backend.
Andrea Di Biagio [Fri, 23 Mar 2018 11:50:43 +0000 (11:50 +0000)]
[llvm-mca] Pass the InstrBuilder to the constructor of Backend.

This is done in preparation for the fix for PR36784.
No functional change.

llvm-svn: 328306

6 years ago[llvm-mca] Add flag -resource-pressure to enable/disable printing of the resource...
Andrea Di Biagio [Fri, 23 Mar 2018 11:33:09 +0000 (11:33 +0000)]
[llvm-mca] Add flag -resource-pressure to enable/disable printing of the resource pressure view.

By default, the tool always enables the resource pressure view.
This flag lets user specify whether they want to add that view or not.

llvm-svn: 328305

6 years ago[X86][Btver2] Vector move/load/store instructions use a JFPU01 scheduler pipe and...
Simon Pilgrim [Fri, 23 Mar 2018 11:27:31 +0000 (11:27 +0000)]
[X86][Btver2] Vector move/load/store instructions use a JFPU01 scheduler pipe and JFPX/JVALU function unit as well as the AGUs

llvm-svn: 328304

6 years ago[AArch64] Clean-up a few over-eager regexps in models.
Florian Hahn [Fri, 23 Mar 2018 11:00:42 +0000 (11:00 +0000)]
[AArch64] Clean-up a few over-eager regexps in models.

Patch by Simon Pilgrim <llvm-dev@redking.me.uk>

That is a slightly modified version of the AArch64 changes from
Simon's D44687 .

llvm-svn: 328303

6 years ago[clangd] Remove 'static' from a function inside anonymous ns. NFC
Ilya Biryukov [Fri, 23 Mar 2018 10:39:15 +0000 (10:39 +0000)]
[clangd] Remove 'static' from a function inside anonymous ns. NFC

llvm-svn: 328302

6 years ago[LoopUnroll] Simplify induction variables after peeling too.
Florian Hahn [Fri, 23 Mar 2018 10:38:12 +0000 (10:38 +0000)]
[LoopUnroll] Simplify induction variables after peeling too.

Loop peeling also has an impact on the induction variables, so we should
benefit from induction variable simplification after peeling too.

Reviewers: sanjoy, bogner, mzolotukhin, efriedma

Reviewed By: efriedma

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

llvm-svn: 328301

6 years ago[ORC] Join materialization thread in unit test
Benjamin Kramer [Fri, 23 Mar 2018 10:14:19 +0000 (10:14 +0000)]
[ORC] Join materialization thread in unit test

There's are race between this thread and the destructor of the test ORC
components on the main threads. I saw flaky failures there in about 4%
of the runs of this unit test.

llvm-svn: 328300

6 years ago[ELF] - Another fix for "LLD crashes with --emit-relocs when trying to proccess ...
George Rimar [Fri, 23 Mar 2018 09:18:31 +0000 (09:18 +0000)]
[ELF] - Another fix for "LLD crashes with --emit-relocs when trying to proccess .eh_frame"

This fixes PR36367 which is about segfault when --emit-relocs is
used together with .eh_frame sections which happens because
of reordering of regular and .rel[a] sections.

Path changes loop that iterates over input sections to create
relocation target sections first.

Differential revision: https://reviews.llvm.org/D44679

llvm-svn: 328299

6 years ago[ARM] Error out on .arm assembler directives on windows
Martin Storsjo [Fri, 23 Mar 2018 09:10:03 +0000 (09:10 +0000)]
[ARM] Error out on .arm assembler directives on windows

Windows on arm is thumb only.

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

llvm-svn: 328298

6 years agoRevert "[DAGCombiner] Fold (zext (and/or/xor (shl/shr (load x), cst), cst))"
Martin Storsjo [Fri, 23 Mar 2018 08:36:47 +0000 (08:36 +0000)]
Revert "[DAGCombiner] Fold (zext (and/or/xor (shl/shr (load x), cst), cst))"

This reverts commit r328252. This change broke building a number
of projects when targeting ARM and AArch64, see PR36873.

llvm-svn: 328297

6 years ago[X86] Give VPCMPEQQ the same itinerary as its SSE counterpart.
Craig Topper [Fri, 23 Mar 2018 06:58:55 +0000 (06:58 +0000)]
[X86] Give VPCMPEQQ the same itinerary as its SSE counterpart.

llvm-svn: 328296

6 years ago[X86] Correct the latencies of SNB integer vector multiplies based on Agner's data...
Craig Topper [Fri, 23 Mar 2018 06:41:43 +0000 (06:41 +0000)]
[X86] Correct the latencies of SNB integer vector multiplies based on Agner's data. Add missing MMX multiplies.

llvm-svn: 328295

6 years ago[X86] Match vpblendvb/vblendvps/vblendvpd itineraries to the SSE equivalent. Change...
Craig Topper [Fri, 23 Mar 2018 06:41:41 +0000 (06:41 +0000)]
[X86] Match vpblendvb/vblendvps/vblendvpd itineraries to the SSE equivalent. Change pblendvb/blendvps/blendvpd to use WriteFVarBlend

llvm-svn: 328294

6 years ago[X86] Change VPSADBW itinerary to SSE_INTALU_ITINS_P to match the SSE version.
Craig Topper [Fri, 23 Mar 2018 06:41:40 +0000 (06:41 +0000)]
[X86] Change VPSADBW itinerary to SSE_INTALU_ITINS_P to match the SSE version.

llvm-svn: 328293

6 years ago[X86] Give VLDDQUrm and LDDQUrm the same itinerary.
Craig Topper [Fri, 23 Mar 2018 06:41:39 +0000 (06:41 +0000)]
[X86] Give VLDDQUrm and LDDQUrm the same itinerary.

llvm-svn: 328292

6 years ago[X86] Merge VMOVMSKBrr and MOVMSKBrr in the SNB sheduler model.
Craig Topper [Fri, 23 Mar 2018 06:41:38 +0000 (06:41 +0000)]
[X86] Merge VMOVMSKBrr and MOVMSKBrr in the SNB sheduler model.

The VMOVMSKBrr was in a separate InstRW with a lower latency, but I assume they should be the same and the higher latency matches Agners table so I'm going with that.

llvm-svn: 328291

6 years ago[X86] Add VEXTRB/W/D/Q to Zen scheduler model.
Craig Topper [Fri, 23 Mar 2018 06:41:36 +0000 (06:41 +0000)]
[X86] Add VEXTRB/W/D/Q to Zen scheduler model.

The SSE versions were present, but not the VEX version.

llvm-svn: 328290

6 years ago[X86] Fix the itinerary for vextractps to match extractps.
Craig Topper [Fri, 23 Mar 2018 06:41:35 +0000 (06:41 +0000)]
[X86] Fix the itinerary for vextractps to match extractps.

llvm-svn: 328289

6 years agoBring r328238 back with a fix.
Rafael Espindola [Fri, 23 Mar 2018 01:36:23 +0000 (01:36 +0000)]
Bring r328238 back with a fix.

The issues was that we were setting hidden visibility if, when
processing a hidden class, we found out that we needed to emit a
reference to a vtable provided by the standard library.

Original message:

Set dso_local on vtables.

llvm-svn: 328288

6 years ago[DAG] Fix node id invalidation in Instruction Selection.
Nirav Dave [Fri, 23 Mar 2018 01:22:39 +0000 (01:22 +0000)]
[DAG] Fix node id invalidation in Instruction Selection.

Invalidation should be bit negation. Add missing negation.

llvm-svn: 328287

6 years agoRemove problematic PrettyStackTrace entry added in r328276
Jordan Rose [Fri, 23 Mar 2018 01:12:09 +0000 (01:12 +0000)]
Remove problematic PrettyStackTrace entry added in r328276

I'm not sure /why/ this is causing issues for libclang, but it is.
Unbreak the buildbots since it's already consumed an hour of my time.

llvm-svn: 328286

6 years agoFix the MSVC build.
Rafael Espindola [Fri, 23 Mar 2018 00:42:47 +0000 (00:42 +0000)]
Fix the MSVC build.

llvm-svn: 328285

6 years agoFix PR36793.
Rafael Espindola [Fri, 23 Mar 2018 00:35:27 +0000 (00:35 +0000)]
Fix PR36793.

With this patch lld will iterate over compile units to find the line
tables instead of assuming there is only one at offset 0.

llvm-svn: 328284

6 years ago[Modules] Update test to mention it requires C++14.
Volodymyr Sapsai [Fri, 23 Mar 2018 00:16:06 +0000 (00:16 +0000)]
[Modules] Update test to mention it requires C++14.

llvm-svn: 328283

6 years ago[analyzer] Trust _Nonnull annotations for system framework
George Karpenkov [Fri, 23 Mar 2018 00:16:03 +0000 (00:16 +0000)]
[analyzer] Trust _Nonnull annotations for system framework

Changes the analyzer to believe that methods annotated with _Nonnull
from system frameworks indeed return non null objects.
Local methods with such annotation are still distrusted.
rdar://24291919

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

llvm-svn: 328282

6 years ago[analyzer] Extend GCDAntipatternChecker to match group_enter/group_leave pattern
George Karpenkov [Fri, 23 Mar 2018 00:16:02 +0000 (00:16 +0000)]
[analyzer] Extend GCDAntipatternChecker to match group_enter/group_leave pattern

rdar://38480416

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

llvm-svn: 328281

6 years ago[analyzer] [NFC] Move worklist implementation to WorkList.cpp
George Karpenkov [Fri, 23 Mar 2018 00:16:01 +0000 (00:16 +0000)]
[analyzer] [NFC] Move worklist implementation to WorkList.cpp

Current location is very confusing, especially because there is already
WorkList.h, and other code in CoreEngine.cpp is not related to work list
implementation.

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

llvm-svn: 328280

6 years ago[sanitizer] Fix PPC bot
Vitaly Buka [Fri, 23 Mar 2018 00:15:10 +0000 (00:15 +0000)]
[sanitizer] Fix PPC bot

llvm-svn: 328279

6 years ago[CommandObjectFrame] Remove dead code.
Davide Italiano [Fri, 23 Mar 2018 00:14:41 +0000 (00:14 +0000)]
[CommandObjectFrame] Remove dead code.

llvm-svn: 328278

6 years ago[ARM] Add ARMv8.2-A FP16 vector intrinsic
Abderrazek Zaafrani [Fri, 23 Mar 2018 00:08:40 +0000 (00:08 +0000)]
[ARM] Add ARMv8.2-A FP16 vector intrinsic

Putting back the code in commit r327189 that was reverted in r322737. The code is being committed in three stages and this one is the last stage: 1) r327455 fp16 feature flags, 2) r327836 pass half type or i16 based on FullFP16, and 3) the code here which the front-end fp16 vector intrinsic for ARM.

Differential revision https://reviews.llvm.org/D43650

llvm-svn: 328277

6 years agoSink PrettyDeclStackTrace down to the AST library
Jordan Rose [Fri, 23 Mar 2018 00:07:18 +0000 (00:07 +0000)]
Sink PrettyDeclStackTrace down to the AST library

...and add some very basic stack trace entries for module building.
This would have helped track down rdar://problem/38434694 sooner.

llvm-svn: 328276

6 years ago[TableGen] Don't capture returned std::vectors by const reference.
Craig Topper [Fri, 23 Mar 2018 00:02:45 +0000 (00:02 +0000)]
[TableGen] Don't capture returned std::vectors by const reference.

The full vector is being returned not a reference. So the reference was just a to a temporary.

llvm-svn: 328275

6 years agoFor llvm-nm and Mach-O files also use function starts info in some
Kevin Enderby [Thu, 22 Mar 2018 23:59:35 +0000 (23:59 +0000)]
For llvm-nm and Mach-O files also use function starts info in some
cases when printing symbols.  As an improvement to:

r305733 - Change llvm-nm for Mach-O files to use dyld info in some cases when printing symbols

it could be made a bit better if it also read the function starts and faked
up nlist entries to those address not already faked up by the other
dyld info.  This would help with stripped static functions.

rdar://38761029

llvm-svn: 328274

6 years ago[sanitizer] zx_vmo_write on Fuchsia takes only 4 arguments now
Petr Hosek [Thu, 22 Mar 2018 23:58:37 +0000 (23:58 +0000)]
[sanitizer] zx_vmo_write on Fuchsia takes only 4 arguments now

The system call now fails when it cannot write the requested size.
Update the sanitizer runtime Fuchsia implementation accordingly.

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

llvm-svn: 328273

6 years agoState that CFG is preserved in 'Falkor HW Prefetch Fix Late Phase'.
Michael Zolotukhin [Thu, 22 Mar 2018 23:44:40 +0000 (23:44 +0000)]
State that CFG is preserved in 'Falkor HW Prefetch Fix Late Phase'.

That removes some redundant recomputations from the passes pipeline.

llvm-svn: 328272

6 years ago[Support/Parallel] Use lock_guard which has less overhead than unique_lock.
Fangrui Song [Thu, 22 Mar 2018 23:40:02 +0000 (23:40 +0000)]
[Support/Parallel] Use lock_guard which has less overhead than unique_lock.

Summary: unique_lock has the overhead of tracking ownership status and the owner.

Reviewers: grimar, zturner

Subscribers: llvm-commits

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

llvm-svn: 328271

6 years ago[clang-doc] Reland "[clang-doc] Setup clang-doc frontend framework"
Julie Hockett [Thu, 22 Mar 2018 23:34:46 +0000 (23:34 +0000)]
[clang-doc] Reland "[clang-doc] Setup clang-doc frontend framework"

Fixed windows release build tests.

llvm-svn: 328270

6 years agoAdd temporary printouts to test to help debug failures.
Eric Fiselier [Thu, 22 Mar 2018 23:14:20 +0000 (23:14 +0000)]
Add temporary printouts to test to help debug failures.

Some debian libc++ bots started having failures in the locale
tests due to what I assume is a change in the locale data for fr_FR
in glibc.

This change prints the actual value from the test to help debugging.
It should be reverted once the bots cycle.

llvm-svn: 328268

6 years agoReapply "[test] Add tests for llc passes pipelines." with a fix for bots with expensi...
Michael Zolotukhin [Thu, 22 Mar 2018 23:02:48 +0000 (23:02 +0000)]
Reapply "[test] Add tests for llc passes pipelines." with a fix for bots with expensive checks on.

llvm-svn: 328267

6 years agoSet dso_local on __ImageBase.
Rafael Espindola [Thu, 22 Mar 2018 23:02:19 +0000 (23:02 +0000)]
Set dso_local on __ImageBase.

llvm-svn: 328266

6 years agoAvoid Clang error about throwing _LIBCPP_ASSERT in noexcept function.
Eric Fiselier [Thu, 22 Mar 2018 23:01:08 +0000 (23:01 +0000)]
Avoid Clang error about throwing _LIBCPP_ASSERT in noexcept function.

This fixes a couple of tests which produced a warning that a 'throw'
occurred in a noexcept function (by way of _LIBCPP_ASSERT). It does
so by hiding the 'throw' across an opaque function boundary.

This fix isn't ideal, since we still have _LIBCPP_ASSERT's in functions
marked noexcept -- and this problem should be addressed in the future.
However, throwing _LIBCPP_ASSERT is really only meant to allow testing
of the assertions, and is not yet ready for general use.

llvm-svn: 328265

6 years ago[libcxx] [test] Strip trailing whitespace. NFC.
Stephan T. Lavavej [Thu, 22 Mar 2018 22:59:02 +0000 (22:59 +0000)]
[libcxx] [test] Strip trailing whitespace. NFC.

llvm-svn: 328264

6 years agoAdd a test.
Rafael Espindola [Thu, 22 Mar 2018 22:57:48 +0000 (22:57 +0000)]
Add a test.

This would have found the regression in r328238.

llvm-svn: 328263

6 years agoMove SampleProfile.h into IPO along with the rest of the IPO pass headers
David Blaikie [Thu, 22 Mar 2018 22:42:44 +0000 (22:42 +0000)]
Move SampleProfile.h into IPO along with the rest of the IPO pass headers

llvm-svn: 328262

6 years agoWorkaround GCC bug PR78489 - SFINAE order is not respected.
Eric Fiselier [Thu, 22 Mar 2018 22:32:55 +0000 (22:32 +0000)]
Workaround GCC bug PR78489 - SFINAE order is not respected.

This patch works around variant test failures which are new to
GCC 8. GCC 8 either doesn't perform SFINAE in lexical order, or
it doesn't halt after encountering the first failure. This
causes hard error to occur instead of substitution failure.

See gcc.gnu.org/PR78489

llvm-svn: 328261

6 years ago[X86] Correct the VROUND regular expressions in Znver1 scheduler model to account...
Craig Topper [Thu, 22 Mar 2018 22:17:11 +0000 (22:17 +0000)]
[X86] Correct the VROUND regular expressions in Znver1 scheduler model to account for r328254

llvm-svn: 328260

6 years agoFinish moving the IPSCCP pass from Scalar to IPO - moving the registration
David Blaikie [Thu, 22 Mar 2018 22:07:53 +0000 (22:07 +0000)]
Finish moving the IPSCCP pass from Scalar to IPO - moving the registration

llvm-svn: 328259

6 years ago[analyzer] Enable temporary object destructor inlining by default.
Artem Dergachev [Thu, 22 Mar 2018 22:05:53 +0000 (22:05 +0000)]
[analyzer] Enable temporary object destructor inlining by default.

When a temporary is constructed with a proper construction context, it should
be safe to inline the destructor. We have added suppressions for some of the
common false positives caused by such inlining, so there should be - and from my
observations there indeed is - more benefit than harm from enabling destructor
inlining.

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

llvm-svn: 328258

6 years agoRevert r325687 (workaround for PR36032).
Evgeny Stupachenko [Thu, 22 Mar 2018 22:04:39 +0000 (22:04 +0000)]
Revert r325687 (workaround for PR36032).

Summary:
Revert r325687 workaround for PR36032 since
 a fix was committed in r326154.

Reviewers: sbaranga

Differential Revision: http://reviews.llvm.org/D44768

From: Evgeny Stupachenko <evstupac@gmail.com>
                         <evgeny.v.stupachenko@intel.com>
llvm-svn: 328257

6 years agoAdd test for demangling GNU ABI tags.
Rafael Espindola [Thu, 22 Mar 2018 22:04:32 +0000 (22:04 +0000)]
Add test for demangling GNU ABI tags.

Patch by Christopher James Halse Rogers!

llvm-svn: 328256

6 years ago[CFG] [analyzer] Add C++17-specific ctor-initializer construction contexts.
Artem Dergachev [Thu, 22 Mar 2018 22:02:38 +0000 (22:02 +0000)]
[CFG] [analyzer] Add C++17-specific ctor-initializer construction contexts.

CXXCtorInitializer-based constructors are also affected by the C++17 mandatory
copy elision, like variable constructors and return value constructors.
Extend r328248 to support those.

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

llvm-svn: 328255

6 years ago[X86] Rename VROUNDYPS* and VROUNDYPD* instructions to VROUNDPSY* and VROUNDPDY*...
Craig Topper [Thu, 22 Mar 2018 21:55:20 +0000 (21:55 +0000)]
[X86] Rename VROUNDYPS* and VROUNDYPD* instructions to VROUNDPSY* and VROUNDPDY*. Fix itinerary mistake on all memory forms of VROUNDPD

This makes the Y position consistent with other instructions.

This should have been NFC, but while refactoring the multiclass I noticed that VROUNDPD memory forms were using the register itinerary.

llvm-svn: 328254

6 years ago[analyzer] Remove an assertion that doesn't hold in C++17.
Artem Dergachev [Thu, 22 Mar 2018 21:54:48 +0000 (21:54 +0000)]
[analyzer] Remove an assertion that doesn't hold in C++17.

Function return values can be constructed directly in variables or passed
directly into return statements, without even an elidable copy in between.
This is how the C++17 mandatory copy elision AST behaves. The behavior we'll
have in such cases is the "old" behavior that we've had before we've
implemented destructor inlining and proper lifetime extension support.

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

llvm-svn: 328253

6 years ago[DAGCombiner] Fold (zext (and/or/xor (shl/shr (load x), cst), cst))
Guozhi Wei [Thu, 22 Mar 2018 21:47:25 +0000 (21:47 +0000)]
[DAGCombiner] Fold (zext (and/or/xor (shl/shr (load x), cst), cst))

In our real world application, we found the following optimization is missed in DAGCombiner

(zext (and/or/xor (shl/shr (load x), cst), cst)) -> (and/or/xor (shl/shr (zextload x), (zext cst)), (zext cst))

If the user of original zext is an add, it may enable further lea optimization on x86.

This patch add a new function CombineZExtLogicopShiftLoad to do this optimization.

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

llvm-svn: 328252

6 years agoFix layering between SCCP and IPO SCCP
David Blaikie [Thu, 22 Mar 2018 21:41:29 +0000 (21:41 +0000)]
Fix layering between SCCP and IPO SCCP

Transforms/Scalar/SCCP.cpp implemented both the Scalar and IPO SCCP, but
this meant Transforms/Scalar including Transfroms/IPO headers, creating
a circular dependency. (IPO depends on Scalar already) - so move the IPO
SCCP shims out into IPO and the basic library implementation accessible
from Scalar/SCCP.h to be used from the IPO/SCCP.cpp implementation.

llvm-svn: 328250

6 years ago[CFG] [analyzer] NFC: Move construction context allocation into a helper method.
Artem Dergachev [Thu, 22 Mar 2018 21:40:24 +0000 (21:40 +0000)]
[CFG] [analyzer] NFC: Move construction context allocation into a helper method.

Improve readability of ConstructionContext::createFromLayers().

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

llvm-svn: 328249

6 years ago[CFG] [analyzer] Add C++17-specific variable and return construction contexts.
Artem Dergachev [Thu, 22 Mar 2018 21:37:39 +0000 (21:37 +0000)]
[CFG] [analyzer] Add C++17-specific variable and return construction contexts.

In C++17 copy elision is mandatory for variable and return value constructors
(as long as it doesn't involve type conversion) which results in AST that does
not contain elidable constructors in their usual places. In order to provide
construction contexts in this scenario we need to cover more AST patterns.

This patch makes the CFG prepared for these scenarios by:

- Fork VariableConstructionContext and ReturnedValueConstructionContext into
  two different sub-classes (each) one of which indicates the C++17 case and
  contains a reference to an extra CXXBindTemporaryExpr.
- Allow CFGCXXRecordTypedCall element to accept VariableConstructionContext and
  ReturnedValueConstructionContext as its context.

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

llvm-svn: 328248

6 years ago[analyzer] Make symbol_iterator iterate over SVal's symbolic base.
Artem Dergachev [Thu, 22 Mar 2018 21:30:58 +0000 (21:30 +0000)]
[analyzer] Make symbol_iterator iterate over SVal's symbolic base.

If a memory region (or an SVal that represents a pointer to that memory region)
is a (direct or indirect, not necessarily proper) sub-region of a SymbolicRegion
then it is said to have a symbolic base.

For now SVal::symbol_iterator explores the symbol within a symbolic region
only when the SVal represents a pointer to the symbolic region itself,
not to any of its sub-regions.

This behavior is not indended by any user of symbol_iterator; all users who
cared about such behavior were expecting the iterator to descend into the
symbolic base of an arbitrary region, find the parent symbol of the symbolic
base region, and iterate over that symbol. Lack of such behavior resulted in
bugs demonstarted by the test cases.

Hence the decision to change the API to behave more intuitively.

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

llvm-svn: 328247

6 years ago[MIR] Making MIR Printing, opt -dot-cfg, and -debug printing faster
Roman Tereshin [Thu, 22 Mar 2018 21:29:07 +0000 (21:29 +0000)]
[MIR] Making MIR Printing, opt -dot-cfg, and -debug printing faster

Value::printAsOperand has been scanning the entire module just to
print a single value as an operand, regardless being asked to print a
type or not at all, and regardless really needing to scan the module
to print a type.

It made some of the users of the method exceptionally slow on large
IR-modules (or large MIR-files with large IR-modules embedded).

This patch defers scanning a module looking for struct types, mostly
numbered struct types, as much as possible, speeding up those users
w/o changing any APIs at all.

See speedup examples below:

Release Build:

# 83 seconds -> 5.5 seconds
time ./bin/llc -start-before=irtranslator -stop-after=irtranslator \
  -global-isel -global-isel-abort=2 -simplify-mir sqlite3.O0.ll -o \
  sqlite3.O0.ll.regbankselected.mir

# 133 seconds -> 6.2 seconds
time ./bin/opt sqlite3.O0.ll -dot-cfg -disable-output

Release + Asserts Build:

# 95 seconds -> 5.5 seconds
time ./bin/llc -start-before=irtranslator -stop-after=irtranslator \
  -global-isel -global-isel-abort=2 -simplify-mir sqlite3.O0.ll -o \
  sqlite3.O0.ll.regbankselected.mir

# 146 seconds -> 6.2 seconds
time ./bin/opt sqlite3.O0.ll -dot-cfg -disable-output

# 1096 seconds -> 553 seconds
time ./bin/llc -debug-only=isel -fast-isel=false -stop-after=isel \
  sqlite3.O0.ll -o /dev/null 2> err

where sqlite3.O0.ll is non-optimized IR produced from
sqlite-amalgamation (http://sqlite.org/download.html), which is entire
SQLite3 implementation in a single C-file.

Benchmarked on 4-cores / 8 threads PCI-E SSD iMac running macOS

Reviewers: dexonsmith, bkramer, void, chandlerc, aditya_nandakumar, dsanders, qcolombet,

Reviewed By: bogner

Subscribers: thegameg, llvm-commits

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

llvm-svn: 328246

6 years agoUse DoNotOptimize to prevent new/delete elision.
Eric Fiselier [Thu, 22 Mar 2018 21:28:09 +0000 (21:28 +0000)]
Use DoNotOptimize to prevent new/delete elision.

The new/delete tests, in particular those which test replacement
functions, often fail when the optimizer is enabled because the
calls to new/delete may be optimized away, regardless of their side-effects.

This patch converts the tests to use DoNotOptimize in order to prevent
the elision.

llvm-svn: 328245

6 years agoRevert "Revert "[InstrProf] Support for external functions in text format.""
Mircea Trofin [Thu, 22 Mar 2018 21:26:52 +0000 (21:26 +0000)]
Revert "Revert "[InstrProf] Support for external functions in text format.""

Summary:
This reverts commit 364eb09576a7667bc6d3ff80c52a83014ccac976 and separates out
the portion that was fixing binary reader error propagation - turns out, there
are production cases where that causes a regression.

Will re-introduce the error propagation fix separately.

The fix to the text reader error propagation is still "in".

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: llvm-commits

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

llvm-svn: 328244

6 years agoFix test failure on Windows caused by different underlying enumeration type rules
Eric Fiselier [Thu, 22 Mar 2018 21:17:07 +0000 (21:17 +0000)]
Fix test failure on Windows caused by different underlying enumeration type rules

llvm-svn: 328243

6 years agoRevert "Set dso_local on vtables."
Rafael Espindola [Thu, 22 Mar 2018 21:14:16 +0000 (21:14 +0000)]
Revert "Set dso_local on vtables."

This reverts commit r328238.

Looks like it broke some buildbots.

llvm-svn: 328242

6 years ago[X86][SkylakeClient] Fix a bunch of instructions that were incorrectly assigned Port0...
Craig Topper [Thu, 22 Mar 2018 21:10:07 +0000 (21:10 +0000)]
[X86][SkylakeClient] Fix a bunch of instructions that were incorrectly assigned Port015 instead of Port01.

The VEC ADD and VEC MUL units aren't present on port 5 on SkylakeClient.

llvm-svn: 328241

6 years ago[MachineOutliner][NFC] Refactoring + comments in runOnModule
Jessica Paquette [Thu, 22 Mar 2018 21:07:09 +0000 (21:07 +0000)]
[MachineOutliner][NFC] Refactoring + comments in runOnModule

Split up some of the if/else branches in runOnModule. Elaborate on some
comments. Replace a call to getOrCreateMachineFunction with getMachineFunction.

This makes it clearer what's happening in runOnModule, and ensures that the
outliner doesn't create any MachineFunctions which will never be used by the
outliner (or anything else, really).

llvm-svn: 328240

6 years agoMore OpenBSD fixes
Vitaly Buka [Thu, 22 Mar 2018 20:42:28 +0000 (20:42 +0000)]
More OpenBSD fixes

Summary:
- Use internal_syscall_ptr in internal_readlink
- use sigcontext on OpenBSD

Patch by David CARLIER

Reviewers: krytarowski, vitalybuka

Reviewed By: vitalybuka

Subscribers: kubamracek, llvm-commits, #sanitizers

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

llvm-svn: 328239

6 years agoSet dso_local on vtables.
Rafael Espindola [Thu, 22 Mar 2018 20:33:01 +0000 (20:33 +0000)]
Set dso_local on vtables.

llvm-svn: 328238

6 years ago[CodeGen] Add a new pass for PostRA sink
Jun Bum Lim [Thu, 22 Mar 2018 20:06:47 +0000 (20:06 +0000)]
[CodeGen] Add a new pass for PostRA sink

Summary:
This pass sinks COPY instructions into a successor block, if the COPY is not
used in the current block and the COPY is live-in to a single successor
(i.e., doesn't require the COPY to be duplicated).  This avoids executing the
the copy on paths where their results aren't needed.  This also exposes
additional opportunites for dead copy elimination and shrink wrapping.

These copies were either not handled by or are inserted after the MachineSink
pass. As an example of the former case, the MachineSink pass cannot sink
COPY instructions with allocatable source registers; for AArch64 these type
of copy instructions are frequently used to move function parameters (PhyReg)
into virtual registers in the entry block..

For the machine IR below, this pass will sink %w19 in the entry into its
successor (%bb.1) because %w19 is only live-in in %bb.1.

```
   %bb.0:
      %wzr = SUBSWri %w1, 1
      %w19 = COPY %w0
      Bcc 11, %bb.2
    %bb.1:
      Live Ins: %w19
      BL @fun
      %w0 = ADDWrr %w0, %w19
      RET %w0
    %bb.2:
      %w0 = COPY %wzr
      RET %w0
```
As we sink %w19 (CSR in AArch64) into %bb.1, the shrink-wrapping pass will be
able to see %bb.0 as a candidate.

With this change I observed 12% more shrink-wrapping candidate and 13% more dead copies deleted  in spec2000/2006/2017 on AArch64.

Reviewers: qcolombet, MatzeB, thegameg, mcrosier, gberry, hfinkel, john.brawn, twoh, RKSimon, sebpop, kparzysz

Reviewed By: sebpop

Subscribers: evandro, sebpop, sfertile, aemerson, mgorny, javed.absar, kristof.beyls, llvm-commits

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

llvm-svn: 328237

6 years agoDocument optforfuzzing attribute created in r328214.
Matt Morehouse [Thu, 22 Mar 2018 19:50:10 +0000 (19:50 +0000)]
Document optforfuzzing attribute created in r328214.

llvm-svn: 328236

6 years ago[DWARF] Replace assert with diagnostic. PR36868.
Paul Robinson [Thu, 22 Mar 2018 19:37:56 +0000 (19:37 +0000)]
[DWARF] Replace assert with diagnostic. PR36868.

llvm-svn: 328235

6 years agoMove the initialization of the Meta Renamer pass over to IPO along with the rest...
David Blaikie [Thu, 22 Mar 2018 19:36:54 +0000 (19:36 +0000)]
Move the initialization of the Meta Renamer pass over to IPO along with the rest of it that was moved in r328209

llvm-svn: 328234

6 years ago[DAG, X86] Fix ISel-time node insertion ids
Nirav Dave [Thu, 22 Mar 2018 19:32:07 +0000 (19:32 +0000)]
[DAG, X86] Fix ISel-time node insertion ids

As in SystemZ backend, correctly propagate node ids when inserting new
unselected nodes into the DAG during instruction Seleciton for X86
target.

Fixes PR36865.

Reviewers: jyknight, craig.topper

Subscribers: hiraditya, llvm-commits

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

llvm-svn: 328233

6 years ago[SymbolFilePDB] Use section contributions as another way to determine the compiland
Aaron Smith [Thu, 22 Mar 2018 19:26:33 +0000 (19:26 +0000)]
[SymbolFilePDB] Use section contributions as another way to determine the compiland

Some PDB Symbols don't have line information. Use the section contributions to determine their compiland.
This is useful to determine the parent compiland for PDBSymbolTypeData, i.e. variables.

llvm-svn: 328232

6 years ago[X86] Correct the scheduling data for some of the 32 and 64 bit multiplies to as...
Craig Topper [Thu, 22 Mar 2018 19:22:51 +0000 (19:22 +0000)]
[X86] Correct the scheduling data for some of the 32 and 64 bit multiplies to as best as I understand how they are implemented.

llvm-svn: 328231

6 years ago[SymbolFilePDB] Ignore compiler generated functions when creating the LLDB type from...
Aaron Smith [Thu, 22 Mar 2018 19:21:34 +0000 (19:21 +0000)]
[SymbolFilePDB] Ignore compiler generated functions when creating the LLDB type from a PDB

llvm-svn: 328230

6 years agoUn-XFAIL a test under new GCC version; the GCC bug has been fixed
Eric Fiselier [Thu, 22 Mar 2018 19:18:08 +0000 (19:18 +0000)]
Un-XFAIL a test under new GCC version; the GCC bug has been fixed

llvm-svn: 328229

6 years agoFixed __kmpc_get_target_offload() to call library initialization.
Andrey Churbanov [Thu, 22 Mar 2018 18:51:51 +0000 (18:51 +0000)]
Fixed __kmpc_get_target_offload() to call library initialization.

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

llvm-svn: 328228

6 years ago[InstCombineCalls] Update deprecated API usage (NFC)
Daniel Neilson [Thu, 22 Mar 2018 18:36:15 +0000 (18:36 +0000)]
[InstCombineCalls] Update deprecated API usage (NFC)

Summary:
Just updating a call to MemSetInst::getAlignment() to MemSetInst::getDestAlignment(). The
former has been deprecated.

llvm-svn: 328227

6 years ago[X86][Btver2] Conversion, MaskedLoad/MaskedStore and NTStores all are scheduled throu...
Simon Pilgrim [Thu, 22 Mar 2018 18:29:16 +0000 (18:29 +0000)]
[X86][Btver2] Conversion, MaskedLoad/MaskedStore and NTStores all are scheduled through the JFPU1 pipe

llvm-svn: 328226

6 years agoFix improperly failing test - and the code it was testing. Thanks to Stephan Lavavej...
Marshall Clow [Thu, 22 Mar 2018 18:27:28 +0000 (18:27 +0000)]
Fix improperly failing test - and the code it was testing. Thanks to Stephan Lavavej for the catch.

llvm-svn: 328225

6 years agoSet dso_local on builtin functions.
Rafael Espindola [Thu, 22 Mar 2018 18:03:13 +0000 (18:03 +0000)]
Set dso_local on builtin functions.

The difference between CreateRuntimeFunction and CreateBuiltinFunction
is that CreateBuiltinFunction would not set dllimport or dso_local.

To keep the current semantics, just forward to CreateRuntimeFunction
with Local=true so it doesn't add dllimport.

llvm-svn: 328224

6 years agoFix Address Size in test.
Rafael Espindola [Thu, 22 Mar 2018 17:46:57 +0000 (17:46 +0000)]
Fix Address Size in test.

This is an i386 test, so it should be 4.

llvm-svn: 328223

6 years ago[X86][Btver2] FCMP (inc FMAX/FMIN) instructions use the JFPA functional pipe
Simon Pilgrim [Thu, 22 Mar 2018 17:43:12 +0000 (17:43 +0000)]
[X86][Btver2] FCMP (inc FMAX/FMIN) instructions use the JFPA functional pipe

The ymm instructions are double pumped as well.

llvm-svn: 328222

6 years ago[Codeview/PDB] Rename some methods for clarity.
Zachary Turner [Thu, 22 Mar 2018 17:37:28 +0000 (17:37 +0000)]
[Codeview/PDB] Rename some methods for clarity.

NFC, this just renames some methods to better express what they
do, and also adds a few helper methods to add some symmetry to the
API in a few places (for example there was a getStringFromId but not
a getIdFromString method in the string table).

llvm-svn: 328221

6 years ago[clang-format] Fix ObjC style guesser to also iterate over child lines
Ben Hamilton [Thu, 22 Mar 2018 17:37:19 +0000 (17:37 +0000)]
[clang-format] Fix ObjC style guesser to also iterate over child lines

Summary:
When I wrote `ObjCHeaderStyleGuesser`, I incorrectly assumed the
correct way to iterate over all tokens in `AnnotatedLine` was to
iterate over the linked list tokens starting with
`AnnotatedLine::First`.

However, `AnnotatedLine` also contains a vector
`AnnotedLine::Children` with child `AnnotedLine`s which have their own
tokens which we need to iterate over.

Because I didn't iterate over the tokens in the children lines, the
ObjC style guesser would fail on syntax like:

  #define FOO ({ NSString *s = ... })

as the statement(s) inside { ... } are child lines.

This fixes the bug and adds a test. I confirmed the test
failed before the fix, and passed after the fix.

Test Plan: New tests added. Ran tests with:
  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak, Wizard

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 328220

6 years ago[OpenMP][Clang] Add call to global data sharing stack initialization on the workers...
Gheorghe-Teodor Bercea [Thu, 22 Mar 2018 17:33:27 +0000 (17:33 +0000)]
[OpenMP][Clang] Add call to global data sharing stack initialization on the workers side

Summary: The workers also need to initialize the global stack. The call to the initialization function needs to happen after the kernel_init() function is called by the master. This ensures that the per-team data structures of the runtime have been initialized.

Reviewers: ABataev, grokos, carlo.bertolli, caomhin

Reviewed By: ABataev

Subscribers: jholewinski, guansong, cfe-commits

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

llvm-svn: 328219

6 years ago[GISel]: Fix incorrect IRTranslation while translating null pointer types
Aditya Nandakumar [Thu, 22 Mar 2018 17:31:38 +0000 (17:31 +0000)]
[GISel]: Fix incorrect IRTranslation while translating null pointer types

https://reviews.llvm.org/D44762

Currently IRTranslator produces
%vreg17<def>(p0) = G_CONSTANT 0;

instead we should build
%vreg16(s64) = G_CONSTANT 0
%vreg17(p0) = G_INTTOPTR %vreg16

reviewed by @aemerson.

llvm-svn: 328218

6 years ago[X86][Btver2] FMUL ymm instructions are double pumped on the JFPM functional pipe
Simon Pilgrim [Thu, 22 Mar 2018 17:25:38 +0000 (17:25 +0000)]
[X86][Btver2] FMUL ymm instructions are double pumped on the JFPM functional pipe

llvm-svn: 328217

6 years ago[ARM] Enable the full InstRW overlap check for ARMScheduleR52.td
Craig Topper [Thu, 22 Mar 2018 17:17:47 +0000 (17:17 +0000)]
[ARM] Enable the full InstRW overlap check for ARMScheduleR52.td

This fixes a few issues with the R52 instregexs to enable the full overlap checking

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

llvm-svn: 328216

6 years agoMake the debug info in some tests more realistic.
Rafael Espindola [Thu, 22 Mar 2018 17:14:41 +0000 (17:14 +0000)]
Make the debug info in some tests more realistic.

Currently lld just parses the .debug_line section assuming that there
is only one compile unit. That assumption is false (PR36793).

I have a patch that changes lld to iterate over the compile units and
parse the portions of the .debug_line they point to (which fixes
PR36793).

A problem is that we will then need a compiler unit pointing to
.debug_line for lld to see it.

It seems like bfd has the same restriction.

This patch updates existing tests to add a minimal compile unit so
that they still work with PR36793 fixed.

llvm-svn: 328215

6 years ago[SimplifyCFG] Create attribute for fuzzing-specific optimizations.
Matt Morehouse [Thu, 22 Mar 2018 17:07:51 +0000 (17:07 +0000)]
[SimplifyCFG] Create attribute for fuzzing-specific optimizations.

Summary:
When building with libFuzzer, converting control flow to selects or
obscuring the original operands of CMPs reduces the effectiveness of
libFuzzer's heuristics.

This patch provides an attribute to disable or modify certain optimizations
for optimal fuzzing signal.

Provides a less aggressive alternative to https://reviews.llvm.org/D44057.

Reviewers: vitalybuka, davide, arsenm, hfinkel

Reviewed By: vitalybuka

Subscribers: junbuml, mehdi_amini, wdng, javed.absar, hiraditya, llvm-commits, kcc

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

llvm-svn: 328214

6 years ago[CUDA] add REQUIRES fields for CUDA variants of LTO tests.
Artem Belevich [Thu, 22 Mar 2018 16:47:41 +0000 (16:47 +0000)]
[CUDA] add REQUIRES fields for CUDA variants of LTO tests.

Also relax checking for nvptx triple. This should avoid test failure if
the test is executed on 32-bit platform.

llvm-svn: 328213

6 years ago[DWARF] Add EmitDwarfOffset function, NFC.
Alexey Bataev [Thu, 22 Mar 2018 16:43:21 +0000 (16:43 +0000)]
[DWARF] Add EmitDwarfOffset function, NFC.

Added EmitDwarfOffset function after discussion with Eric Christofer.

llvm-svn: 328212

6 years agovim: rename `singlethread` to `syncscope`
Saleem Abdulrasool [Thu, 22 Mar 2018 16:39:54 +0000 (16:39 +0000)]
vim: rename `singlethread` to `syncscope`

SVN r307722 renamed the keyword from `singlethread` to `syncscope`.
Update the syntax file accordingly.

llvm-svn: 328211

6 years ago[LoopPredication] Add profitability check based on BPI
Anna Thomas [Thu, 22 Mar 2018 16:03:59 +0000 (16:03 +0000)]
[LoopPredication] Add profitability check based on BPI

Summary:
LoopPredication is not profitable when the loop is known to always exit
through some block other than the latch block.
A coarse grained latch check can cause loop predication to predicate the
loop, and unconditionally deoptimize.

However, without predicating the loop, the guard may never fail within the
loop during the dynamic execution because the non-latch loop termination
condition exits the loop before the latch condition causes the loop to
exit.
We teach LP about this using BranchProfileInfo pass.

Reviewers: apilipenko, skatkov, mkazantsev, reames

Reviewed by: skatkov

Subscribers: llvm-commits

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

llvm-svn: 328210

6 years agoMove MetaRenamer from Transforms/UTils to Transforms/IPO since it implements part...
David Blaikie [Thu, 22 Mar 2018 15:57:47 +0000 (15:57 +0000)]
Move MetaRenamer from Transforms/UTils to Transforms/IPO since it implements part of IPO.h

llvm-svn: 328209

6 years ago[DWARF] Fix mixing assembler -g with DWARF .file directives.
Paul Robinson [Thu, 22 Mar 2018 15:48:01 +0000 (15:48 +0000)]
[DWARF] Fix mixing assembler -g with DWARF .file directives.

We were effectively overriding an explicit '.file' directive with info
for the assembler source.  That shouldn't happen.

Fixes PR36636, really, even for .s files emitted by Clang.

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

llvm-svn: 328208

6 years agoRevert "[InstrProf] Support for external functions in text format."
Benjamin Kramer [Thu, 22 Mar 2018 15:29:55 +0000 (15:29 +0000)]
Revert "[InstrProf] Support for external functions in text format."

This reverts commit r328132. Breaks FDO selfhost. I'm seeing
error: /tmp/profraw: Invalid instrumentation profile data (bad magic)

llvm-svn: 328207

6 years ago[CallSiteSplitting] Preserve DominatorTreeAnalysis.
Florian Hahn [Thu, 22 Mar 2018 15:23:33 +0000 (15:23 +0000)]
[CallSiteSplitting] Preserve DominatorTreeAnalysis.

The dominator tree analysis can be preserved easily.
Some other kinds of analysis can probably be preserved
too.

Reviewers: junbuml, dberlin

Reviewed By: dberlin

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

llvm-svn: 328206

6 years ago[MC] fix documentation comments; NFC
Sanjay Patel [Thu, 22 Mar 2018 15:23:21 +0000 (15:23 +0000)]
[MC] fix documentation comments; NFC

llvm-svn: 328205