OSDN Git Service

android-x86/external-llvm.git
5 years agoAMDGPU: Remove remnants of old address space mapping
Matt Arsenault [Fri, 31 Aug 2018 05:49:54 +0000 (05:49 +0000)]
AMDGPU: Remove remnants of old address space mapping

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341165 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ORC] Remove a stray debugging output line left in a unit test.
Lang Hames [Fri, 31 Aug 2018 00:53:53 +0000 (00:53 +0000)]
[ORC] Remove a stray debugging output line left in a unit test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341155 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ORC] Add utilities to RTDyldObjectLinkingLayer2 to simplify symbol flag
Lang Hames [Fri, 31 Aug 2018 00:53:17 +0000 (00:53 +0000)]
[ORC] Add utilities to RTDyldObjectLinkingLayer2 to simplify symbol flag
management and materialization responsibility registration.

The setOverrideObjectFlagsWithResponsibilityFlags method instructs
RTDyldObjectlinkingLayer2 to override the symbol flags produced by RuntimeDyld with
the flags provided by the MaterializationResponsibility instance. This can be used
to enable symbol visibility (hidden/exported) for COFF object files, which do not
currently support the SF_Exported flag.

The setAutoClaimResponsibilityForObjectSymbols method instructs
RTDyldObjectLinkingLayer2 to claim responsibility for any symbols provided by a
given object file that were not already in the MaterializationResponsibility
instance. Setting this flag allows higher-level program representations (e.g.
LLVM IR) to be added based on only a subset of the symbols they provide, without
having to write intervening layers to scan and add the additional symbols. This
trades diagnostic quality for convenience however: If all symbols are enumerated
up-front then clashes can be detected and reported early. If this option is set,
clashes for the additional symbols may not be detected until late, and detection
may depend on the flow of control through JIT'd code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341154 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoImport lit.llvm after rL341135
Fangrui Song [Fri, 31 Aug 2018 00:22:20 +0000 (00:22 +0000)]
Import lit.llvm after rL341135

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341149 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "[NFC] Add severe validation of InstructionPrecedenceTracking" for discussion
Max Kazantsev [Fri, 31 Aug 2018 00:01:54 +0000 (00:01 +0000)]
Revert "[NFC] Add severe validation of InstructionPrecedenceTracking" for discussion

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341147 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] adding initial intersect test for Node to Instruction association
Michael Berg [Thu, 30 Aug 2018 22:43:34 +0000 (22:43 +0000)]
[NFC] adding initial intersect test for Node to Instruction association

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341138 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Hexagon] Check validity of register class when generating bitsplit
Krzysztof Parzyszek [Thu, 30 Aug 2018 22:26:43 +0000 (22:26 +0000)]
[Hexagon] Check validity of register class when generating bitsplit

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341137 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ARM] Enable GEP offset splitting for 32-bit ARM.
Eli Friedman [Thu, 30 Aug 2018 22:18:27 +0000 (22:18 +0000)]
[ARM] Enable GEP offset splitting for 32-bit ARM.

It has essentially the same benefit it has on 64-bit ARM: it
substantially reduces the number of constants used by large GEP
operations. Seems to be generally helpful across a few different
codebases I've tried.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341136 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemove LIT_SITE_CFG_IN_FOOTER, llvm
Nico Weber [Thu, 30 Aug 2018 22:13:34 +0000 (22:13 +0000)]
Remove LIT_SITE_CFG_IN_FOOTER, llvm

It's always replaced with the same (short) static string, so just put that
there directly.

No intended behavior change.
https://reviews.llvm.org/D51357

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341135 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[WebAssembly] Update utility functions with SIMD types
Thomas Lively [Thu, 30 Aug 2018 22:10:43 +0000 (22:10 +0000)]
[WebAssembly] Update utility functions with SIMD types

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341131 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[WebAssembly] Vector conversions
Thomas Lively [Thu, 30 Aug 2018 21:43:51 +0000 (21:43 +0000)]
[WebAssembly] Vector conversions

Summary:
Lowers away bitconverts between vector types. This CL depends
on D51383.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341128 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[WebAssembly] SIMD loads and stores
Thomas Lively [Thu, 30 Aug 2018 21:36:48 +0000 (21:36 +0000)]
[WebAssembly] SIMD loads and stores

Summary: Reuse the patterns from WebAssemblyInstrMemory.td.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341127 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agodsymutil: Avoid pruning non-type forward declarations inside DW_TAG_module
Adrian Prantl [Thu, 30 Aug 2018 21:21:16 +0000 (21:21 +0000)]
dsymutil: Avoid pruning non-type forward declarations inside DW_TAG_module
forward declarations.

Especially with template instantiations, there are legitimate reasons
why for declarations might be emitted into a DW_TAG_module skeleton /
forward-declaration sub-tree, that are not forward declarations in the
sense of that there is a more complete definition over in a .pcm file.

The example in the testcase is a constant DW_TAG_member of a
DW_TAG_class template instatiation.

rdar://problem/43623196

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341123 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemove some debugging code that was accidentally left in.
Zachary Turner [Thu, 30 Aug 2018 21:00:57 +0000 (21:00 +0000)]
Remove some debugging code that was accidentally left in.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341122 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd a utility script to stress test the demangler.
Zachary Turner [Thu, 30 Aug 2018 20:53:48 +0000 (20:53 +0000)]
Add a utility script to stress test the demangler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341120 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[MS Demangler] Add support for $$Z parameter pack separator.
Zachary Turner [Thu, 30 Aug 2018 20:53:29 +0000 (20:53 +0000)]
[MS Demangler] Add support for $$Z parameter pack separator.

$$Z appears between adjacent expanded parameter packs in the
same template instantiation.  We don't need to print it, it's
only there to disambiguate between manglings that would otherwise
be ambiguous.  So we just need to parse it and throw it away.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341119 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoSafeStack: Prevent OOB reads with mem intrinsics
Vlad Tsyrklevich [Thu, 30 Aug 2018 20:44:51 +0000 (20:44 +0000)]
SafeStack: Prevent OOB reads with mem intrinsics

Summary:
Currently, the SafeStack analysis disallows out-of-bounds writes but not
out-of-bounds reads for mem intrinsics like llvm.memcpy. This could
cause leaks of pointers to the safe stack by leaking spilled registers/
frame pointers. Check for allocas used as source or destination pointers
to mem intrinsics.

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: pcc, llvm-commits, kcc

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341116 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoHashing: use 64-bit seed for hashing on all platforms.
Tim Northover [Thu, 30 Aug 2018 20:28:32 +0000 (20:28 +0000)]
Hashing: use 64-bit seed for hashing on all platforms.

