platform/upstream/llvm.git
7 years agoFixup whitespace.
Kuba Mracek [Mon, 10 Jul 2017 15:19:14 +0000 (15:19 +0000)]
Fixup whitespace.

llvm-svn: 307538

7 years ago[tsan] Add support for running TSan tests on iOS simulator and devices
Kuba Mracek [Mon, 10 Jul 2017 15:00:55 +0000 (15:00 +0000)]
[tsan] Add support for running TSan tests on iOS simulator and devices

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

llvm-svn: 307537

7 years ago[PM] Fix a warning.
Philip Pfaffe [Mon, 10 Jul 2017 13:54:23 +0000 (13:54 +0000)]
[PM] Fix a warning.

The DebugLogging argument was unused in the EP callbacks registration.

llvm-svn: 307536

7 years agoImprove error message when run from a buffer that doesn't visit a file
Philipp Stephani [Mon, 10 Jul 2017 13:49:18 +0000 (13:49 +0000)]
Improve error message when run from a buffer that doesn't visit a file

Summary: In this case, users currently get a confusing type error.  Make the error message more obvious.

Reviewers: klimek

Reviewed By: klimek

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

llvm-svn: 307535

7 years ago[PM] Fix r307532: Get rid of a dangling reference.
Philip Pfaffe [Mon, 10 Jul 2017 12:48:51 +0000 (12:48 +0000)]
[PM] Fix r307532: Get rid of a dangling reference.

Escaping lambda by-reference capture of local variable caused a dangling
reference.

llvm-svn: 307534

7 years agofix typos in comments and error messages; NFC
Hiroshi Inoue [Mon, 10 Jul 2017 12:44:25 +0000 (12:44 +0000)]
fix typos in comments and error messages; NFC

llvm-svn: 307533

7 years ago[PM] Enable registration of out-of-tree passes with PassBuilder
Philip Pfaffe [Mon, 10 Jul 2017 10:57:55 +0000 (10:57 +0000)]
[PM] Enable registration of out-of-tree passes with PassBuilder

Summary:
This patch adds a callback registration API to the PassBuilder,
enabling registering out-of-tree passes with it.

Through the Callback API, callers may register callbacks with the
various stages at which passes are added into pass managers, including
parsing of a pass pipeline as well as at extension points within the
default -O pipelines.

Registering utilities like `require<>` and `invalidate<>` needs to be
handled manually by the caller, but a helper is provided.

Additionally, adding passes at pipeline extension points is exposed
through the opt tool. This patch adds a `-passes-ep-X` commandline
option for every extension point X, which opt parses into pipelines
inserted into that extension point.

Reviewers: chandlerc

Reviewed By: chandlerc

Subscribers: lksbhm, grosser, davide, mehdi_amini, llvm-commits, mgorny

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

llvm-svn: 307532

7 years ago[ARM] Tidy up ARMBaseRegisterInfo implementation. NFC
Javed Absar [Mon, 10 Jul 2017 10:42:55 +0000 (10:42 +0000)]
[ARM] Tidy up ARMBaseRegisterInfo implementation. NFC

Clean up ARMBaseRegisterInfo implementation a bit.
Differential Revision: https://reviews.llvm.org/D35116

llvm-svn: 307531

7 years ago[DWARF] - Rename variable. NFC.
George Rimar [Mon, 10 Jul 2017 10:04:51 +0000 (10:04 +0000)]
[DWARF] - Rename variable. NFC.

Variable was called 'Name' and contained text
name of relocation type. Problem was that
outside of this error handling scope we already
have different 'Name' variable that contains
section name.

Change helps to avoid confusion.

llvm-svn: 307530

7 years agoThis patch completely replaces the scheduling information for the SandyBridge archite...
Gadi Haber [Mon, 10 Jul 2017 09:53:16 +0000 (09:53 +0000)]
This patch completely replaces the scheduling information for the SandyBridge architecture target by modifying the file X86SchedSandyBridge.td located under the X86 Target.
The SandyBridge architects have provided us with a more accurate information about each instruction latency, number of uOPs and used ports and I used it to replace the existing estimated SNB instructions scheduling and to add missing scheduling information.

Please note that the patch extensively affects the X86 MC instr scheduling for SNB.

Also note that this patch will be followed by additional patches for the remaining target architectures HSW, IVB, BDW, SKL and SKX.

The updated and extended information about each instruction includes the following details:
•static latency of the instruction
•number of uOps from which the instruction consists of
•all ports used by the instruction's' uOPs

For example, the following code dictates that instructions, ADC64mr, ADC8mr, SBB64mr, SBB8mr have a static latency of 9 cycles. Each of these instructions is decoded into 6 micro operations which use ports 4, ports 2 or 3 and port 0 and ports 0 or 1 or 5:

def SBWriteResGroup94 : SchedWriteRes<[SBPort4,SBPort23,SBPort0,SBPort015]> {
let Latency = 9;
let NumMicroOps = 6;
let ResourceCycles = [1,2,2,1];

}
def: InstRW<[SBWriteResGroup94], (instregex "ADC64mr")>;
def: InstRW<[SBWriteResGroup94], (instregex "ADC8mr")>;
def: InstRW<[SBWriteResGroup94], (instregex "SBB64mr")>;
def: InstRW<[SBWriteResGroup94], (instregex "SBB8mr")>;

Note that apart for the header, most of the X86SchedSandyBridge.td file was generated by a script.

Reviewers: zvi, chandlerc, RKSimon, m_zuckerman, craig.topper, igorb

Differential Revision:  https://reviews.llvm.org/D35019#inline-304691

llvm-svn: 307529

7 years ago[DWARF] - Remove unused variables. NFC.
George Rimar [Mon, 10 Jul 2017 09:36:44 +0000 (09:36 +0000)]
[DWARF] - Remove unused variables. NFC.

llvm-svn: 307528

7 years ago[GlobalISel][X86] Support G_LOAD/G_STORE i1.
Igor Breger [Mon, 10 Jul 2017 09:26:09 +0000 (09:26 +0000)]
[GlobalISel][X86] Support G_LOAD/G_STORE i1.

Summary: Support G_LOAD/G_STORE i1.