get_execution_seed returns a size_t which varies across platforms, but its
users actually always feed it into a uint64_t role so it makes sense to be
consistent.

Mostly this is just a tidy-up, but it also apparently allows PCH files to be
shared between Clang compilers built for 32-bit and 64-bit hosts.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341113 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Add -x86-experimental-vector-widening-legalization command lines to vector...
Craig Topper [Thu, 30 Aug 2018 20:10:10 +0000 (20:10 +0000)]
[X86] Add -x86-experimental-vector-widening-legalization command lines to vector-idiv-v2i32.ll

If we're legalizing via widening already, then the type legalizer will scalarize the divs/rems as i32.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341108 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago [RISCV] Fixed SmallVector.h Assertion `idx < size()'
Ana Pazos [Thu, 30 Aug 2018 19:43:19 +0000 (19:43 +0000)]
 [RISCV] Fixed SmallVector.h Assertion `idx < size()'

Summary:

RISCVAsmParser needs to handle the case the error message is of specific type, other than the generic Match_InvalidOperand, and the corresponding
operand is missing.

This bug was uncovered by a LLVM MC Assembler Protocol Buffer Fuzzer  for the RISC-V assembly language.

Reviewers: asb

Reviewed By: asb

Subscribers: llvm-commits, jocewei, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, kito-cheng, shiva0217, zzheng, edward-jones, mgrang, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341104 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[DAGCombiner] Fix bad identation. NFC
Craig Topper [Thu, 30 Aug 2018 19:35:40 +0000 (19:35 +0000)]
[DAGCombiner] Fix bad identation. NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341103 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Weaken an overly aggressive assert.
Craig Topper [Thu, 30 Aug 2018 19:35:38 +0000 (19:35 +0000)]
[X86] Weaken an overly aggressive assert.

This assert tried to check that AND constants are only on the RHS. But its possible for both operands to be constants if one is opaque which will prevent the AND from being constant folded.

Fixes PR38771

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341102 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ARM] Adjust the feature set for Exynos
Evandro Menezes [Thu, 30 Aug 2018 19:22:00 +0000 (19:22 +0000)]
[ARM] Adjust the feature set for Exynos

Enable `FeatureUseAA` for all Exynos processors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341101 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[InstCombine] Expand the simplification of pow() into exp2()
Evandro Menezes [Thu, 30 Aug 2018 19:04:51 +0000 (19:04 +0000)]
[InstCombine] Expand the simplification of pow() into exp2()

Generalize the simplification of `pow(2.0, y)` to `pow(2.0 ** n, y)` for all
scalar and vector types.

This improvement helps some benchmarks in SPEC CPU2000 and CPU2006, such as
252.eon, 447.dealII, 453.povray.  Otherwise, no significant regressions on
x86-64 or A64.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341095 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[SROA] Fix alignment for uses of PHI nodes.
Eli Friedman [Thu, 30 Aug 2018 18:59:24 +0000 (18:59 +0000)]
[SROA] Fix alignment for uses of PHI nodes.

Splitting an alloca can decrease the alignment of GEPs into the
partition.  Normally, rewriting accounts for this, but the code was
missing for uses of PHI nodes and select instructions.

Fixes https://bugs.llvm.org/show_bug.cgi?id=38707 .

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341094 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoReverting r340807.
Andrew Kaylor [Thu, 30 Aug 2018 18:37:18 +0000 (18:37 +0000)]
Reverting r340807.

This patch restores the old behavior of getAllocationDataForFunction in MemoryBuiltins.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341091 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Add kshift test cases for D51401. NFC
Craig Topper [Thu, 30 Aug 2018 17:51:02 +0000 (17:51 +0000)]
[X86] Add kshift test cases for D51401. NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341088 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAllow inconsistent offsets for 'noreturn' basic blocks when '-verify-cfiinstrs'
Vladimir Stefanovic [Thu, 30 Aug 2018 17:31:38 +0000 (17:31 +0000)]
Allow inconsistent offsets for 'noreturn' basic blocks when '-verify-cfiinstrs'

With r295105, some 'noreturn' blocks (those that don't return and have no
successors) may be merged.
If such blocks' predecessors have different outgoing offset or register, don't
report an error in CFIInstrInserter verify().

Thanks to Vlad Tsyrklevich for reporting the issue.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341087 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[LLVM-C] Add Bindings For Named Metadata
Robert Widmann [Thu, 30 Aug 2018 17:09:43 +0000 (17:09 +0000)]
[LLVM-C] Add Bindings For Named Metadata

Summary: Add a new type for named metadata nodes.  Use this to implement iterators and accessors for NamedMDNodes and extend the echo test to use them to copy module-level debug information.

Reviewers: whitequark, deadalnix, aprantl, dexonsmith

Reviewed By: whitequark

Subscribers: Wallbraker, JDevlieghere, llvm-commits, harlanhaskins

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341085 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[IR] fix declaration of shuffle mask
Sanjay Patel [Thu, 30 Aug 2018 16:44:07 +0000 (16:44 +0000)]
[IR] fix declaration of shuffle mask

An address sanitizer bot flagged this as a potential bug.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341084 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[libFuzzer] Port to Windows
Matt Morehouse [Thu, 30 Aug 2018 15:54:44 +0000 (15:54 +0000)]
[libFuzzer] Port to Windows

Summary:
Port libFuzzer to windows-msvc.
This patch allows libFuzzer targets to be built and run on Windows, using -fsanitize=fuzzer and/or fsanitize=fuzzer-no-link. It allows these forms of coverage instrumentation to work on Windows as well.
It does not fix all issues, such as those with -fsanitize-coverage=stack-depth, which is not usable on Windows as of this patch.
It also does not fix any libFuzzer integration tests. Nearly all of them fail to compile, fixing them will come in a later patch, so libFuzzer tests are disabled on Windows until them.

Patch By: metzman

Reviewers: morehouse, rnk

Reviewed By: morehouse, rnk

Subscribers: #sanitizers, delcypher, morehouse, kcc, eraman

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341082 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[WebAssembly] Made disassembler only use stack instructions.
Wouter van Oortmerssen [Thu, 30 Aug 2018 15:40:53 +0000 (15:40 +0000)]
[WebAssembly] Made disassembler only use stack instructions.

Summary:
Now uses the StackBased bit from the tablegen defs to identify
stack instructions (and ignore register based or non-wasm instructions).

Also changed how we store operands, since we now have up to 16 of them
per instruction. To not cause static data bloat, these are compressed
into a tiny table.

+ a few other cleanups.

Tested:
- MCTest
- llvm-lit -v `find test -name WebAssembly`

Reviewers: dschuff, jgravelle-google, sunfish, tlively

Subscribers: sbc100, aheejin, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341081 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMove test/Analysis/DivergenceAnalysis/AMDGPU/loads.ll
Nicolai Haehnle [Thu, 30 Aug 2018 15:24:00 +0000 (15:24 +0000)]
Move test/Analysis/DivergenceAnalysis/AMDGPU/loads.ll

Should fix failures of buildbots that don't build the AMDGPU backend.

Change-Id: I01cb84b4b47803b10c5b21ea0353546239860a51

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341079 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[IR] add shuffle queries for identity extend/extract
Sanjay Patel [Thu, 30 Aug 2018 15:05:38 +0000 (15:05 +0000)]
[IR] add shuffle queries for identity extend/extract

This was one of the potential follow-ups suggested in D48236,
and these will be used to make matching the patterns in PR38691 cleaner:
https://bugs.llvm.org/show_bug.cgi?id=38691

About the vocabulary: in the DAG, these would be concat_vector with an
undef operand or extract_subvector. Alternate names are discussed in the
review, but I think these are familiar/good enough to proceed. Once we
have uses of them in code, we might adjust if there are better options.

https://reviews.llvm.org/D51392

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341075 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMake TargetInstrInfo::isCopyInstr return true for regular COPY-instructions
Alexander Ivchenko [Thu, 30 Aug 2018 14:32:47 +0000 (14:32 +0000)]
Make TargetInstrInfo::isCopyInstr return true for regular COPY-instructions

..Move all target-dependent checks into new isCopyInstrImpl method.

This change allows us to treat MoveReg-type instructions and generic
COPY instruction in the same way

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341072 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Rename the DivergenceAnalysis to LegacyDivergenceAnalysis
Nicolai Haehnle [Thu, 30 Aug 2018 14:21:36 +0000 (14:21 +0000)]
[NFC] Rename the DivergenceAnalysis to LegacyDivergenceAnalysis

Summary:
This is patch 1 of the new DivergenceAnalysis (https://reviews.llvm.org/D50433).

The purpose of this patch is to free up the name DivergenceAnalysis for the new generic
implementation. The generic implementation class will be shared by specialized
divergence analysis classes.

Patch by: Simon Moll

Reviewed By: nhaehnle

Subscribers: jvesely, jholewinski, arsenm, nhaehnle, mgorny, jfb, llvm-commits

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

Change-Id: Ie8146b11be2c50d5312f30e11c7a3036a15b48cb

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341071 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMore build fix for r341064.
Alexandre Ganea [Thu, 30 Aug 2018 14:05:49 +0000 (14:05 +0000)]
More build fix for r341064.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341070 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sparc] Use ANDN instead of AND if constant can be encoded more efficiently
Daniel Cederman [Thu, 30 Aug 2018 14:05:26 +0000 (14:05 +0000)]
[Sparc] Use ANDN instead of AND if constant can be encoded more efficiently

Summary:
In the case of (and reg, constant) or (or reg, constant), it can be
beneficial to use a ANDNrr/ORNrr instruction instead of ANDrr/ORrr,
if the complement of the constant can be encoded using a single SETHI
instruction instead of a SETHI/ORri pair.

If the constant has more than one use, it is probably better to keep it
in its original form.

Reviewers: jyknight, venkatra

Reviewed By: jyknight

Subscribers: fedor.sergeev, jrtc27, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341069 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[AMDGPU] Preliminary patch for divergence driven instruction selection. Operands...
Alexander Timofeev [Thu, 30 Aug 2018 13:55:04 +0000 (13:55 +0000)]
[AMDGPU] Preliminary patch for divergence driven instruction selection. Operands Folding 1.

Reviewers: rampitec

Differential revision: https://reviews/llvm/org/D51316

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341068 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoBuild fix for r341064. Temporarily disable compile-time validation for createFileError().
Alexandre Ganea [Thu, 30 Aug 2018 13:36:07 +0000 (13:36 +0000)]
Build fix for r341064. Temporarily disable compile-time validation for createFileError().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341067 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Error] Add FileError helper; upgrade StringError behavior
Alexandre Ganea [Thu, 30 Aug 2018 13:10:42 +0000 (13:10 +0000)]
[Error] Add FileError helper; upgrade StringError behavior

FileError is meant to encapsulate both an Error and a file name/path. It should be used in cases where an Error occurs deep down the call chain, and we want to return it to the caller along with the file name.

StringError was updated to display the error messages in different ways. These can be:

1. display the error_code message, and convert to the same error_code (ECError behavior)
2. display an arbitrary string, and convert to a provided error_code (current StringError behavior)
3. display both an error_code message and a string, in this order; and convert to the same error_code

These behaviors can be triggered depending on the constructor. The goal is to use StringError as a base class, when a library needs to provide a explicit Error type.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341064 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CodeGen] emit inline asm clobber list warnings for reserved (cont)
Ties Stuij [Thu, 30 Aug 2018 12:52:35 +0000 (12:52 +0000)]
[CodeGen] emit inline asm clobber list warnings for reserved (cont)

Summary:
This is a continuation of https://reviews.llvm.org/D49727
Below the original text, current changes in the comments:

Currently, in line with GCC, when specifying reserved registers like sp or pc on an inline asm() clobber list, we don't always preserve the original value across the statement. And in general, overwriting reserved registers can have surprising results.

For example:

  extern int bar(int[]);

  int foo(int i) {
    int a[i]; // VLA
    asm volatile(
        "mov r7, #1"
      :
      :
      : "r7"
    );

    return 1 + bar(a);
  }

Compiled for thumb, this gives:

  $ clang --target=arm-arm-none-eabi -march=armv7a -c test.c -o - -S -O1 -mthumb
  ...
  foo:
          .fnstart
  @ %bb.0:                                @ %entry
          .save   {r4, r5, r6, r7, lr}
          push    {r4, r5, r6, r7, lr}
          .setfp  r7, sp, #12
          add     r7, sp, #12
          .pad    #4
          sub     sp, #4
          movs    r1, #7
          add.w   r0, r1, r0, lsl #2
          bic     r0, r0, #7
          sub.w   r0, sp, r0
          mov     sp, r0
          @APP
          mov.w   r7, #1
          @NO_APP
          bl      bar
          adds    r0, #1
          sub.w   r4, r7, #12
          mov     sp, r4
          pop     {r4, r5, r6, r7, pc}
  ...

r7 is used as the frame pointer for thumb targets, and this function needs to restore the SP from the FP because of the variable-length stack allocation a. r7 is clobbered by the inline assembly (and r7 is included in the clobber list), but LLVM does not preserve the value of the frame pointer across the assembly block.

This type of behavior is similar to GCC's and has been discussed on the bugtracker: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11807 . No consensus seemed to have been reached on the way forward. Clang behavior has briefly been discussed on the CFE mailing (starting here: http://lists.llvm.org/pipermail/cfe-dev/2018-July/058392.html). I've opted for following Eli Friedman's advice to print warnings when there are reserved registers on the clobber list so as not to diverge from GCC behavior for now.

The patch uses MachineRegisterInfo's target-specific knowledge of reserved registers, just before we convert the inline asm string in the AsmPrinter.

If we find a reserved register, we print a warning:

  repro.c:6:7: warning: inline asm clobber list contains reserved registers: R7 [-Winline-asm]
        "mov r7, #1"
        ^

Reviewers: efriedma, olista01, javed.absar

Reviewed By: efriedma

Subscribers: eraman, kristof.beyls, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341062 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[AArch64] Optimise load(adr address) to ldr address
David Green [Thu, 30 Aug 2018 11:55:16 +0000 (11:55 +0000)]
[AArch64] Optimise load(adr address) to ldr address

Providing that the load is known to be 4 byte aligned, we can optimise a
ldr(adr address) to just ldr address.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341058 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[llvm-mca] correctly initialize field 'CycleRetired' in the TimelineView.
Andrea Di Biagio [Thu, 30 Aug 2018 11:17:58 +0000 (11:17 +0000)]
[llvm-mca] correctly initialize field 'CycleRetired' in the TimelineView.

This fixes a [-Wmissing-field-initializers] warning reported by buildbot
lld-x86_64-darwin13, build #25152.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341056 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[llvm-mca] Report the number of dispatched micro opcodes in the DispatchStatistics...
Andrea Di Biagio [Thu, 30 Aug 2018 10:50:20 +0000 (10:50 +0000)]
[llvm-mca] Report the number of dispatched micro opcodes in the DispatchStatistics view.

This patch introduces the following changes to the DispatchStatistics view:
 * DispatchStatistics now reports the number of dispatched opcodes instead of
   the number of dispatched instructions.
 * The "Dynamic Dispatch Stall Cycles" table now also reports the percentage of
   stall cycles against the total simulated cycles.

This change allows users to easily compare dispatch group sizes with the
processor DispatchWidth.
Before this change, it was difficult to correlate the two numbers, since
DispatchStatistics view reported numbers of instructions (instead of opcodes).
DispatchWidth defines the maximum size of a dispatch group in terms of number of
micro opcodes.

The other change introduced by this patch is related to how DispatchStage
generates "instruction dispatch" events.
In particular:
 * There can be multiple dispatch events associated with a same instruction
 * Each dispatch event now encapsulates the number of dispatched micro opcodes.

The number of micro opcodes declared by an instruction may exceed the processor
DispatchWidth. Therefore, we cannot assume that instructions are always fully
dispatched in a single cycle.
DispatchStage knows already how to handle instructions declaring a number of
opcodes bigger that DispatchWidth. However, DispatchStage always emitted a
single instruction dispatch event (during the first simulated dispatch cycle)
for instructions dispatched.

With this patch, DispatchStage now correctly notifies multiple dispatch events
for instructions that cannot be dispatched in a single cycle.

A few views had to be modified. Views can no longer assume that there can only
be one dispatch event per instruction.

Tests (and docs) have been updated.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341055 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Whitespace fix
Max Kazantsev [Thu, 30 Aug 2018 10:42:08 +0000 (10:42 +0000)]
[NFC] Whitespace fix

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341054 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[RISCV] Fix r341050
Alex Bradbury [Thu, 30 Aug 2018 10:39:30 +0000 (10:39 +0000)]
[RISCV] Fix r341050

A few stray lines were accidentally committed. Remove these.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341053 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix "Q" and "R" inline assembly template modifiers for big-endian Arm
Florian Hahn [Thu, 30 Aug 2018 10:28:23 +0000 (10:28 +0000)]
Fix "Q" and "R" inline assembly template modifiers for big-endian Arm

Consider the endianness of the target when printing register names.  This is in line with the documentation at http://llvm.org/docs/LangRef.html#asm-template-argument-modifiers

Patch by Jackson Woodruff <jackson.woodruff@arm.com>

Reviewers: t.p.northover, echristo, javed.absar, efriedma

Reviewed By: efriedma

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341052 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Add severe validation of InstructionPrecedenceTracking
Max Kazantsev [Thu, 30 Aug 2018 10:26:06 +0000 (10:26 +0000)]
[NFC] Add severe validation of InstructionPrecedenceTracking

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341051 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[RISCV][NFC] Rework CHECK lines in rvi-aliases-valid.s
Alex Bradbury [Thu, 30 Aug 2018 10:25:27 +0000 (10:25 +0000)]
[RISCV][NFC] Rework CHECK lines in rvi-aliases-valid.s

Previously CHECK prefixes weren't defined that can be used to check _only_ the
InstPrinter output when generating .s from llvm-mc, or that check _only_ the
output after passing the generated object through objdump. This means we can't
write useful checks for instructions that reference symbols.

Instead, use:
CHECK-S                 Match the .s output with aliases enabled
CHECK-S-NOALIAS         Match the .s output with aliases disabled
CHECK-OBJ               Match the objdumped object output with aliases enabled
CHECK-OBJ-NOALIAS       Match the objdumped object output with aliases enabled
CHECK-S-OBJ             Match both the .s and objdumped object output with
                        aliases enabled
CHECK-S-OBJ-NOALIAS     Match both the .s and objdumped object output with
                        aliases disabled

While we're at it, use whitespace consistently within this file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341050 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "[Hexagon][Test] Remove undef and infinite loop from test"
Roman Lebedev [Thu, 30 Aug 2018 10:01:03 +0000 (10:01 +0000)]
Revert "[Hexagon][Test] Remove undef and infinite loop from test"

Bots are unhappy:

/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm/test/CodeGen/Hexagon/swp-const-tc2.ll:10:14: error: CHECK-NOT: excluded string found in input
; CHECK-NOT: = mpy
             ^
<stdin>:22:6: note: found here
 r5 += mpyi(r2,r3)
     ^~~~~

This reverts commit r341046.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341049 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC][CodeGen][SelectionDAG] Tests for X % C == 0 codegen improvement.
Roman Lebedev [Thu, 30 Aug 2018 09:32:21 +0000 (09:32 +0000)]
[NFC][CodeGen][SelectionDAG] Tests for X % C == 0 codegen improvement.

Hacker's Delight 10-17: when C is constant,
the result of X % C == 0 can be computed more cheaply
without actually calculating the remainder.

The motivation is discussed here:
https://bugs.llvm.org/show_bug.cgi?id=35479.

Patch by: hermord (Dmytro Shynkevych)!

For https://reviews.llvm.org/D50222

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341047 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Hexagon][Test] Remove undef and infinite loop from test
Roman Lebedev [Thu, 30 Aug 2018 09:32:15 +0000 (09:32 +0000)]
[Hexagon][Test] Remove undef and infinite loop from test

Summary:
As suggested in D50222, this has been refactored into a separate patch.

The undef and the infinite loop at the end cause this test to be translated
unpredictably. In particular, the checked-for `mpy` disappears under
certain legal optimizations (e.g. the one in D50222).
Since the use of these constructs is not relevant to the behavior tested,
according to the header comment, this change, suggested by @kparzysz,
eliminates them.

Patch by: hermord (Dmytro Shynkevych)!

Reviewers: kparzysz

Reviewed By: kparzysz

Subscribers: llvm-commits, kparzysz

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341046 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "[CMake] Use LLVM_ENABLE_IDE instead of CMAKE_CONFIGURATION_TYPES"
Roman Lebedev [Thu, 30 Aug 2018 09:32:09 +0000 (09:32 +0000)]
Revert "[CMake] Use LLVM_ENABLE_IDE instead of CMAKE_CONFIGURATION_TYPES"

That resulted in the check-llvm-* targets not being avaliable
in the QtCreator-configured build directories.

Moreover, that was a clearly non-NFC change, and i can't find any review
for it.

This reverts commit rL340435.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341045 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Rename map to make the naming consistent
Max Kazantsev [Thu, 30 Aug 2018 09:24:33 +0000 (09:24 +0000)]
[NFC] Rename map to make the naming consistent

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341043 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[XRay] Help gcc disambiguate names
Dean Michael Berris [Thu, 30 Aug 2018 09:04:12 +0000 (09:04 +0000)]
[XRay] Help gcc disambiguate names

Follow-up to D51210.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341042 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[XRay] Move out template and use perfect forwarding
Dean Michael Berris [Thu, 30 Aug 2018 08:15:42 +0000 (08:15 +0000)]
[XRay] Move out template and use perfect forwarding

Follow up to D51210.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341032 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "[SimplifyCFG] Common debug handling [NFC]"
Martin Storsjo [Thu, 30 Aug 2018 08:06:50 +0000 (08:06 +0000)]
Revert "[SimplifyCFG] Common debug handling [NFC]"

This reverts commit r340997.

This change turned out not to be NFC after all, but e.g. causes
clang to crash when building the linux kernel for aarch64.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341031 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[XRay] Remove attribute packed
Dean Michael Berris [Thu, 30 Aug 2018 07:57:32 +0000 (07:57 +0000)]
[XRay] Remove attribute packed

Followup to D51210.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341030 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[XRay] FDRTraceWriter and FDR Trace Loading
Dean Michael Berris [Thu, 30 Aug 2018 07:22:21 +0000 (07:22 +0000)]
[XRay] FDRTraceWriter and FDR Trace Loading

Summary:
This is the first step in the larger refactoring and reduction of
D50441.

This step in the process does the following:

- Introduces more granular types of `Record`s representing the many
  kinds of records written/read by the Flight Data Recorder (FDR) mode
  `Trace` loading function(s).

- Introduces an abstract `RecordVisitor` type meant to handle the
  processing of the various `Record` derived types. This `RecordVisitor`
  has two implementations in this patch: `RecordInitializer` and
  `FDRTraceWriter`.

- We also introduce a convenience interface for building a collection of
  `Record` instances called a `LogBuilder`. This allows us to generate
  sequences of `Record` instances manually (used in unit tests but
  useful otherwise).

- The`FDRTraceWriter` class implements the `RecordVisitor` interface and
  handles the writing of metadata records to a `raw_ostream`. We
  demonstrate that in the unit test, we can generate in-memory FDR mode
  traces using the specific `Record` derived types, which we load
  through the `loadTrace(...)` function yielding valid `Trace` objects.

This patch introduces the required types and concepts for us to start
replacing the logic implemented in the `loadFDRLog` function to use the
more granular types. In subsequent patches, we will introduce more
visitor implementations which isolate the verification, printing,
indexing, production/consumption, and finally the conversion of the FDR
mode logs.

The overarching goal of these changes is to make handling FDR mode logs
better tested, more understandable, more extensible, and more
systematic. This will also allow us to better represent the execution
trace, as we improve the fidelity of the events we represent in an XRay
`Trace` object, which we intend to do after FDR mode log processing is
in better shape.

Reviewers: eizan

Reviewed By: eizan

Subscribers: mgorny, hiraditya, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341029 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoDon't count debug instructions towards neighborhood count
Matt Arsenault [Thu, 30 Aug 2018 07:18:19 +0000 (07:18 +0000)]
Don't count debug instructions towards neighborhood count

In computeRegisterLiveness, the max instructions to search
was counting dbg_value instructions, which could potentially
cause an observable codegen change from the presence of debug
info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341028 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoCodeGen: Make computeRegisterLiveness search forward first
Matt Arsenault [Thu, 30 Aug 2018 07:18:10 +0000 (07:18 +0000)]
CodeGen: Make computeRegisterLiveness search forward first

If there is an unused def, this would previously
report that the register was live. Check for uses
first so that it is reported as dead if never used.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341027 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoCodeGen: Make computeRegisterLiveness consider successors
Matt Arsenault [Thu, 30 Aug 2018 07:17:51 +0000 (07:17 +0000)]
CodeGen: Make computeRegisterLiveness consider successors

If the end of the block is reached during the scan, check
the live ins of the successors. This was already done in the
other direction if the block entry was reached.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341026 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[DWARF] Missing location debug information with -O2.
Carlos Alberto Enciso [Thu, 30 Aug 2018 07:17:41 +0000 (07:17 +0000)]
[DWARF] Missing location debug information with -O2.

Check that Machine CSE correctly handles during the transformation, the
debug location information for local variables.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341025 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Improved sched model for X86 CMPXCHG* instructions.
Andrew V. Tischenko [Thu, 30 Aug 2018 06:26:00 +0000 (06:26 +0000)]
[X86] Improved sched model for X86 CMPXCHG* instructions.
Differential Revision: https://reviews.llvm.org/D50070

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341024 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[InstCombine] Add test cases for D51398
Craig Topper [Thu, 30 Aug 2018 06:14:54 +0000 (06:14 +0000)]
[InstCombine] Add test cases for D51398

These tests contain the pattern (neg (max ~X, C)) which we should transform to ((min X, ~C) + 1)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341023 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Make Feature64Bit useful
Craig Topper [Thu, 30 Aug 2018 06:01:05 +0000 (06:01 +0000)]
[X86] Make Feature64Bit useful

We now only add +64bit to the CPU string for "generic" CPU. All other CPU names are assumed to have the feature flag already set if they support 64-bit. I've remove the implies from CMPXCHG8 so that Feature64Bit only comes in via CPUs or user passing -mattr=+64bit.

I've changed the assert to a report_fatal_error so it's not lost in Release builds.

The test updates are to fix things that tripped the new error.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341022 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Update test command line to not use 64-bit mode on a 32-bit only athlon cpu.
Craig Topper [Thu, 30 Aug 2018 06:01:03 +0000 (06:01 +0000)]
[X86] Update test command line to not use 64-bit mode on a 32-bit only athlon cpu.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341021 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Remove powerpc cpu name and features from uwtables.ll
Craig Topper [Thu, 30 Aug 2018 06:01:01 +0000 (06:01 +0000)]
[X86] Remove powerpc cpu name and features from uwtables.ll

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341020 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoDAG: Don't use ABI copies in some contexts
Matt Arsenault [Thu, 30 Aug 2018 05:49:28 +0000 (05:49 +0000)]
DAG: Don't use ABI copies in some contexts

If an ABI-like value is used in a different block,
the type split used is not necessarily the same as
the call's ABI. The value is used through an intermediate
copy virtual registers from the other block. This
resulted in copies with inconsistent sizes later.

Fixes regressions since r338197 when AMDGPU started
splitting vector types for calls.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341018 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Move OrderedInstructions and InstructionPrecedenceTracking to Analysis
Max Kazantsev [Thu, 30 Aug 2018 04:49:03 +0000 (04:49 +0000)]
[NFC] Move OrderedInstructions and InstructionPrecedenceTracking to Analysis

These classes don't make any changes to IR and have no reason to be in
Transform/Utils. This patch moves them to Analysis folder. This will allow
us reusing these classes in some analyzes, like MustExecute.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341015 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRe-enable "[NFC] Unify guards detection"
Max Kazantsev [Thu, 30 Aug 2018 03:39:16 +0000 (03:39 +0000)]
Re-enable "[NFC] Unify guards detection"

rL340921 has been reverted by rL340923 due to linkage dependency
from Transform/Utils to Analysis which is not allowed. In this patch
this has been fixed, a new utility function moved to Analysis.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341014 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[XRay][llvm] Load XRay Profiles
Dean Michael Berris [Thu, 30 Aug 2018 01:43:22 +0000 (01:43 +0000)]
[XRay][llvm] Load XRay Profiles

Summary:
This change implements the profile loading functionality in LLVM to
support XRay's profiling mode in compiler-rt.

We introduce a type named `llvm::xray::Profile` which allows building a
profile representation. We can load an XRay profile from a file to build
Profile instances, or do it manually through the Profile type's API.

The intent is to get the `llvm-xray` tool to generate `Profile`
instances and use that as the common abstraction through which all
conversion and analysis can be done. In the future we can generate
`Profile` instances from `Trace` instances as well, through conversion
functions.

Some of the key operations supported by the `Profile` API are:

- Path interning (`Profile::internPath(...)`) which returns a unique path
  identifier.

- Block appending (`Profile::addBlock(...)`) to add thread-associated
  profile information.

- Path ID to Path lookup (`Profile::expandPath(...)`) to look up a
  PathID and return the original interned path.

- Block iteration.

A 'Path' in this context represents the function call stack in
leaf-to-root order. This is represented as a path in an internally
managed prefix tree in the `Profile` instance. Having a handle (PathID)
to identify the unique Paths we encounter for a particular Profile
allows us to reduce the amount of memory required to associate profile
data to a particular Path.

This is the first of a series of patches to migrate the `llvm-stacks`
tool towards using a single profile representation.

Depends on D48653.

Reviewers: kpw, eizan

Reviewed By: kpw

Subscribers: kpw, thakis, mgorny, llvm-commits, hiraditya

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341012 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[WebAssembly] Be a little more conservative in WebAssemblyFixFunctionBitcasts
Sam Clegg [Thu, 30 Aug 2018 01:01:30 +0000 (01:01 +0000)]
[WebAssembly] Be a little more conservative in WebAssemblyFixFunctionBitcasts

We don't have enough information to know if struct types being
bitcast will cause validation failures or not, so be conservative
and allow such cases to persist (fot now).

Fixes: https://bugs.llvm.org/show_bug.cgi?id=38711

Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341010 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[GlobalMerge] Fix GlobalMerge on bss external global variables.
Huihui Zhang [Thu, 30 Aug 2018 00:49:50 +0000 (00:49 +0000)]
[GlobalMerge] Fix GlobalMerge on bss external global variables.

Summary:
Global variables that are external and zero initialized are
supposed to be merged with global variables in the bss section
rather than the data section.

Reviewers: efriedma, rengolin, t.p.northover, javed.absar, asl, john.brawn, pcc

Reviewed By: efriedma

Subscribers: dmgreen, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341008 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[SimplifyCFG] Rename a variable for readibility of a future change [NFC]
Philip Reames [Thu, 30 Aug 2018 00:12:29 +0000 (00:12 +0000)]
[SimplifyCFG] Rename a variable for readibility of a future change [NFC]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341004 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[SimplifyCFG] Fix a cost modeling oversight in branch commoning
Philip Reames [Thu, 30 Aug 2018 00:03:02 +0000 (00:03 +0000)]
[SimplifyCFG] Fix a cost modeling oversight in branch commoning

The cost modeling was not accounting for the fact we were duplicating the instruction once per predecessor.  With a default threshold of 1, this meant we were actually creating #pred copies.

Adding to the fun, there is *absolutely no* test coverage for this.  Simply bailing for more than one predecessor passes all checked in tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341001 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[MS Demangler] Fix several crashes and demangling bugs.
Zachary Turner [Wed, 29 Aug 2018 23:56:09 +0000 (23:56 +0000)]
[MS Demangler] Fix several crashes and demangling bugs.

These bugs were found by writing a Python script which spidered
the entire Chromium build directory tree demangling every symbol
in every object file.  At the start, the tool printed:

  Processed 27443 object files.
  2926377/2936108 symbols successfully demangled (99.6686%)
  9731 symbols could not be demangled (0.3314%)
  14589 files crashed while demangling (53.1611%)

After this patch, it prints:

  Processed 27443 object files.
  41295518/41295617 symbols successfully demangled (99.9998%)
  99 symbols could not be demangled (0.0002%)
  0 files crashed while demangling (0.0000%)

The issues fixed in this patch are:

  * Ignore empty parameter packs.  Previously we would encounter
    a mangling for an empty parameter pack and add a null node
    to the AST.  Since we don't print these anyway, we now just
    don't add anything to the AST and ignore it entirely.  This
    fixes some of the crashes.

  * Account for "incorrect" string literal demanglings.  Apparently
    an older version of clang would not truncate mangled string
    literals to 32 bytes of encoded character data.  The demangling
    code however would allocate a 32 byte buffer thinking that it
    would not encounter more than this, and overrun the buffer.
    We now demangle up to 128 bytes of data, since the buggy
    clang would encode up to 32 *characters* of data.

  * Extended support for demangling init-fini stubs.  If you had
    something like
      struct Foo {
        static vector<string> S;
      };
    this would generate a dynamic atexit initializer *for the
    variable*.  We didn't handle this, but now we print something
    nice.  This is actually an improvement over undname, which will
    fail to demangle this at all.

  * Fixed one case of static this adjustment.  We weren't handling
    several thunk codes so we didn't recognize the mangling.  These
    are now handled.

  * Fixed a back-referencing problem.  Member pointer templates
    should have their components considered for back-referencing

The remaining 99 symbols which can't be demangled are all symbols
which are compiler-generated and undname can't demangle either.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341000 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Make getPreferredAlignment honor section markings.
Eli Friedman [Wed, 29 Aug 2018 23:46:26 +0000 (23:46 +0000)]
[NFC] Make getPreferredAlignment honor section markings.

This should more accurately reflect what the AsmPrinter will actually
do.

This is NFC, as far as I can tell; all the places that might be affected
already have an extra check to avoid using the result of
getPreferredAlignment in this situation.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340999 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[SimplifyCFG] Common debug handling [NFC]
Philip Reames [Wed, 29 Aug 2018 23:22:07 +0000 (23:22 +0000)]
[SimplifyCFG] Common debug handling [NFC]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340997 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[llvm-strip] Fix -p|--preserve-dates to not truncate output when used in-place.
Jordan Rupprecht [Wed, 29 Aug 2018 23:21:56 +0000 (23:21 +0000)]
[llvm-strip] Fix -p|--preserve-dates to not truncate output when used in-place.

The restoreDateOnFile() method used to preserve dates uses sys::fs::openFileForWrite(). That method defaults to opening files with CD_CreateAlways, which truncates the output file if it exists. Use CD_OpenExisting instead to open it and *not* truncate it, which also has the side benefit of erroring if the file does not exist (it should always exist, because we just wrote it out).

Also, fix the test case to make sure the output is a valid output file, and not empty. The extra test assertions are enough to catch this regression.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340996 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[MemorySSA] Silence warning.
Alina Sbirlea [Wed, 29 Aug 2018 23:20:29 +0000 (23:20 +0000)]
[MemorySSA] Silence warning.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340995 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoReverse subregister saved loops in register usage info collector; NFC
Matthias Braun [Wed, 29 Aug 2018 23:12:42 +0000 (23:12 +0000)]
Reverse subregister saved loops in register usage info collector; NFC

On AMDGPU we have 70 register classes, so iterating over all 70
each time and exiting is costly on the CPU, this flips the loop
around so that it loops over the 70 register classes first,
and exits without doing the inner loop if needed.

On my test just starting radv this takes
RegUsageInfoCollector::runOnMachineFunction
from 6.0% of total time to 2.7% of total time,
and reduces the startup from 2.24s to 2.19s

Patch by David Airlie!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340993 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert r340947 "[InstCombine] Expand the simplification of pow() into exp2()"
Reid Kleckner [Wed, 29 Aug 2018 22:58:33 +0000 (22:58 +0000)]
Revert r340947 "[InstCombine] Expand the simplification of pow() into exp2()"

It broke the clang-cl self-host.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340991 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[MemorySSA] Fix checkClobberSanity to skip Start only for Defs and Uses.
Alina Sbirlea [Wed, 29 Aug 2018 22:38:51 +0000 (22:38 +0000)]
[MemorySSA] Fix checkClobberSanity to skip Start only for Defs and Uses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340981 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd a todo and tests to Address a review commnt from D50925 [NFC]
Philip Reames [Wed, 29 Aug 2018 22:09:21 +0000 (22:09 +0000)]
Add a todo and tests to Address a review commnt from D50925 [NFC]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340978 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[LICM] Hoist stores of invariant values to invariant addresses out of loops
Philip Reames [Wed, 29 Aug 2018 21:49:30 +0000 (21:49 +0000)]
[LICM] Hoist stores of invariant values to invariant addresses out of loops

Teach LICM to hoist stores out of loops when the store writes to a location otherwise unused in the loop, writes a value which is invariant, and is guaranteed to execute if the loop is entered.

Worth noting is that this transformation is partially overlapping with the existing promotion transformation. Reasons this is worthwhile anyway include:
 * For multi-exit loops, this doesn't require duplication of the store.
 * It kicks in for case where we can't prove we exit through a normal exit (i.e. we may throw), but can prove the store executes before that possible side exit.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340974 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAMDGPU: Handle 32-bit address wraparounds for SMRD opcodes
Marek Olsak [Wed, 29 Aug 2018 20:03:00 +0000 (20:03 +0000)]
AMDGPU: Handle 32-bit address wraparounds for SMRD opcodes

Summary: This fixes GPU hangs with OpenGL bindless handle arithmetic.

Reviewers: arsenm, nhaehnle

Subscribers: kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340959 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[SimpleLoopUnswitch] After unswitch delete dead blocks in parent loops
Fedor Sergeev [Wed, 29 Aug 2018 19:10:44 +0000 (19:10 +0000)]
[SimpleLoopUnswitch] After unswitch delete dead blocks in parent loops

Summary:
Assert from PR38737 happens on the dead block inside the parent loop
after unswitching nontrivial switch in the inner loop.

deleteDeadBlocksFromLoop now takes extra care to detect/remove dead
blocks in all the parent loops in addition to the blocks from original
loop being unswitched.

Reviewers: asbirlea, chandlerc

Reviewed By: asbirlea

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340955 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "[libFuzzer] Port to Windows"
Matt Morehouse [Wed, 29 Aug 2018 18:40:41 +0000 (18:40 +0000)]
Revert "[libFuzzer] Port to Windows"

This reverts r340949 due to bot breakage again.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340954 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[InstCombine] canonicalize fneg with llvm.sin
Sanjay Patel [Wed, 29 Aug 2018 18:27:49 +0000 (18:27 +0000)]
[InstCombine] canonicalize fneg with llvm.sin

This is a follow-up to rL339604 which did the same transform
for a sin libcall. The handling of intrinsics vs. libcalls
is unfortunately scattered, so I'm just adding this next to
the existing transform for llvm.cos for now.

This should resolve PR38458:
https://bugs.llvm.org/show_bug.cgi?id=38458
If the call was already negated, the negates will cancel
each other out.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340952 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[MemorySSA] Add expesive check for validating clobber accesses.
Alina Sbirlea [Wed, 29 Aug 2018 18:26:04 +0000 (18:26 +0000)]
[MemorySSA] Add expesive check for validating clobber accesses.

Summary: Add validation of clobber accesses as expensive check.

Reviewers: george.burgess.iv

Subscribers: sanjoy, jlebar, Prazek, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340951 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[InstCombine] add tests for llvm.sin(-x); NFC
Sanjay Patel [Wed, 29 Aug 2018 18:11:42 +0000 (18:11 +0000)]
[InstCombine] add tests for llvm.sin(-x); NFC

Also add a corresponding test for llvm.cos with FMF to
make sure that was handled correctly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340950 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[libFuzzer] Port to Windows
Matt Morehouse [Wed, 29 Aug 2018 18:08:34 +0000 (18:08 +0000)]
[libFuzzer] Port to Windows

Summary:
Port libFuzzer to windows-msvc.
This patch allows libFuzzer targets to be built and run on Windows, using -fsanitize=fuzzer and/or fsanitize=fuzzer-no-link. It allows these forms of coverage instrumentation to work on Windows as well.
It does not fix all issues, such as those with -fsanitize-coverage=stack-depth, which is not usable on Windows as of this patch.
It also does not fix any libFuzzer integration tests. Nearly all of them fail to compile, fixing them will come in a later patch, so libFuzzer tests are disabled on Windows until them.

Reviewers: morehouse, rnk

Reviewed By: morehouse, rnk

Subscribers: #sanitizers, delcypher, morehouse, kcc, eraman

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340949 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[InstCombine] Expand the simplification of pow() with nested exp{,2}()
Evandro Menezes [Wed, 29 Aug 2018 17:59:48 +0000 (17:59 +0000)]
[InstCombine] Expand the simplification of pow() with nested exp{,2}()

Expand the simplification of `pow(exp{,2}(x), y)` to all FP types.

This improvement helps some benchmarks in SPEC CPU2000 and CPU2006, such as
252.eon, 447.dealII, 453.povray.  Otherwise, no significant regressions on
x86-64 or A64.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340948 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[InstCombine] Expand the simplification of pow() into exp2()
Evandro Menezes [Wed, 29 Aug 2018 17:59:34 +0000 (17:59 +0000)]
[InstCombine] Expand the simplification of pow() into exp2()

Generalize the simplification of `pow(2.0, y)` to `pow(2.0 ** n, y)` for all
scalar and vector types.

This improvement helps some benchmarks in SPEC CPU2000 and CPU2006, such as
252.eon, 447.dealII, 453.povray.  Otherwise, no significant regressions on
x86-64 or A64.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340947 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[llvm-mca] Add fields "Total uOps" and "uOps Per Cycle" to the report generated by...
Andrea Di Biagio [Wed, 29 Aug 2018 17:56:39 +0000 (17:56 +0000)]
[llvm-mca] Add fields "Total uOps" and "uOps Per Cycle" to the report generated by the SummaryView.

This patch adds two new fields to the perf report generated by the SummaryView.
Fields are now logically organized into two small groups; only the second group
contains throughput indicators.

Example:
```
Iterations:        100
Instructions:      300
Total Cycles:      414
Total uOps:        700