Reviewers: zvi, guyblank

Reviewed By: guyblank

Subscribers: rovka, kristof.beyls, llvm-commits

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

llvm-svn: 307527

7 years ago[GlobalISel][X86] extend G_ZEXT support.
Igor Breger [Mon, 10 Jul 2017 09:07:34 +0000 (09:07 +0000)]
[GlobalISel][X86] extend G_ZEXT support.

Summary:
Mark G_ZEXT/G_SEXT i1 to i8/i16,  i8 to i16 as legal.
Support G_ZEXT i1 to i8/i16 instruction selection ( C++ code).
This patch requred to support G_LOAD/G_STORE i1.

Reviewers: zvi, guyblank

Reviewed By: guyblank

Subscribers: rovka, llvm-commits, kristof.beyls

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

llvm-svn: 307526

7 years ago[docs] NFC: Fix links in the tutorial
Kirill Bobyrev [Mon, 10 Jul 2017 09:07:23 +0000 (09:07 +0000)]
[docs] NFC: Fix links in the tutorial

r274441 introduced Chapter 10 of "Implementing a Language with LLVM" tutorial,
which caused all files in the tutorial to start using two digit numbering. But
many links were not changed and therefore appear to be broken. This patch
addresses described issue.

As a result, following command does not produce any output anymore:

$ grep -nR '<LangImpl[0-9].html>' ./docs/tutorial/

llvm-svn: 307525

7 years agoX86 Intrinsics: _bit_scan_forward should not be under #ifdef __RDRND__
Zvi Rackover [Mon, 10 Jul 2017 07:13:56 +0000 (07:13 +0000)]
X86 Intrinsics: _bit_scan_forward should not be under #ifdef __RDRND__

Summary:
The _bit_scan_forward and _bit_scan_reverse intrinsics were accidentally
masked under the preprocessor checks that prune intrinsics definitions for the
benefit of faster compile-time on Windows. This patch moves the
definitons out of that region.

Fixes pr33722

Reviewers: craig.topper, aaboud, thakis

Reviewed By: craig.topper

Subscribers: cfe-commits

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

llvm-svn: 307524

7 years agofix formatting; NFC
Hiroshi Inoue [Mon, 10 Jul 2017 06:32:52 +0000 (06:32 +0000)]
fix formatting; NFC

llvm-svn: 307523

7 years ago[X86] Fix typo in comment. NFC
Craig Topper [Mon, 10 Jul 2017 06:09:22 +0000 (06:09 +0000)]
[X86] Fix typo in comment. NFC

llvm-svn: 307522

7 years ago[ArgumentPromotion] Change use of removed argument in llvm.dbg.value to undef
Mikael Holmen [Mon, 10 Jul 2017 06:07:24 +0000 (06:07 +0000)]
[ArgumentPromotion] Change use of removed argument in llvm.dbg.value to undef

Summary:
This solves PR33641.

When removing a dead argument we must also handle possibly existing calls
to llvm.dbg.value that use the removed argument. Now we change the use
of the otherwise dead argument to an undef for some other pass to cleanup
later.

If the calls are left untouched, they will later on cause errors:
 "function-local metadata used in wrong function"
since the ArgumentPromotion rewrites the code by creating a new function
with the wanted signature, but the metadata is not recreated so the new
function may then erroneously use metadata from the old function.

Reviewers: mstorsjo, rnk, arsenm

Reviewed By: rnk

Subscribers: wdng, llvm-commits

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

llvm-svn: 307521

7 years ago[X86] Remove asserts from getX86CpuIDAndInfo/getX86CpuIDAndInfoEx. Restore past behav...
Craig Topper [Mon, 10 Jul 2017 06:04:11 +0000 (06:04 +0000)]
[X86] Remove asserts from getX86CpuIDAndInfo/getX86CpuIDAndInfoEx. Restore past behavior of returning an unsupported indication to the caller instead.

These asserts could only occur if we fail to properly detect the compiler, but an assert is not a good way to do that because it doesn't work in release builds.

I wonder if we could use #error?

llvm-svn: 307520

7 years ago[ADT] Fix another "oops" spotted by eddyb and reported in IRC.
Chandler Carruth [Mon, 10 Jul 2017 05:41:14 +0000 (05:41 +0000)]
[ADT] Fix another "oops" spotted by eddyb and reported in IRC.

This test pretty clearly should be calling 'maxnum' here. =]

llvm-svn: 307519

7 years agoFix issues with UBSAN test configuration.
Eric Fiselier [Mon, 10 Jul 2017 04:32:21 +0000 (04:32 +0000)]
Fix issues with UBSAN test configuration.

On Apple the test feature 'sanitizer-new-delete' was incorrectly
getting added to the LIT feature set, which mistakenly caused tests
to be disabled when using UBSAN (the feature is only needed with ASAN/MSAN/TSAN).

llvm-svn: 307518

7 years agoWork around PR31864 - ATOMIC_LLONG_LOCK_FREE is incorrect in 32 bit builds
Eric Fiselier [Mon, 10 Jul 2017 04:16:50 +0000 (04:16 +0000)]
Work around PR31864 - ATOMIC_LLONG_LOCK_FREE is incorrect in 32 bit builds

llvm-svn: 307517

7 years agollvm-profdata: Reduce memory usage by using Error callback rather than member
David Blaikie [Mon, 10 Jul 2017 03:04:59 +0000 (03:04 +0000)]
llvm-profdata: Reduce memory usage by using Error callback rather than member

Reduces llvm-profdata memory usage on a large profile from 7.8GB to 5.1GB.

The ProfData API now supports reporting all the errors/warnings rather
than only the first, though llvm-profdata ignores everything after the
first for now to preserve existing behavior. (if there's a desire for
other behavior, happy to implement that - but might be as well left for
a separate patch)

Reviewers: davidxl

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

llvm-svn: 307516

7 years agoRemove incorrect FIXME comment; the FIXME was addressed before the changes were committed
Eric Fiselier [Mon, 10 Jul 2017 02:59:26 +0000 (02:59 +0000)]
Remove incorrect FIXME comment; the FIXME was addressed before the changes were committed

llvm-svn: 307515

7 years agoRemove non-ascii characters introduced in r307513
Eric Fiselier [Mon, 10 Jul 2017 02:52:34 +0000 (02:52 +0000)]
Remove non-ascii characters introduced in r307513

llvm-svn: 307514

7 years ago[coroutines] Include the implicit object parameter type when looking up coroutine_tra...
Eric Fiselier [Mon, 10 Jul 2017 01:27:22 +0000 (01:27 +0000)]
[coroutines] Include the implicit object parameter type when looking up coroutine_traits for member functions.

This patch was originally from Toby Allsopp, but I hijacked it and
fixed it up with his permission.

llvm-svn: 307513

7 years agoDon't access Python objects while not holding the GIL.
Zachary Turner [Sun, 9 Jul 2017 23:32:15 +0000 (23:32 +0000)]
Don't access Python objects while not holding the GIL.

Patch by Tatyana Krasnukha
Differential Revision: https://reviews.llvm.org/D34942

llvm-svn: 307512

7 years agoCGSCCPassManagerTest.cpp: Fix warnings. [-Wunused-variable]
NAKAMURA Takumi [Sun, 9 Jul 2017 23:06:05 +0000 (23:06 +0000)]
CGSCCPassManagerTest.cpp: Fix warnings. [-Wunused-variable]

llvm-svn: 307511

7 years agoFix test failure to to new/delete ellisions
Eric Fiselier [Sun, 9 Jul 2017 22:20:07 +0000 (22:20 +0000)]
Fix test failure to to new/delete ellisions

llvm-svn: 307510

7 years ago[analyzer] Faster hashing of subsequences in CompoundStmts.
Raphael Isemann [Sun, 9 Jul 2017 21:14:36 +0000 (21:14 +0000)]
[analyzer] Faster hashing of subsequences in CompoundStmts.

Summary: This patches improves the hashing subsequences in CompoundStmts by incrementally hashing all subsequences with the same starting position. This results in a reduction of the time for this constraint while running over SQLite from 1.10 seconds to 0.55 seconds (-50%).

Reviewers: NoQ

Reviewed By: NoQ

Subscribers: cfe-commits, xazax.hun, v.g.vassilev

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

llvm-svn: 307509

7 years ago[X86] Relax an assertion when legalizing vector types.
Davide Italiano [Sun, 9 Jul 2017 19:22:48 +0000 (19:22 +0000)]
[X86] Relax an assertion when legalizing vector types.

WidenVSELECTAndMask can fold (and it folds in this case) so we
get a BUILD_VECTOR of constants as mask. convertMask() seems to
work fine when the input is a vector of constants, and we still
need to call it to extend/add elements at the end. but the current
code just asserts on anything but a SETCC or AND/OR/XOR of 2xSETCC.
This change was discussed briefly with Simon Pilgrim, who also
suggests we might consider dropping this assertion in the future.

Fixes PR33715.

llvm-svn: 307508

7 years ago[X86] Add more feature flag bit defines to cpuid.h for gcc compatibility.
Craig Topper [Sun, 9 Jul 2017 17:43:11 +0000 (17:43 +0000)]
[X86] Add more feature flag bit defines to cpuid.h for gcc compatibility.

llvm-svn: 307507

7 years ago[X86] Add __get_cpuid_count to cpuid.h. Update __get_cpuid to check the maximum level...
Craig Topper [Sun, 9 Jul 2017 17:43:10 +0000 (17:43 +0000)]
[X86] Add __get_cpuid_count to cpuid.h. Update __get_cpuid to check the maximum level support before accessing the leaf. Rename level to leaf everywhere.

This matches gcc behavior.

llvm-svn: 307506

7 years agooptional: Implement LWG 2900 and P0602
Casey Carter [Sun, 9 Jul 2017 17:15:49 +0000 (17:15 +0000)]
optional: Implement LWG 2900 and P0602

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

llvm-svn: 307505

7 years ago[X86] Allow GHC calling convention to use YMM and ZMM registers
Simon Pilgrim [Sun, 9 Jul 2017 16:57:10 +0000 (16:57 +0000)]
[X86] Allow GHC calling convention to use YMM and ZMM registers

GHC 8.4 will know how to use YMM and ZMM registers for calls.

Submitted on behalf of @bgamari (Ben Gamari)

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

llvm-svn: 307504

7 years ago[AVR] Fix test errors due to tied operands not matching
Dylan McKay [Sun, 9 Jul 2017 16:36:35 +0000 (16:36 +0000)]
[AVR] Fix test errors due to tied operands not matching

Broken due to r307259.

llvm-svn: 307503

7 years agoHandle ConstantExpr correctly in SelectionDAGBuilder
Simon Pilgrim [Sun, 9 Jul 2017 16:01:04 +0000 (16:01 +0000)]
Handle ConstantExpr correctly in SelectionDAGBuilder

This change fixes a bug in SelectionDAGBuilder::visitInsertValue and SelectionDAGBuilder::visitExtractValue where constant expressions (InsertValueConstantExpr and ExtractValueConstantExpr) would be treated as non-constant instructions (InsertValueInst and ExtractValueInst). This bug resulted in an incorrect memory access, which manifested as an assertion failure in SDValue::SDValue.

Fixes PR#33094.

Submitted on behalf of @Praetonus (Benoit Vey)

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

llvm-svn: 307502

7 years ago[analyzer] Make StmtDataCollector part of the CloneDetection API
Raphael Isemann [Sun, 9 Jul 2017 15:56:39 +0000 (15:56 +0000)]
[analyzer] Make StmtDataCollector part of the CloneDetection API

Summary: We probably want to use this useful templates in other pieces of code (e.g. the one from D34329), so we should make this public.

Reviewers: NoQ

Reviewed By: NoQ

Subscribers: cfe-commits, xazax.hun, v.g.vassilev, johannes

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

llvm-svn: 307501

7 years ago[X86][AVX512] Regenerate AVX512VL comparison tests.
Simon Pilgrim [Sun, 9 Jul 2017 15:47:43 +0000 (15:47 +0000)]
[X86][AVX512] Regenerate AVX512VL comparison tests.

Show poor codegen on KNL targets as mentioned on D35179