Dispatch Width:    4
uOps Per Cycle:    1.69
IPC:               0.72
Block RThroughput: 4.0
```

This patch also updates the docs for llvm-mca.
Due to the nature of this change, several tests in the tools/llvm-mca directory
were affected, and had to be updated using script `update_mca_test_checks.py`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340946 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[llvm-mca] Don't disable the SummaryView if flag `-all-stats` is false.
Andrea Di Biagio [Wed, 29 Aug 2018 17:40:04 +0000 (17:40 +0000)]
[llvm-mca] Don't disable the SummaryView if flag `-all-stats` is false.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340945 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[MinGW] [X86] Add stubs for references to data variables that might end up imported...
Martin Storsjo [Wed, 29 Aug 2018 17:28:34 +0000 (17:28 +0000)]
[MinGW] [X86] Add stubs for references to data variables that might end up imported from a dll

Variables declared with the dllimport attribute are accessed via a
stub variable named __imp_<var>. In MinGW configurations, variables that
aren't declared with a dllimport attribute might still end up imported
from another DLL with runtime pseudo relocs.

For x86_64, this avoids the risk that the target is out of range
for a 32 bit PC relative reference, in case the target DLL is loaded
further than 4 GB from the reference. It also avoids having to make the
text section writable at runtime when doing the runtime fixups, which
makes it worthwhile to do for i386 as well.

Add stub variables for all dso local data references where a definition
of the variable isn't visible within the module, since the DLL data
autoimporting might make them imported even though they are marked as
dso local within LLVM.

Don't do this for variables that actually are defined within the same
module, since we then know for sure that it actually is dso local.

Don't do this for references to functions, since there's no need for
runtime pseudo relocations for autoimporting them; if a function from
a different DLL is called without the appropriate dllimport attribute,
the call just gets routed via a thunk instead.

GCC does something similar since 4.9 (when compiling with -mcmodel=medium
or large; from that version, medium is the default code model for x86_64
mingw), but only for x86_64.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340942 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[InstCombine] Replace two calls to getNumUses() with !hasNUsesOrMore
Craig Topper [Wed, 29 Aug 2018 17:09:21 +0000 (17:09 +0000)]
[InstCombine] Replace two calls to getNumUses() with !hasNUsesOrMore

We were calling getNumUses to check for 1 or 2 uses. But getNumUses is linear in the number of uses. We can instead use !hasNUsesOrMore(3) which will stop the linear scan as soon as it determines there are at least 3 uses even if there are more.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340939 91177308-0d34-0410-b5e6-96231b3b80d8