llvm-svn: 307500

7 years agoRemove freed InvalidDomains from InvalidDomainMap.
Tobias Grosser [Sun, 9 Jul 2017 15:47:17 +0000 (15:47 +0000)]
Remove freed InvalidDomains from InvalidDomainMap.

Summary:
Since r306667, propagateInvalidStmtDomains gets a reference to an
InvalidDomainMap. As part of the branch leading to return false, the respective
domain is freed. It is, however, not removed from the InvalidDomainMap, leaking
a pointer to a freed object which results in a use-after-free. Fix this be
removing the domain from the map before returning.

We tried to derive a test case that reliably failes, but did not succeed in
producing one. Hence, for now the failures in our LNT bots must be sufficient
to keep this issue tested.

Reviewers: grosser, Meinersbur, bollu

Subscribers: bollu, nandini12396, pollydev, llvm-commits

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

llvm-svn: 307499

7 years ago[PM] Fix a nasty bug in the new PM where we failed to properly
Chandler Carruth [Sun, 9 Jul 2017 13:45:11 +0000 (13:45 +0000)]
[PM] Fix a nasty bug in the new PM where we failed to properly
invalidation of analyses when merging SCCs.

While I've added a bunch of testing of this, it takes something much
more like the inliner to really trigger this as you need to have
partially-analyzed SCCs with updates at just the right time. So I've
added a direct test for this using the inliner and verifying the
domtree. Without the changes here, this test ends up finding a stale
dominator tree.

However, to handle this properly, we need to invalidate analyses
*before* merging the SCCs. After talking to Philip and Sanjoy about this
they convinced me this was the right approach. To do this, we need
a callback mechanism when merging SCCs so we can observe the cycle that
will be merged before the merge happens. This API update ended up being
surprisingly easy.

With this commit, the new PM passes the test-suite again. It hadn't
since MemorySSA was enabled for EarlyCSE as that also will find this bug
very quickly.

llvm-svn: 307498

7 years ago[PM] Add unittesting of the call graph update logic with complex
Chandler Carruth [Sun, 9 Jul 2017 13:16:55 +0000 (13:16 +0000)]
[PM] Add unittesting of the call graph update logic with complex
dependencies between analyses.

This uncovers even more issues with the proxies and the splitting apart
of SCCs which are fixed in this patch. I discovered this while trying to
add more rigorous testing for a change I'm making to the call graph
update invalidation logic.

llvm-svn: 307497

7 years ago[ADT] Fix a test case to use a correct escape for a null byte followed
Chandler Carruth [Sun, 9 Jul 2017 07:37:47 +0000 (07:37 +0000)]
[ADT] Fix a test case to use a correct escape for a null byte followed
by a valid octal digit.

The length argument shows that this was in fact the intent.

This was pointed out in IRC, thanks to eddyb!

llvm-svn: 307496

7 years ago[X86] Remove check for AVX512 support from skylake-avx512 detection in getHostCPUName.
Craig Topper [Sun, 9 Jul 2017 07:26:14 +0000 (07:26 +0000)]
[X86] Remove check for AVX512 support from skylake-avx512 detection in getHostCPUName.

Users of getHostCPUName should also use getHostCPUFeatures which will take care of making sure avx512 is disabled if the CPU doesn't support it. This is consistent with what we do for other CPUs.

llvm-svn: 307495

7 years ago[GlobalISel][X86] Add legalizer tests for G_LOAD/G_STORE operations. NFC.
Igor Breger [Sun, 9 Jul 2017 07:25:57 +0000 (07:25 +0000)]
[GlobalISel][X86] Add legalizer tests for G_LOAD/G_STORE operations. NFC.

llvm-svn: 307494

7 years ago[PM] Teach PreservedAnalyses to have an `allInSet` static factory
Chandler Carruth [Sun, 9 Jul 2017 07:23:27 +0000 (07:23 +0000)]
[PM] Teach PreservedAnalyses to have an `allInSet` static factory
function template to simplify building a quick object with a set marked
as preserved.

llvm-svn: 307493

7 years ago[IR] Add Type::isIntOrIntVectorTy(unsigned) similar to the existing isIntegerTy(unsig...
Craig Topper [Sun, 9 Jul 2017 07:04:03 +0000 (07:04 +0000)]
[IR] Add Type::isIntOrIntVectorTy(unsigned) similar to the existing isIntegerTy(unsigned), but also works for vectors.

llvm-svn: 307492

7 years ago[IR] Make use of Type::isPtrOrPtrVectorTy/isIntOrIntVectorTy/isFPOrFPVectorTy to...
Craig Topper [Sun, 9 Jul 2017 07:04:00 +0000 (07:04 +0000)]
[IR] Make use of Type::isPtrOrPtrVectorTy/isIntOrIntVectorTy/isFPOrFPVectorTy to shorten code. NFC

llvm-svn: 307491

7 years ago[ADT] Add a default constructor and a bool conversion to function_ref.
Chandler Carruth [Sun, 9 Jul 2017 06:12:56 +0000 (06:12 +0000)]
[ADT] Add a default constructor and a bool conversion to function_ref.

The internal representation has a natural way to handle this and it
seems nicer than having to wrap this in an optional (with its own
separate flag).

This also matches how std::function works.

llvm-svn: 307490

7 years ago[FastISel] fix a fallback diagnostic.
Igor Breger [Sun, 9 Jul 2017 05:55:20 +0000 (05:55 +0000)]
[FastISel] fix a fallback diagnostic.

Summary: FastISel was marked as failed in case instruction selection succeeded.

Reviewers: qcolombet, zvi, rovka, ab

Reviewed By: zvi

Subscribers: javed.absar, ab, qcolombet, bogner, llvm-commits

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

llvm-svn: 307489

7 years agofix trivial typos; NFC
Hiroshi Inoue [Sun, 9 Jul 2017 05:54:44 +0000 (05:54 +0000)]
fix trivial typos; NFC

sucessor -> successor

llvm-svn: 307488

7 years ago[PM] Finish implementing and fix a chain of bugs uncovered by testing
Chandler Carruth [Sun, 9 Jul 2017 03:59:31 +0000 (03:59 +0000)]
[PM] Finish implementing and fix a chain of bugs uncovered by testing
the invalidation propagation logic from an SCC to a Function.

I wrote the infrastructure to test this but didn't actually use it in
the unit test where it was designed to be used. =[ My bad. Once
I actually added it to the test case I discovered that it also hadn't
been properly implemented, so I've implemented it. The logic in the FAM
proxy for an SCC pass to propagate invalidation follows the same ideas
as the FAM proxy for a Module pass, but the implementation is a bit
different to reflect the fact that it is forwarding just for an SCC.

However, implementing this correctly uncovered a surprising "bug" (it
was conservatively correct but relatively very expensive) in how we
handle invalidation when splitting one SCC into multiple SCCs. We did an
eager invalidation when in reality we should be deferring invaliadtion
for the *current* SCC to the CGSCC pass manager and just invaliating the
newly constructed SCCs. Otherwise we end up invalidating too much too
soon. This was exposed by the inliner test case that I've updated. Now,
we invalidate *just* the split off '(test1_f)' SCC when doing the CG
update, and then the inliner finishes and invalidates the '(test1_g,
test1_h)' SCC's analyses. The first few attempts at fixing this hit
still more bugs, but all of those are covered by existing tests. For
example, the inliner should also preserve the FAM proxy to avoid
unnecesasry invalidation, and this is safe because the CG update
routines it uses handle any necessary adjustments to the FAM proxy.

Finally, the unittests for the CGSCC pass manager needed a bunch of
updates where we weren't correctly preserving the FAM proxy because it
hadn't been fully implemented and failing to preserve it didn't matter.

Note that this doesn't yet fix the current crasher due to MemSSA finding
a stale dominator tree, but without this the fix to that crasher doesn't
really make any sense when testing because it relies on the proxy
behavior.

llvm-svn: 307487

7 years ago[InstCombine] Speculatively implement a fix for what might be the root cause of PR337...
Craig Topper [Sun, 9 Jul 2017 03:25:17 +0000 (03:25 +0000)]
[InstCombine] Speculatively implement a fix for what might be the root cause of PR33721 by making sure that we have integer types before doing select C, -1, 0 -> sext C to int

I recently changed m_One and m_AllOnes to use Constant::isOneValue/isAllOnesValue which work on floating point values too. The original implementation looked specifically for ConstantInt scalars and splats. So I'm guessing we are accidentally trying to issue sext/zexts on floating point types now.

Hopefully I figure out how to reproduce the failure from the PR soon.

llvm-svn: 307486

7 years ago[AMDGPU] Fix -Wimplicit-fallthrough warning. NFCI.
Simon Pilgrim [Sat, 8 Jul 2017 19:50:03 +0000 (19:50 +0000)]
[AMDGPU] Fix -Wimplicit-fallthrough warning. NFCI.

llvm-svn: 307485

7 years ago[AArch64] Fix -Wimplicit-fallthrough warnings. NFCI.
Simon Pilgrim [Sat, 8 Jul 2017 19:28:24 +0000 (19:28 +0000)]
[AArch64] Fix -Wimplicit-fallthrough warnings. NFCI.

Add breaks - doesn't affect results as both GPR/FPU both check for 32/64 bit sizes. So will still default to GenericOps in the same way.

llvm-svn: 307484

7 years agoFix build failure with gcc about mixing enum and non-enum
Yaxun Liu [Sat, 8 Jul 2017 19:13:41 +0000 (19:13 +0000)]
Fix build failure with gcc about mixing enum and non-enum

llvm-svn: 307483

7 years ago[Demangler] NFC: Don't make the parse_* functions templates
Erik Pilkington [Sat, 8 Jul 2017 18:54:08 +0000 (18:54 +0000)]
[Demangler] NFC: Don't make the parse_* functions templates

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

llvm-svn: 307482

7 years ago[Demangler] NFC: Move Db struct to beginning of file
Erik Pilkington [Sat, 8 Jul 2017 18:54:07 +0000 (18:54 +0000)]
[Demangler] NFC: Move Db struct to beginning of file

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

llvm-svn: 307481

7 years ago[ARM] Fix -Wimplicit-fallthrough warning. NFCI.
Simon Pilgrim [Sat, 8 Jul 2017 18:42:04 +0000 (18:42 +0000)]
[ARM] Fix -Wimplicit-fallthrough warning. NFCI.

llvm-svn: 307480

7 years ago[Bash-autocompletion] Auto complete cc1 options if -cc1 is specified
Yuka Takahashi [Sat, 8 Jul 2017 17:48:59 +0000 (17:48 +0000)]
[Bash-autocompletion] Auto complete cc1 options if -cc1 is specified

Summary:
We don't want to autocomplete flags whose Flags class has `NoDriverOption` when argv[1] is not `-cc1`.

Another idea for this implementation is to make --autocomplete a cc1
option and handle it in clang Frontend, by porting --autocomplete
handler from Driver to Frontend, so that we can handle Driver options
and CC1 options in unified manner.

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

llvm-svn: 307479

7 years ago[Bash-autocompletion] Fix a bug that -foo=bar doesn't handled properly
Yuka Takahashi [Sat, 8 Jul 2017 17:34:02 +0000 (17:34 +0000)]
[Bash-autocompletion] Fix a bug that -foo=bar doesn't handled properly

Summary: Fixed a bug that -foo=bar wasn't handled properly on old version of bash.

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

llvm-svn: 307478

7 years agoRe-enable "[IndVars] Canonicalize comparisons between non-negative values and indvars"
Max Kazantsev [Sat, 8 Jul 2017 17:17:30 +0000 (17:17 +0000)]
Re-enable "[IndVars] Canonicalize comparisons between non-negative values and indvars"

The patch was reverted due to a bug. The bug was that if the IV is the 2nd operand of the icmp
instruction, then the "Pred" variable gets swapped and differs from the instruction's predicate.
In this patch we use the original predicate to do the transformation.

Also added a test case that exercises this situation.

Differentian Revision: https://reviews.llvm.org/D35107

llvm-svn: 307477

7 years ago[LoopVectorize] partly revert r307475
Sanjay Patel [Sat, 8 Jul 2017 16:34:46 +0000 (16:34 +0000)]
[LoopVectorize] partly revert r307475

Bots are failing because of the additional checks.

llvm-svn: 307476

7 years ago[LoopVectorize] auto-generate complete checks; NFC
Sanjay Patel [Sat, 8 Jul 2017 16:10:42 +0000 (16:10 +0000)]
[LoopVectorize] auto-generate complete checks; NFC

I'm looking at a cmp transform in InstCombine that would affect these tests,
but it's hard to know if it makes things better or worse without seeing the
full IR. OTOH, maybe these tests shouldn't be running a bunch of transform
passes in the first place?

llvm-svn: 307475

7 years agoAdd a .arcconfig file for openmp.
Dimitry Andric [Sat, 8 Jul 2017 16:09:47 +0000 (16:09 +0000)]
Add a .arcconfig file for openmp.

llvm-svn: 307474

7 years agoFix -Wimplicit-fallthrough warning. NFCI.
Simon Pilgrim [Sat, 8 Jul 2017 15:26:26 +0000 (15:26 +0000)]
Fix -Wimplicit-fallthrough warning. NFCI.

llvm-svn: 307473

7 years ago[CodeGen] Fold variable into assert.
Benjamin Kramer [Sat, 8 Jul 2017 14:14:57 +0000 (14:14 +0000)]
[CodeGen] Fold variable into assert.

Avoids warnings in Release builds.

llvm-svn: 307472

7 years ago[x86] add SBB optimization for SETBE (ule) condition code
Sanjay Patel [Sat, 8 Jul 2017 14:04:48 +0000 (14:04 +0000)]
[x86] add SBB optimization for SETBE (ule) condition code

x86 scalar select-of-constants (Cond ? C1 : C2) combining/lowering is a mess
with missing optimizations. We handle some patterns, but miss logical variants.

To clean that up, we should convert all select-of-constants to logic/math and
enhance the combining for the expected patterns from that. Selecting 0 or -1
needs extra attention to produce the optimal code as shown here.

Attempt to verify that all of these IR forms are logically equivalent:
http://rise4fun.com/Alive/plxs

Earlier steps in this series:
rL306040
rL306072
rL307404 (D34652)

As acknowledged in the earlier review, there's a possibility that some Intel
uarch would prefer to produce an xor to clear the fake register operand with
sbb %eax, %eax. This will likely need to be addressed in a separate pass.

llvm-svn: 307471

7 years agoCodeGen: Fix address space of global variable
Yaxun Liu [Sat, 8 Jul 2017 13:24:52 +0000 (13:24 +0000)]
CodeGen: Fix address space of global variable

Certain targets (e.g. amdgcn) require global variable to stay in global or constant address
space. In C or C++ global variables are emitted in the default (generic) address space.
This patch introduces virtual functions TargetCodeGenInfo::getGlobalVarAddressSpace
and TargetInfo::getConstantAddressSpace to handle this in a general approach.

It only affects IR generated for amdgcn target.

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

llvm-svn: 307470

7 years ago[Solaris] get rid of _RESTRICT_KYWD warning during the build
Kamil Rytarowski [Sat, 8 Jul 2017 11:27:56 +0000 (11:27 +0000)]
[Solaris] get rid of _RESTRICT_KYWD warning during the build

Summary:
(re)definition of _RESTRICT_KYWD rightfully causes a warning message during the Solaris build.
This hack is not needed if build compiler is properly configured (.e.g /usr/bin/gcc) so just remove it.

Reviewers: ro, mgorny, krytarowski, joerg

Reviewed By: joerg

Subscribers: quenelle, llvm-commits

Patch by Fedor Sergeev (Oracle).

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

llvm-svn: 307469

7 years ago[analyzer] Fix a path in the developer manual
Gabor Horvath [Sat, 8 Jul 2017 08:23:52 +0000 (08:23 +0000)]
[analyzer] Fix a path in the developer manual

Patch by: Reka Nikolett Kovacs

llvm-svn: 307468

7 years ago[X86] In getHostCPUName, remove some code that changes some AMD CPU names based on...
Craig Topper [Sat, 8 Jul 2017 06:44:36 +0000 (06:44 +0000)]
[X86] In getHostCPUName, remove some code that changes some AMD CPU names based on features not being enabled.

The CPU name is really just used for scheduler and other microarchitectural optimizations. The feature flags should be determined by getHostCPUFeatures which should always be used with getHostCPUName. Trying to alter CPU name strings to control features just isn't practical.

Most of these types of things were removed from Intel CPUs a while ago.

This is part of my plan to bring compiler-rt's cpu_model.c file up to date with the equivalent functionality in libgcc. A lot of the code in that file is copied from Host.cpp and we want to keep them reasonably in sync.

llvm-svn: 307467

7 years ago[X86] Correct the BDVER4 model numbers to include 0x70-0x7f.
Craig Topper [Sat, 8 Jul 2017 06:44:35 +0000 (06:44 +0000)]
[X86] Correct the BDVER4 model numbers to include 0x70-0x7f.

According to wikipedia and some other googling suggests these should also be considered as BDVER4.

llvm-svn: 307466

7 years ago[X86] Minor formatting fix. NFC
Craig Topper [Sat, 8 Jul 2017 06:44:34 +0000 (06:44 +0000)]
[X86] Minor formatting fix. NFC

llvm-svn: 307465

7 years agoUpdate message that Main Thread Checker produces.
Kuba Mracek [Sat, 8 Jul 2017 05:18:19 +0000 (05:18 +0000)]
Update message that Main Thread Checker produces.

llvm-svn: 307464

7 years ago[X86] Use 'unsigned' instead of 'unsigned int' for consistency in the X86 portion...
Craig Topper [Sat, 8 Jul 2017 05:16:14 +0000 (05:16 +0000)]
[X86] Use 'unsigned' instead of 'unsigned int' for consistency in the X86 portion of Host.cpp.

llvm-svn: 307463

7 years ago[X86] Cleanup some CPUID usage in getAvailableFeatures.
Craig Topper [Sat, 8 Jul 2017 05:16:13 +0000 (05:16 +0000)]
[X86] Cleanup some CPUID usage in getAvailableFeatures.

We should make sure leaf 1 is available before accessing it. Same with leaf 0x80000001.

llvm-svn: 307462

7 years agoFix filesystem build on platforms with weird time_t types.
Eric Fiselier [Sat, 8 Jul 2017 04:18:41 +0000 (04:18 +0000)]
Fix filesystem build on platforms with weird time_t types.

32-bit powerpc provides a 64 bit time_t type and older ppc64 systems
provide time_t as a floating point type. This caused problems when building
operations.cpp since operations.cpp contained compile time tests for conversions
between time_t and filesystem time type.

When these tests failed they caused the libc++ build to fail as well. This is unfortunate.

This patch moves the tests out of the source file and into the test suite. It also
expands the tests to allow testing of the weird time_t configurations on all platforms.

llvm-svn: 307461

7 years agoRevert "Revert "Revert "Revert "Switch external cvtres.exe for llvm's own resource...
Eric Beckmann [Sat, 8 Jul 2017 03:06:10 +0000 (03:06 +0000)]
Revert "Revert "Revert "Revert "Switch external cvtres.exe for llvm's own resource library.""""

This reverts commit 147f45ff24456aea59575fa4ac16c8fa554df46a.

Revert "Revert "Revert "Revert "Replace trivial use of external rc.exe by writing our own .res file.""""

This reverts commit 61a90a67ed54a1f0dfeab457b65abffa129569e4.

The patches were intially reverted because they were causing a failure
on CrWinClangLLD.  Unfortunately, this was done haphazardly and didn't
compile, so the revert was reverted again quickly to fix this.  One that
was done, the revert of the revert was itself reverted.  This allowed me
to finally fix the actual bug in r307452.  This patch re-enables the
code path that had originally been causing the bug, now that it (should)
be fixed.

llvm-svn: 307460

7 years agoDelete the pdb diff test.
Zachary Turner [Sat, 8 Jul 2017 02:54:19 +0000 (02:54 +0000)]
Delete the pdb diff test.

This is failing on Linux for unknown reasons, so I need to
get the bots green while I investigate.

llvm-svn: 307459

7 years ago[ODRHash] Support FriendDecl
Richard Trieu [Sat, 8 Jul 2017 02:04:42 +0000 (02:04 +0000)]
[ODRHash] Support FriendDecl

llvm-svn: 307458

7 years agoRemove a variable that was only used in asserts and had a duplicate copy in something...
Eric Christopher [Sat, 8 Jul 2017 01:03:29 +0000 (01:03 +0000)]
Remove a variable that was only used in asserts and had a duplicate copy in something we did use anyhow.

llvm-svn: 307457

7 years ago[X86] Move AVX512VPOPCNTDQ in __builtin_cpu_support's enum to match trunk gcc.
Craig Topper [Sat, 8 Jul 2017 00:47:44 +0000 (00:47 +0000)]
[X86] Move AVX512VPOPCNTDQ in __builtin_cpu_support's enum to match trunk gcc.

There are two other features before it that we don't currently support in the the frontend or backend so I left placeholders to keep the encoding correct.

I think the compiler-rt implementation of this feature is even further out of date.

llvm-svn: 307456

7 years agoFix warnings introduced by r307434.
Richard Smith [Sat, 8 Jul 2017 00:37:59 +0000 (00:37 +0000)]
Fix warnings introduced by r307434.

llvm-svn: 307455

7 years agoThe x86 instruction unwinder can be asked to disassemble non-instruction
Jason Molenda [Sat, 8 Jul 2017 00:12:15 +0000 (00:12 +0000)]
The x86 instruction unwinder can be asked to disassemble non-instruction
blocks of memory, and if the final bytes of that block look like a long
x86 instruction, it can cause the llvm disassembler to read past the end
of the buffer.  Use the maximum allowed instruction length that we pass
to the llvm disassembler as a way to limit this to the size of the buffer.

An example of how to trigger this is when lldb does a function call, it
puts a breakpoint on the beginning of main() and uses that as the return
address from the function call.  When we stop at that location, lldb may
try to find the first frame up the stack.  Because this is on the first
instruction of a function, it will get the word-size value at the stack
pointer and assume that this was the caller's pc value.  But this is random
stack memory and could point to anything - an object in memory, something
in the data section, whatever.  And if we have a symbol for that thing,
we'll try to disassemble it.

This was leading to infrequent crashes in customer scenarios; figured out
what was happening with address sanitizer.

<rdar://problem/30463256>

llvm-svn: 307454

7 years agoAdd name offset flags, for parity with cvtres.exe.
Eric Beckmann [Fri, 7 Jul 2017 23:23:53 +0000 (23:23 +0000)]
Add name offset flags, for parity with cvtres.exe.

Summary:
The original cvtres.exe sets the high bit when an identifier offset
points to a string.  Even though this is not mentioned in the spec, and
in fact does not seem to cause errors with most cases, for some reason
this causes a failure in Chromium where the new resource file is not
verified as a new version.  This patch sets this high bit flag, and also
adds a test case to check that the output of our library is always
identical to original cvtres.

Reviewers: zturner, ruiu

Subscribers: llvm-commits, hiraditya

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

llvm-svn: 307452

7 years ago[InstCombine] Make InstCombine's IRBuilder be passed by reference everywhere
Craig Topper [Fri, 7 Jul 2017 23:16:26 +0000 (23:16 +0000)]
[InstCombine] Make InstCombine's IRBuilder be passed by reference everywhere

Previously the InstCombiner class contained a pointer to an IR builder that had been passed to the constructor. Sometimes this would be passed to helper functions as either a pointer or the pointer would be dereferenced to be passed by reference.

This patch makes it a reference everywhere including the InstCombiner class itself so there is more inconsistency. This a large, but mechanical patch. I've done very minimal formatting changes on it despite what clang-format wanted to do.

llvm-svn: 307451

7 years agoFix diagnostic in verify test to match new Clang output
Eric Fiselier [Fri, 7 Jul 2017 23:02:30 +0000 (23:02 +0000)]
Fix diagnostic in verify test to match new Clang output

llvm-svn: 307450

7 years agoRevert r307445 as it breaks on certain platforms.
Dehao Chen [Fri, 7 Jul 2017 22:40:37 +0000 (22:40 +0000)]
Revert r307445 as it breaks on certain platforms.

llvm-svn: 307449

7 years agoMake sure SANITIZER_MIN_OSX_VERSION is defined before using it.
Kuba Mracek [Fri, 7 Jul 2017 22:40:13 +0000 (22:40 +0000)]
Make sure SANITIZER_MIN_OSX_VERSION is defined before using it.

llvm-svn: 307448

7 years ago[MS] Don't statically initialize dllimport member function pointers
Reid Kleckner [Fri, 7 Jul 2017 22:04:29 +0000 (22:04 +0000)]
[MS] Don't statically initialize dllimport member function pointers

Summary:
r306137 made dllimport pointers to member functions non-constant. This
is correct because a load must be executed to resolve any dllimported
data. However, r306137 did not account for the use of dllimport member
function pointers used as template arguments.

This change re-lands r306137 with a template instantiation fix.

This fixes PR33570.

Reviewers: rnk, majnemer

Subscribers: cfe-commits

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

llvm-svn: 307446

7 years agoAdd sample PGO integration test to cover profile annotation and inlining.
Dehao Chen [Fri, 7 Jul 2017 22:01:47 +0000 (22:01 +0000)]
Add sample PGO integration test to cover profile annotation and inlining.

Summary: The patch makes the integration test cover major sample PGO components.

Reviewers: davidxl

Reviewed By: davidxl

Subscribers: sanjoy, cfe-commits

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

llvm-svn: 307445

7 years agoAdd testcase for r305850.
Lang Hames [Fri, 7 Jul 2017 21:51:11 +0000 (21:51 +0000)]
Add testcase for r305850.

Accidentally left this out of the original commit.

llvm-svn: 307444

7 years agoUpdate buildgo.sh to pass -isysroot on Darwin.
Kuba Mracek [Fri, 7 Jul 2017 21:17:29 +0000 (21:17 +0000)]
Update buildgo.sh to pass -isysroot on Darwin.

llvm-svn: 307443

7 years ago[PowerPC] NFC : Common up definitions of isIntS16Immediate and update parameter to...
Lei Huang [Fri, 7 Jul 2017 21:12:35 +0000 (21:12 +0000)]
[PowerPC] NFC : Common up definitions of isIntS16Immediate and update parameter to int16_t

llvm-svn: 307442

7 years agoremove deprecated register storage class specifier
Ed Maste [Fri, 7 Jul 2017 21:06:05 +0000 (21:06 +0000)]
remove deprecated register storage class specifier

While importing libomp into the FreeBSD base system we encountered
Clang warnings that "'register' storage class specifier is deprecated
and incompatible with C++1z [-Wdeprecated-register]".

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

llvm-svn: 307441

7 years agoProfData: Fix some unchecked Errors in unit tests
David Blaikie [Fri, 7 Jul 2017 21:02:59 +0000 (21:02 +0000)]
ProfData: Fix some unchecked Errors in unit tests

The 'NoError' function was meant to be used as the input to
ASSERT/EXPECT_TRUE, but it is easy to forget this (it could be annotated
with nodiscard to help this) so many sites that look like they're checked
are not (& silently discard the failure). Only one site actually has an
Error sneaking out this way and I've replaced that one with a
FIXME+consumeError.

The rest of the code has been modified to use the EXPECT_THAT_ERROR
macros Zach introduced a while back. Between the options available this
seems OK/good/something to standardize on - though it's difficult to
build a matcher that could handle checking for a specific llvm::Error
result, so those remain using the custom ErrorEquals (& the nodiscard
added to ensure it is not misused as it was previous to this patch). It
could still be generalized a bit further (even not as far as a matcher,
but at least support multiple kinds of Error, etc) & added to the
general Error utility header.

llvm-svn: 307440

7 years agoIncrease the import-threshold for crtical functions.
Dehao Chen [Fri, 7 Jul 2017 21:01:00 +0000 (21:01 +0000)]
Increase the import-threshold for crtical functions.

Summary: For interative sample-pgo, if a hot call site is inlined in the profiling binary, we should inline it in before profile annotation in the backend. Before that, the compile phase first collects all GUIDs that needs to be imported and creates virtual "hot" call edge in the summary. However, "hot" is not good enough to guarantee the callsites get inlined. This patch introduces "critical" call edge, and assign much higher importing threshold for those edges.

Reviewers: tejohnson

Reviewed By: tejohnson

Subscribers: sanjoy, mehdi_amini, llvm-commits, eraman

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

llvm-svn: 307439

7 years agoEnable the new PM + SamlePGO + ThinLTO testing.
Dehao Chen [Fri, 7 Jul 2017 20:53:17 +0000 (20:53 +0000)]
Enable the new PM + SamlePGO + ThinLTO testing.

Summary: This patch should be enabled after https://reviews.llvm.org/D34895

Reviewers: chandlerc, tejohnson, davidxl

Reviewed By: tejohnson

Subscribers: sanjoy, mehdi_amini, inglorion, eraman, cfe-commits

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

llvm-svn: 307438

7 years agoAdd sample PGO support to ThinLTO new pass manager.
Dehao Chen [Fri, 7 Jul 2017 20:53:10 +0000 (20:53 +0000)]
Add sample PGO support to ThinLTO new pass manager.

Summary:
For SamplePGO + ThinLTO, because profile annotation is done twice at both PrepareForThinLTO pipeline and backend compiler, the following changes are needed at the PrepareForThinLTO phase to ensure the IR is not changed dramatically. Otherwise the profile annotation will be inaccurate in the backend compiler.

* disable hot-caller heuristic
* disable loop unrolling
* disable indirect call promotion

This will unblock the new PM testing for sample PGO (tools/clang/test/CodeGen/pgo-sample-thinlto-summary.c), which will be covered in another cfe patch.

Reviewers: chandlerc, tejohnson, davidxl

Reviewed By: tejohnson

Subscribers: sanjoy, mehdi_amini, Prazek, inglorion, llvm-commits

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

llvm-svn: 307437