platform/upstream/llvm.git
7 years ago[change-namespace] avoid adding leading '::' when possible.
Eric Liu [Tue, 21 Mar 2017 12:41:59 +0000 (12:41 +0000)]
[change-namespace] avoid adding leading '::' when possible.

Summary:
When changing namespaces, the tool adds leading "::" to references that need to
be fully-qualified, which would affect readability.

We avoid adding "::" when the symbol name does not conflict with the new
namespace name. For example, a symbol name "na::nb::X" conflicts with "ns::na"
since it would be resolved to "ns::na::nb::X" in the new namespace.

Reviewers: hokein

Reviewed By: hokein

Subscribers: cfe-commits

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

llvm-svn: 298363

7 years agoStride in distribute parallel for loops with no chunk size.
Andrey Churbanov [Tue, 21 Mar 2017 12:17:22 +0000 (12:17 +0000)]
Stride in distribute parallel for loops with no chunk size.

Patch by George Rokos.

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

llvm-svn: 298362

7 years ago[DependenceInfo] change name Write to MustWrite to remove ambiguity [NFC]
Siddharth Bhat [Tue, 21 Mar 2017 11:54:08 +0000 (11:54 +0000)]
[DependenceInfo] change name Write to MustWrite to remove ambiguity [NFC]

"Write" is an overloaded term. In collectInfo() till buildFlow(), it is
used to mean "must writes". However, within the memory based analysis,
it is used to mean "both may and must writes". Renaming the Write
variable helps clarify this difference.

Reviewers: grosser

Tags: #polly

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

llvm-svn: 298361

7 years ago[DebugInfo][X86] Teach Optimize LEAs pass to handle debug values
Andrea Di Biagio [Tue, 21 Mar 2017 11:36:21 +0000 (11:36 +0000)]
[DebugInfo][X86] Teach Optimize LEAs pass to handle debug values

This patch fixes an issue in the Optimize LEAs pass where redundant LEAs were
not removed because they were being used by debug values. The debug values are
now ignored when determining whether LEAs are redundant.

For now the debug values for the redundant LEAs are marked as undefined,
effectively lost. The intention is for a follow up patch which will attempt to
preserve the debug values where possible.

Patch by Andrew Ng.

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

llvm-svn: 298360

7 years agoNFC. InstCombiner::visitFAdd extract LHSIntVal/RHSIntVal local variables
Artur Pilipenko [Tue, 21 Mar 2017 11:32:15 +0000 (11:32 +0000)]
NFC. InstCombiner::visitFAdd extract LHSIntVal/RHSIntVal local variables

llvm-svn: 298359

7 years ago[GlobalISel] Move isTriviallyDead to Utils. NFC.
Volkan Keles [Tue, 21 Mar 2017 10:47:35 +0000 (10:47 +0000)]
[GlobalISel] Move isTriviallyDead to Utils. NFC.

Make it accessible by the targets to avoid code duplication.

llvm-svn: 298358

7 years ago[DAGTypeLegalizer] Handle widening truncate to vector of i1.
Jonas Paulsson [Tue, 21 Mar 2017 10:24:14 +0000 (10:24 +0000)]
[DAGTypeLegalizer]  Handle widening truncate to vector of i1.

Previously, PromoteIntRes_TRUNCATE() did not handle the case where
the operand needs widening, which resulted in llvm_unreachable().

This patch adds the needed handling, along with a test case.

Review: Eli Friedman, Simon Pilgrim.
https://reviews.llvm.org/D31077

llvm-svn: 298357

7 years ago[ConstantFolding] Fix to prevent constant folding having to repeatedly scan operands...
David Green [Tue, 21 Mar 2017 10:17:39 +0000 (10:17 +0000)]
[ConstantFolding] Fix to prevent constant folding having to repeatedly scan operands. NFCI

After the loop unroll threshold was increased in r295538, very
large constant expressions can be created. This prevents them
from having to be recursively scanned, leading to a compile
time blow-up.

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

llvm-svn: 298356

7 years ago[scan-build-py] reuse command line output parameter for report directory
Laszlo Nagy [Tue, 21 Mar 2017 10:15:18 +0000 (10:15 +0000)]
[scan-build-py] reuse command line output parameter for report directory

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

llvm-svn: 298355

7 years ago[ELF] - Detemplate InputSection::getRelocatedSection(). NFC.
George Rimar [Tue, 21 Mar 2017 09:13:27 +0000 (09:13 +0000)]
[ELF] - Detemplate InputSection::getRelocatedSection(). NFC.

llvm-svn: 298353

7 years agoUpdate isl to isl-0.18-395-g77701b3
Tobias Grosser [Tue, 21 Mar 2017 09:12:11 +0000 (09:12 +0000)]
Update isl to isl-0.18-395-g77701b3

This is a normal maintenance update.

llvm-svn: 298352

7 years ago[ELF] - Detemplate InputSectionBase::uncompress(). NFC
George Rimar [Tue, 21 Mar 2017 09:08:58 +0000 (09:08 +0000)]
[ELF] - Detemplate InputSectionBase::uncompress(). NFC

llvm-svn: 298351

7 years ago[ELF] - Detemplate ARMExidxSentinelSection. NFC.
George Rimar [Tue, 21 Mar 2017 09:01:39 +0000 (09:01 +0000)]
[ELF] - Detemplate ARMExidxSentinelSection. NFC.

llvm-svn: 298350

7 years ago[ELF] - Fix one more access to Sections member.
George Rimar [Tue, 21 Mar 2017 08:57:13 +0000 (08:57 +0000)]
[ELF] - Fix one more access to Sections member.

That finally should linux BB after r298345.

llvm-svn: 298349

7 years ago[ELF] Follow-up to r298345 "[ELF] - Detemplate GdbIndexSection."
George Rimar [Tue, 21 Mar 2017 08:44:25 +0000 (08:44 +0000)]
[ELF] Follow-up to r298345 "[ELF] - Detemplate GdbIndexSection."

Fix for linux build bot:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/8144/steps/build/logs/stdio

llvm-svn: 298348

7 years ago[GlobalISel] Translate shufflevector
Volkan Keles [Tue, 21 Mar 2017 08:44:13 +0000 (08:44 +0000)]
[GlobalISel] Translate shufflevector

Reviewers: qcolombet, aditya_nandakumar, t.p.northover, javed.absar, ab, dsanders

Reviewed By: javed.absar

Subscribers: dberris, rovka, llvm-commits, kristof.beyls

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

llvm-svn: 298347

7 years ago[ELF] - Detemplate InputSectionBase::getLinkOrderDep(). NFC.
George Rimar [Tue, 21 Mar 2017 08:29:48 +0000 (08:29 +0000)]
[ELF] - Detemplate InputSectionBase::getLinkOrderDep(). NFC.

llvm-svn: 298346

7 years ago[ELF] - Detemplate GdbIndexSection.
George Rimar [Tue, 21 Mar 2017 08:19:34 +0000 (08:19 +0000)]
[ELF] - Detemplate GdbIndexSection.

Patch moves Sections array to
InputFile (root class for input files).

That allows to detemplate GdbIndexSection.

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

llvm-svn: 298345

7 years ago[APFloat] Tag the fltSemantic getter functions with LLVM_READNONE.
Craig Topper [Tue, 21 Mar 2017 07:18:00 +0000 (07:18 +0000)]
[APFloat] Tag the fltSemantic getter functions with LLVM_READNONE.

This gives about an 8k reduction in the size of the opt binary on my local x86-64 build.

llvm-svn: 298344

7 years agoRevert "Bypass potential libc's sysconf wrappers for sysconf(_SC_PAGESIZE) call"
Vitaly Buka [Tue, 21 Mar 2017 06:55:32 +0000 (06:55 +0000)]
Revert "Bypass potential libc's sysconf wrappers for sysconf(_SC_PAGESIZE) call"

Bot can't find <sys/auxv.h>

This reverts commit r298305.

llvm-svn: 298343

7 years ago[APInt] Add LLVM_READONLY to some methods.
Craig Topper [Tue, 21 Mar 2017 06:19:46 +0000 (06:19 +0000)]
[APInt] Add LLVM_READONLY to some methods.

llvm-svn: 298342

7 years ago[SystemZ] Don't drop MO flags in foldMemoryOperandImpl()
Jonas Paulsson [Tue, 21 Mar 2017 05:49:40 +0000 (05:49 +0000)]
[SystemZ]  Don't drop MO flags in foldMemoryOperandImpl()

The def operand of the new LG/LD should have the old def operands
flags and subreg index.

New test: test/CodeGen/SystemZ/fold-memory-op-impl.ll

Review: Ulrich Weigand
llvm-svn: 298341

7 years agoResubmit r298334 after fixing OSX build errors.
Zachary Turner [Tue, 21 Mar 2017 05:47:57 +0000 (05:47 +0000)]
Resubmit r298334 after fixing OSX build errors.

Hopefully this works, I can't test since I don't have Mac
hardware, however.

llvm-svn: 298340

7 years ago[Builtin] Implement lit-test support (part 1 of 2: test cases update)
Weiming Zhao [Tue, 21 Mar 2017 05:32:51 +0000 (05:32 +0000)]
[Builtin] Implement lit-test support (part 1 of 2: test cases update)

Original r297566 is splitted into two parts.
This is part one, which adds "RUN" command for test cases.
Unit/arm/call_apsr.S is updated to support thumb1.
It also fixes a bug in arm/aeabi_uldivmod_test.c
gcc_personality_test is XFAILED as the framework cannot handle it so far.
cpu_model_test is also XFAILED for now as it is expected to return non-zero.

TODO: A few tests are XFAILed for armhf and aarch64.
We need further investigating.  [1,2] Tracks the issue.

[1] https://bugs.llvm.org//show_bug.cgi?id=32260
[2] https://bugs.llvm.org//show_bug.cgi?id=32261

Reviewers: rengolin, compnerd, jroelofs, erik.pilkington, arphaman

Reviewed By: jroelofs

Subscribers: jroelofs, aemerson, srhines, nemanjai, llvm-commits, mgorny

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

llvm-svn: 298339

7 years agoRevert r298334 until Zachary has a chance to fix the buildbot failure
Jason Molenda [Tue, 21 Mar 2017 04:45:10 +0000 (04:45 +0000)]
Revert r298334 until Zachary has a chance to fix the buildbot failure
on macosx.

llvm-svn: 298338

7 years agoFix two places where an arm instruction emulation method
Jason Molenda [Tue, 21 Mar 2017 04:34:17 +0000 (04:34 +0000)]
Fix two places where an arm instruction emulation method
can dereference misaligned memory.
<rdar://problem/31106315>, <rdar://problem/31106337>

llvm-svn: 298337

7 years agoFix evaluation of LLVM_DEFINITIONS
Serge Pavlov [Tue, 21 Mar 2017 04:03:24 +0000 (04:03 +0000)]
Fix evaluation of LLVM_DEFINITIONS

CMake variable LLVM_DEFINITIONS collects preprocessor definitions provided
for host compiler that builds llvm components. A function
add_llvm_definitions was introduced in AddLLVMDefinitions.cmake to keep
track of these definitions and was intended to be a replacement for CMake
command add_definitions. Actually in many cases add_definitions is still
used and the content of LLVM_DEFINITIONS is not actual now. On the other
hand the current version of CMake allows getting set of definitions in a
more convenient way. This fix implements evaluation of the variable by
reading corresponding cmake property.

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

llvm-svn: 298336

7 years agoDelete some dead code in HostInfo.
Zachary Turner [Tue, 21 Mar 2017 04:01:59 +0000 (04:01 +0000)]
Delete some dead code in HostInfo.

llvm-svn: 298335

7 years agoDelete various lldb FileSystem functions.
Zachary Turner [Tue, 21 Mar 2017 04:01:04 +0000 (04:01 +0000)]
Delete various lldb FileSystem functions.

Use LLVM's equivalent versions instead.

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

llvm-svn: 298334

7 years agoInitialize m_allow_cxx, m_allow_objc. These ivars in the base class are not
Jason Molenda [Tue, 21 Mar 2017 02:59:15 +0000 (02:59 +0000)]
Initialize m_allow_cxx, m_allow_objc.  These ivars in the base class are not
initialized in the ctor and they're only initialized to 'true' in ClangUserExpression.cpp
when specific languages are detected so we can use uninitialized values.  This
bug has been present since the ivars were added in r144042.
<rdar://problem/31105864>

llvm-svn: 298333

7 years agoAdd support for attribute enum_extensibility.
Akira Hatanaka [Tue, 21 Mar 2017 02:23:00 +0000 (02:23 +0000)]
Add support for attribute enum_extensibility.

This commit adds support for a new attribute that will be used to
distinguish between extensible and inextensible enums. There are three
main purposes of this attribute:

1. Give better control over when enum-related warnings are issued.
For example, in the code below, clang will not issue a -Wassign-enum
warning if the enum is marked "open":

enum __attribute__((enum_extensibility(closed))) EnumClosed {
  B0 = 1, B1 = 10
};

enum __attribute__((enum_extensibility(open))) EnumOpen {
  C0 = 1, C1 = 10
};

enum EnumClosed ec = 100; // warning issued
enum EnumOpen eo = 100; // no warning

2. Enable code-completion and debugging tools to offer better
suggestions.

3. Make it easier for swift's clang importer to determine which swift
type an enum should be mapped to.

For more details, see the discussion I started on cfe-dev:
http://lists.llvm.org/pipermail/cfe-dev/2017-February/052748.html

rdar://problem/12764379
rdar://problem/23145650

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

llvm-svn: 298332

7 years agoFindTypes should find "struct TypeName" as well as "TypeName".
Jim Ingham [Tue, 21 Mar 2017 02:13:50 +0000 (02:13 +0000)]
FindTypes should find "struct TypeName" as well as "TypeName".

This fixes a bug introduced by r291559.  The Module's FindType was
passing the original name not the basename in the case where it didn't
find any separators.  I also added a testcase for this.

<rdar://problem/31159173>

llvm-svn: 298331

7 years agoIRGen: Do not set dllexport on declarations.
Peter Collingbourne [Tue, 21 Mar 2017 02:02:41 +0000 (02:02 +0000)]
IRGen: Do not set dllexport on declarations.

Setting dllexport on a declaration has no effect, as we do not emit export
directives for declarations.

Part of the fix for PR32334.

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

llvm-svn: 298330

7 years agoRevert "[Hexagon] Recognize polynomial-modulo loop idiom again"
Vitaly Buka [Tue, 21 Mar 2017 00:59:51 +0000 (00:59 +0000)]
Revert "[Hexagon] Recognize polynomial-modulo loop idiom again"

Fix memory leaks on check-llvm tests detected by Asan.

This reverts commit r298282.

llvm-svn: 298329

7 years ago[ARM] Revert r297443 and r297820.
Eli Friedman [Tue, 21 Mar 2017 00:26:39 +0000 (00:26 +0000)]
[ARM] Revert r297443 and r297820.

The glueless lowering of addc/adde in Thumb1 has known serious
miscompiles (see https://reviews.llvm.org/D31081), and r297820
causes an infinite loop for certain constructs.  It's not
clear when they will be fixed, so let's just take them out
of the tree for now.

(I resolved a small conflict with r297453.)

llvm-svn: 298328

7 years ago[COFF] Don't let /def override /out filename
Reid Kleckner [Tue, 21 Mar 2017 00:12:51 +0000 (00:12 +0000)]
[COFF] Don't let /def override /out filename

Summary:
This also delays setting the output filename based on the first input
argument until after processing /def.

Fixes PR32354

Reviewers: ruiu, pcc

Subscribers: llvm-commits

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

llvm-svn: 298327

7 years ago[Support] Fill the file_status struct with link count.
Zachary Turner [Mon, 20 Mar 2017 23:55:20 +0000 (23:55 +0000)]
[Support] Fill the file_status struct with link count.

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

llvm-svn: 298326

7 years agoDelete LLDB's MD5 code. Use LLVM instead.
Zachary Turner [Mon, 20 Mar 2017 23:54:54 +0000 (23:54 +0000)]
Delete LLDB's MD5 code. Use LLVM instead.

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

llvm-svn: 298325

7 years ago[analyze-project-deps.py] Add the ability to list all cycles.
Zachary Turner [Mon, 20 Mar 2017 23:54:26 +0000 (23:54 +0000)]
[analyze-project-deps.py] Add the ability to list all cycles.

This analyzes the dependency graph and computes all minimal
cycles.  Equivalent cycles that differ only by rotation are
excluded, as are cycles that are "super-cycles" of other
smaller cycles.  For example, if we discover the cycle
A -> C -> A, and then later A -> B -> C -> D -> A, this latter
cycle is not considered.  Thus, it is possible that after
eliminating some cycles, new ones will appear.  However,
this is the only way to make the algorithm terminate in
a reasonable amount of time.

llvm-svn: 298324

7 years agoMove OffsetInArchive to BitcodeFile.
Rafael Espindola [Mon, 20 Mar 2017 23:47:06 +0000 (23:47 +0000)]
Move OffsetInArchive to BitcodeFile.

It is the only file type that needs it.

llvm-svn: 298323

7 years agoAdd a function to MD5 a file's contents.
Zachary Turner [Mon, 20 Mar 2017 23:33:18 +0000 (23:33 +0000)]
Add a function to MD5 a file's contents.

In doing so, clean up the MD5 interface a little.  Most
existing users only care about the lower 8 bytes of an MD5,
but for some users that care about the upper and lower,
there wasn't a good interface.  Furthermore, consumers
of the MD5 checksum were required to handle endianness
details on their own, so it seems reasonable to abstract
this into a nicer interface that just gives you the right
value.

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

llvm-svn: 298322

7 years ago[ARM] Fix PR32130: Handle promotion of zero sized constants.
Vadzim Dambrouski [Mon, 20 Mar 2017 22:59:57 +0000 (22:59 +0000)]
[ARM] Fix PR32130: Handle promotion of zero sized constants.

The special case of zero sized values was previously not handled correctly.
This patch handles this by not promoting if the size is zero.

Patch by Tim Neumann.

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

llvm-svn: 298320

7 years agoFix parsing of htmxlintrin.h in C++ mode
Eric Christopher [Mon, 20 Mar 2017 22:31:33 +0000 (22:31 +0000)]
Fix parsing of htmxlintrin.h in C++ mode
 - Fix a variable naming mismatch
 - Fix gcc extension pointer arithmetic on void to cast to char *.
 - Test that the header (and htmintrin.h) parse.

llvm-svn: 298318

7 years ago[x86] add tests for setcc of i128/i256; NFC
Sanjay Patel [Mon, 20 Mar 2017 22:15:40 +0000 (22:15 +0000)]
[x86] add tests for setcc of i128/i256; NFC

llvm-svn: 298317

7 years ago[clang-tidy] readability-container-size-empty fix for (*x).size()
Alexander Kornienko [Mon, 20 Mar 2017 22:15:27 +0000 (22:15 +0000)]
[clang-tidy] readability-container-size-empty fix for (*x).size()

llvm-svn: 298316

7 years ago[clang-tidy] Small cleanup. NFC.
Alexander Kornienko [Mon, 20 Mar 2017 22:15:19 +0000 (22:15 +0000)]
[clang-tidy] Small cleanup. NFC.

llvm-svn: 298315

7 years agoMinor improvement of KMP_YIELD_NOW() macro.
Jonathan Peyton [Mon, 20 Mar 2017 22:11:31 +0000 (22:11 +0000)]
Minor improvement of KMP_YIELD_NOW() macro.

This change slightly improves performance of KMP_YIELD_NOW() macro, by using
_rdtsc() intrinsic function if possible.

Patch by Hansang Bae

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

llvm-svn: 298314

7 years agoFix incorrect initial value of __kmp_affinity_type.
Jonathan Peyton [Mon, 20 Mar 2017 22:04:02 +0000 (22:04 +0000)]
Fix incorrect initial value of __kmp_affinity_type.

Affinity initialization code expects __kmp_affinity_type has the value
affinity_default by default, but the cleanup code does not properly set the
value back to affinity_default.  This may introduce some issues when multiple
roots are trying to initialize/uninitialize the runtime successively.

Patch by Hansang Bae

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

llvm-svn: 298313

7 years agoInstCombine: Check source value precision when reducing cast intrinsic
Matt Arsenault [Mon, 20 Mar 2017 21:59:24 +0000 (21:59 +0000)]
InstCombine: Check source value precision when reducing cast intrinsic

Missed this check when porting from the libcall version.

llvm-svn: 298312

7 years agoGlobalISel: add implicit defs & uses when mutating an instruction.
Tim Northover [Mon, 20 Mar 2017 21:58:23 +0000 (21:58 +0000)]
GlobalISel: add implicit defs & uses when mutating an instruction.

Otherwise a scheduler might do bad things to the code we produce.

llvm-svn: 298311

7 years ago[docs] Clarify sanitizer flag behavior
Vedant Kumar [Mon, 20 Mar 2017 21:40:58 +0000 (21:40 +0000)]
[docs] Clarify sanitizer flag behavior

PR32346 suggests that UBSan's docs about the -fsanitize,
-fno-sanitize-recover, and -fsanitize-trap options are not explicit
enough. Try to improve the wording.

llvm-svn: 298310

7 years agoReplace uses of DwarfExpression::addMachineReg* with addMachineRegExpression
Adrian Prantl [Mon, 20 Mar 2017 21:35:09 +0000 (21:35 +0000)]
Replace uses of DwarfExpression::addMachineReg* with addMachineRegExpression
and mark the methods as protected.

Besides reducing the surface area of DwarfExpression, this is in
preparation for an upcoming bugfix in the DwarfExpression
implementation, for which it will be necessary to defer emitting
register operations until the rest of the expression is known.

NFC

llvm-svn: 298309

7 years agoMake implementation details in DwarfExpression protected. (NFC)
Adrian Prantl [Mon, 20 Mar 2017 21:34:19 +0000 (21:34 +0000)]
Make implementation details in DwarfExpression protected. (NFC)

llvm-svn: 298308

7 years agoTurn on HTM on power8 and later (including powerpc64le) since it's
Eric Christopher [Mon, 20 Mar 2017 21:12:53 +0000 (21:12 +0000)]
Turn on HTM on power8 and later (including powerpc64le) since it's
available by default on those cpus and configurations.

llvm-svn: 298307

7 years ago[ELF][MIPS] Calculate relocations agains _gp_disp / __gnu_local_gp using dedicated...
Simon Atanasyan [Mon, 20 Mar 2017 21:03:43 +0000 (21:03 +0000)]
[ELF][MIPS] Calculate relocations agains _gp_disp / __gnu_local_gp using dedicated 'expressions'

The patch introduces two new relocations expressions R_MIPS_GOT_GP and
R_MIPS_GOT_GP_PC. The first one represents a current value of `_gp`
pointer and used to calculate relocations against the `__gnu_local_gp`
symbol. The second one represents the offset between the beginning of
the function and the `_gp` pointer's value.

There are two motivations for introducing new expressions:
- It's better to keep all non-trivial relocation calculations in the
  single place - `getRelocTargetVA` function.
- Relocations against both `_gp_disp` and `__gnu_local_gp` symbols
  depend on the `_gp` value. It's a magical value points to the "middle"
  of GOT. Now all relocations use a common `_gp` value. But in fact,
  under some conditions each input file might require its own `_gp`
  value. I'm going to implement it in the future patches. So it's
  better to make `MipsGotSection` responsible for calculation of
  the `_gp` value.

llvm-svn: 298306

7 years agoBypass potential libc's sysconf wrappers for sysconf(_SC_PAGESIZE) call
Alex Shlyapnikov [Mon, 20 Mar 2017 21:03:28 +0000 (21:03 +0000)]
Bypass potential libc's sysconf wrappers for sysconf(_SC_PAGESIZE) call

Summary:
sysconf(_SC_PAGESIZE) is called very early, during sanitizer init and
any instrumented code (a wrapper/interceptor will likely be instrumented)
calling back to sanitizer before init is done will most surely crash.

Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 298305

7 years ago[ELF][MIPS] Follow-up to r298272. Fix typo to fix buildbot.
Simon Atanasyan [Mon, 20 Mar 2017 20:49:44 +0000 (20:49 +0000)]
[ELF][MIPS] Follow-up to r298272. Fix typo to fix buildbot.

llvm-svn: 298304

7 years agoProposal: Backward-edge CFI for return statements (RCFI)
Kostya Serebryany [Mon, 20 Mar 2017 20:42:00 +0000 (20:42 +0000)]
Proposal: Backward-edge CFI for return statements (RCFI)

Summary: Proposal: Backward-edge CFI for return statements (RCFI)

Reviewers: pcc, eugenis, krasin

Reviewed By: eugenis

Subscribers: llvm-commits

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

llvm-svn: 298303

7 years ago[Fuchsia] Use %gs for ABI slots under -mcmodel=kernel
Evgeniy Stepanov [Mon, 20 Mar 2017 20:35:37 +0000 (20:35 +0000)]
[Fuchsia] Use %gs for ABI slots under -mcmodel=kernel

Make x86_64-fuchsia targets under -mcmodel=kernel use %gs rather
than %fs to access ABI slots for stack-protector and safe-stack

Patch by Roland McGrath.

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

llvm-svn: 298302

7 years ago[SCEV] Fix trip multiple calculation
Eli Friedman [Mon, 20 Mar 2017 20:25:46 +0000 (20:25 +0000)]
[SCEV] Fix trip multiple calculation

If loop bound containing calculations like min(a,b), the Scalar
Evolution API getSmallConstantTripMultiple returns 4294967295 "-1"
as the trip multiple. The problem is that, SCEV use -1 * umax to
represent umin. The multiple constant -1 was returned, and the logic
of guarding against huge trip counts was skipped. Because -1 has 32
active bits.

The fix attempt to factor more general cases. First try to get the
greatest power of two divisor of trip count expression. In case
overflow happens, the trip count expression is still divisible by the
greatest power of two divisor returned. Returns 1 if not divisible by 2.

Patch by Huihui Zhang <huihuiz@codeaurora.org>

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

llvm-svn: 298301

7 years agoAvoid these headers looking like the same file on a content-addressed file system.
Richard Smith [Mon, 20 Mar 2017 20:14:03 +0000 (20:14 +0000)]
Avoid these headers looking like the same file on a content-addressed file system.

llvm-svn: 298300

7 years agoBump __cplusplus for C++17 to 201703L per the C++17 DIS.
Richard Smith [Mon, 20 Mar 2017 20:12:48 +0000 (20:12 +0000)]
Bump __cplusplus for C++17 to 201703L per the C++17 DIS.

llvm-svn: 298299

7 years ago[X86] Clean up test/CodeGen/X86/2006-03-01-InstrSchedBug.ll
David L. Jones [Mon, 20 Mar 2017 20:10:30 +0000 (20:10 +0000)]
[X86] Clean up test/CodeGen/X86/2006-03-01-InstrSchedBug.ll

Summary:
- Migrated from grep to FileCheck.
- Re-indented, removed boilerplate comments.
- Added 'entry' label at beginning of basic block.

Patch by Jorge Gorbe!

Reviewed By: RKSimon

Subscribers: RKSimon, jgorbe, llvm-commits

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

llvm-svn: 298298

7 years agoExplicitly add move constructor/assignment operators.
Zachary Turner [Mon, 20 Mar 2017 19:56:52 +0000 (19:56 +0000)]
Explicitly add move constructor/assignment operators.

These are needed due to some obscure rules in the standard
about how std::vector selects between copy and move
constructors, which can cause a conforming implementation
to attempt to select the copy constructor of RuleMatcher,
which will fail since std::unique_ptr<> isn't copyable.

llvm-svn: 298294

7 years agoAdd test case for merging of chained stores of mismatched type.
Nirav Dave [Mon, 20 Mar 2017 19:48:22 +0000 (19:48 +0000)]
Add test case for merging of chained stores of mismatched type.

llvm-svn: 298293

7 years agoAdd the rest of the error checking for Mach-O dyld compact bind entry errors
Kevin Enderby [Mon, 20 Mar 2017 19:46:55 +0000 (19:46 +0000)]
Add the rest of the error checking for Mach-O dyld compact bind entry errors
and test cases for each of the error checks.

To do this more plumbing was needed so that the segment indexes and
segment offsets can be checked.  Basically what was done was the SegInfo
from llvm-objdump’s MachODump.cpp was moved into libObject for Mach-O
objects as BindRebaseSegInfo and it is only created when an iterator for
bind or rebase entries are created.

This commit really only adds the error checking and test cases for the
bind table entires and the checking for the lazy bind and weak bind entries
are still to be fully done as well as the rebase entires.  Though some of
the plumbing for those are added with this commit.  Those other error
checks and test cases will be added in follow on commits.

Note, the two llvm_unreachable() calls should now actually be unreachable
with the error checks in place and would take a logic bug in the error
checking code to be reached if the segment indexes and segment
offsets are used from a checked bind entry.  Comments have been added
to the methods that require the arguments to have been checked
prior to calling.

llvm-svn: 298292

7 years agoGet ObjectFileMachO to handle @executable_path
Jim Ingham [Mon, 20 Mar 2017 19:21:31 +0000 (19:21 +0000)]
Get ObjectFileMachO to handle @executable_path

Only do this when we are debugging an executable, since we
don't have a good way to trace from an ObjectFile back to its
containing executable.  Detecting pre-run libs before running
is "best effort" in lldb, but this one is pretty easy.

llvm-svn: 298290

7 years agoFix a problem with line tables & .o files that start with code with no line table...
Jim Ingham [Mon, 20 Mar 2017 19:19:03 +0000 (19:19 +0000)]
Fix a problem with line tables & .o files that start with code with no line table entries.

If you have code before the first line table entry when debugging with .o files on macOS, the
LineTable entry search code was assigning all that code to the first line table entry. Don't do that.

<rdar://problem/31095765>

llvm-svn: 298289

7 years agoRevert r298158.
Evgeniy Stepanov [Mon, 20 Mar 2017 18:45:34 +0000 (18:45 +0000)]
Revert r298158.

Revert "[asan] Fix dead stripping of globals on Linux."

OOM in gold linker.

llvm-svn: 298288

7 years agoRevert r298174, r298173, r298169, r298159.
Evgeniy Stepanov [Mon, 20 Mar 2017 18:45:27 +0000 (18:45 +0000)]
Revert r298174, r298173, r298169, r298159.

Revert "Fix sanitizer tests with LLVM_TOOL_LLD_BUILD=OFF."
Revert "[asan] Remove gc-sections test with bfd."
Revert "[asan] Disable globals-gc test with ld.bfd."
Revert "[asan] Fix dead stripping of globals on Linux (compiler-rt)"

OOM in gold linker.

llvm-svn: 298287

7 years agoFixed include order. NFCI.
Simon Pilgrim [Mon, 20 Mar 2017 18:33:23 +0000 (18:33 +0000)]
Fixed include order. NFCI.

llvm-svn: 298286

7 years agoTry using llvm::errc, should hopefully fix version mismatch problem on clang-s390x...
Peter Collingbourne [Mon, 20 Mar 2017 18:19:41 +0000 (18:19 +0000)]
Try using llvm::errc, should hopefully fix version mismatch problem on clang-s390x-linux bot.

llvm-svn: 298285

7 years agoAdd two more papers from Kona, and sort them
Marshall Clow [Mon, 20 Mar 2017 18:18:09 +0000 (18:18 +0000)]
Add two more papers from Kona, and sort them

llvm-svn: 298284

7 years ago[Hexagon] Recognize polynomial-modulo loop idiom again
Krzysztof Parzyszek [Mon, 20 Mar 2017 18:12:58 +0000 (18:12 +0000)]
[Hexagon] Recognize polynomial-modulo loop idiom again

Regain the ability to recognize loops calculating polynomial modulo
operation. This ability has been lost due to some changes in the
preceding optimizations. Add code to preprocess the IR to a form
that the pattern matching code can recognize.

llvm-svn: 298282

7 years ago[AMDGPU] Run always inliner early in opt
Konstantin Zhuravlyov [Mon, 20 Mar 2017 18:06:45 +0000 (18:06 +0000)]
[AMDGPU] Run always inliner early in opt

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

llvm-svn: 298281

7 years agoAdd missing updated test from VN coercion changes. Instructions were renamed. NFC
Daniel Berlin [Mon, 20 Mar 2017 18:04:19 +0000 (18:04 +0000)]
Add missing updated test from VN coercion changes. Instructions were renamed. NFC

llvm-svn: 298280

7 years agoFix UB found by -Wtautological-undefined-compare
David Blaikie [Mon, 20 Mar 2017 18:01:07 +0000 (18:01 +0000)]
Fix UB found by -Wtautological-undefined-compare

llvm-svn: 298279

7 years agoReapply "Modules: Cache PCMs in memory and avoid a use-after-free"
Duncan P. N. Exon Smith [Mon, 20 Mar 2017 17:58:26 +0000 (17:58 +0000)]
Reapply "Modules: Cache PCMs in memory and avoid a use-after-free"

This reverts commit r298185, effectively reapplying r298165, after fixing the
new unit tests (PR32338).  The memory buffer generator doesn't null-terminate
the MemoryBuffer it creates; this version of the commit informs getMemBuffer
about that to avoid the assert.

Original commit message follows:

----

Clang's internal build system for implicit modules uses lock files to
ensure that after a process writes a PCM it will read the same one back
in (without contention from other -cc1 commands).  Since PCMs are read
from disk repeatedly while invalidating, building, and importing, the
lock is not released quickly.  Furthermore, the LockFileManager is not
robust in every environment.  Other -cc1 commands can stall until
timeout (after about eight minutes).

This commit changes the lock file from being necessary for correctness
to a (possibly dubious) performance hack.  The remaining benefit is to
reduce duplicate work in competing -cc1 commands which depend on the
same module.  Follow-up commits will change the internal build system to
continue after a timeout, and reduce the timeout.  Perhaps we should
reconsider blocking at all.

This also fixes a use-after-free, when one part of a compilation
validates a PCM and starts using it, and another tries to swap out the
PCM for something new.

The PCMCache is a new type called MemoryBufferCache, which saves memory
buffers based on their filename.  Its ownership is shared by the
CompilerInstance and ModuleManager.

- The ModuleManager stores PCMs there that it loads from disk, never
touching the disk if the cache is hot.

- When modules fail to validate, they're removed from the cache.

- When a CompilerInstance is spawned to build a new module, each
already-loaded PCM is assumed to be valid, and is frozen to avoid
the use-after-free.

- Any newly-built module is written directly to the cache to avoid the
round-trip to the filesystem, making lock files unnecessary for
correctness.

Original patch by Manman Ren; most testcases by Adrian Prantl!

llvm-svn: 298278

7 years agoMention that the Sphinx docs build wants version 1.5 or later
Jonathan Roelofs [Mon, 20 Mar 2017 17:49:36 +0000 (17:49 +0000)]
Mention that the Sphinx docs build wants version 1.5 or later

`misc.highlighting_failure` support was added to `suppress_warnings` in that
version, and the warnings-as-errors docs build relies on it.

llvm-svn: 298277

7 years ago[WinEH] Adjust decision to emit SEH moves for leaf functions
Reid Kleckner [Mon, 20 Mar 2017 17:45:59 +0000 (17:45 +0000)]
[WinEH] Adjust decision to emit SEH moves for leaf functions

Move the check for "MF->hasWinCFI()" up into the calculation of the
shouldEmitMoves boolean, rather than putting it in the early returning
if. This ensures that endFunction doesn't try to emit .seh_* directives
for leaf functions.

llvm-svn: 298276

7 years agoFix some sphinx -Werror's
Jonathan Roelofs [Mon, 20 Mar 2017 17:07:49 +0000 (17:07 +0000)]
Fix some sphinx -Werror's

... mostly having to do with code blocks which the syntax highlighter chokes on

llvm-svn: 298275

7 years agoUse pthreads for thread-local lsan allocator cache on darwin
Francis Ricci [Mon, 20 Mar 2017 17:06:42 +0000 (17:06 +0000)]
Use pthreads for thread-local lsan allocator cache on darwin

Summary:
This patch allows us to move away from using __thread on darwin,
which is requiring for building lsan for darwin on ios version 7
and on iossim i386.

Reviewers: kubamracek, kcc

Subscribers: llvm-commits

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

llvm-svn: 298274

7 years agoGlobalISel: allow quad-precision values to be dumped.
Tim Northover [Mon, 20 Mar 2017 16:52:08 +0000 (16:52 +0000)]
GlobalISel: allow quad-precision values to be dumped.

Otherwise the fallback path fails with an assertion on AAPCS AArch64 targets,
when "long double" is encountered.

llvm-svn: 298273

7 years ago[ELF] - Detemplate MipsGotSection<ELFT>
George Rimar [Mon, 20 Mar 2017 16:44:28 +0000 (16:44 +0000)]
[ELF] - Detemplate MipsGotSection<ELFT>

This continues detemplation process.

Detemplating MipsGotSection<ELFT> is helpfull because can
help to detemplate getRelocTargetVA. (one more change is required)
It opens road to detemplation of GotSection<ELFT> and probably
something else after that.

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

llvm-svn: 298272

7 years agoSupport, LTO: When pruning a directory, ignore files matching a prefix.
Peter Collingbourne [Mon, 20 Mar 2017 16:41:57 +0000 (16:41 +0000)]
Support, LTO: When pruning a directory, ignore files matching a prefix.

This is a safeguard against data loss if the user specifies a directory
that is not a cache directory. Teach the existing cache pruning clients
to create files with appropriate names.

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

llvm-svn: 298271

7 years agoUpdates branch_weights annotation for call instructions during inlining.
Dehao Chen [Mon, 20 Mar 2017 16:40:44 +0000 (16:40 +0000)]
Updates branch_weights annotation for call instructions during inlining.

Summary: Inliner should update the branch_weights annotation to scale it to proper value.

Reviewers: davidxl, eraman

Reviewed By: eraman

Subscribers: zzheng, llvm-commits

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

llvm-svn: 298270

7 years ago[ELF] - Detemplate BuildIdSection section.
George Rimar [Mon, 20 Mar 2017 16:40:21 +0000 (16:40 +0000)]
[ELF] - Detemplate BuildIdSection section.

Does not introduce anything new,
just performs detemplate, using methods we
already have.

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

llvm-svn: 298269

7 years agoUse isa<> instead of dyn_cast<> (NFC).
Adrian Prantl [Mon, 20 Mar 2017 16:39:41 +0000 (16:39 +0000)]
Use isa<> instead of dyn_cast<> (NFC).

llvm-svn: 298268

7 years agoDisable stack-use-after-return.cc on AArch64. The test was not testing the right...
Kuba Mracek [Mon, 20 Mar 2017 16:36:34 +0000 (16:36 +0000)]
Disable stack-use-after-return.cc on AArch64.  The test was not testing the right thing before (the call to pthread_attr_setstacksize wasn't doing anything) anyway, and now it's running out of stack due to an unrelated change.

llvm-svn: 298267

7 years agoAvoid potential ADL ambiguity between llvm::make_unique and std::make_unique (when...
David Blaikie [Mon, 20 Mar 2017 16:35:33 +0000 (16:35 +0000)]
Avoid potential ADL ambiguity between llvm::make_unique and std::make_unique (when building as C++14+)

Patch by Moritz Kiefer!

llvm-svn: 298266

7 years ago[AMDGPU][MC] Fix for Bugs 28201, 28199, 28170 + LIT tests
Dmitry Preobrazhensky [Mon, 20 Mar 2017 16:33:20 +0000 (16:33 +0000)]
[AMDGPU][MC] Fix for Bugs 28201, 28199, 28170 + LIT tests

This fix enables sp3 abs modifier with constants

Reviewers: artem.tamazov

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

llvm-svn: 298265

7 years ago[InstCombine] Print a debug message when we constant fold an operand during worklist...
Craig Topper [Mon, 20 Mar 2017 16:31:14 +0000 (16:31 +0000)]
[InstCombine] Print a debug message when we constant fold an operand during worklist creation

InstCombine tries to constant fold instruction operands during worklist building, but we don't print that we're doing this.

We also set a change flag here that causes us to rebuild and rerun the worklist one more time even if processing the worklist itself created no additional changes. So in the log I saw two inst combine runs that visited all instructions without printing that anything was changed. I may be submitting another patch to remove the change flag unless I can find some reason why we should be doing that.

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

llvm-svn: 298264

7 years ago[Outliner] ACTUALLY remove the errs output
Jessica Paquette [Mon, 20 Mar 2017 16:25:04 +0000 (16:25 +0000)]
[Outliner] ACTUALLY remove the errs output

I don't know how to type. This fixes the last commit which would have made all
of the overflows legal, and kept the screaming.

llvm-svn: 298263

7 years agoTemplatize parts of VNCoercion, and add constant-only versions of the functions to...
Daniel Berlin [Mon, 20 Mar 2017 16:08:29 +0000 (16:08 +0000)]
Templatize parts of VNCoercion, and add constant-only versions of the functions to be used in NewGVN.
NFCI.

Summary:
This is ground work for the changes to enable coercion in NewGVN.
GVN doesn't care if they end up constant because it eliminates as it goes.
NewGVN cares.

IRBuilder and ConstantFolder deliberately present the same interface,
so we use this to our advantage to templatize our functions to make
them either constant only or not.

Reviewers: davide

Subscribers: llvm-commits, Prazek

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

llvm-svn: 298262

7 years agoFix remote test suite directory creation
Pavel Labath [Mon, 20 Mar 2017 16:07:17 +0000 (16:07 +0000)]
Fix remote test suite directory creation

r298203 make SBPlatform::MakeDirectory less recursive, which breaks the
test suite creation of test directory hierarchy creation on the remote
target. Since the function was never fully recursive, and the name does
not imply recursiveness, I fix the problem by modifying the test runner
to do the recursion manually.

I also make the runner complain more loudly when it fails to create the
directory -- previously it just printed the error to stdout and caused
most of the tests to hang, which is not very helpful in diagnosing the
problem.

llvm-svn: 298261

7 years ago[Outliner] Remove output for offset range check
Jessica Paquette [Mon, 20 Mar 2017 15:51:45 +0000 (15:51 +0000)]
[Outliner] Remove output for offset range check

Forgot to remove some output before committing last time. (Instruction fixups
don't actually overflow anywhere in the test suite so far, so I missed it).

To prevent the outliner from screaming "Overflow!" in the event that that
does happen, this commit removes that output.

llvm-svn: 298260

7 years ago[DeLICM] Refector out parseSetOrNull. NFC.
Michael Kruse [Mon, 20 Mar 2017 15:37:32 +0000 (15:37 +0000)]
[DeLICM] Refector out parseSetOrNull. NFC.

Note that the isl::union_set(isl_ctx,std::string) constructor will
auto-convert the char* to an std::string. Converting a nullptr to
std::string is undefined in C++11 (sect. 21.4.2.9).

llvm-svn: 298259

7 years ago[DeLICM] Add forgotten isl_space_set_tuple_id in unittests.
Michael Kruse [Mon, 20 Mar 2017 15:24:45 +0000 (15:24 +0000)]
[DeLICM] Add forgotten isl_space_set_tuple_id in unittests.

Otherwise the isl_id NewId which ensures uniqueness of the
created space is unused. None of the tests currently uses an
nameless tuple, so there is not change in what is tested.

llvm-svn: 298258

7 years ago[tablegen][globalisel] Capture instructions into locals and related infrastructure...
Daniel Sanders [Mon, 20 Mar 2017 15:20:42 +0000 (15:20 +0000)]
[tablegen][globalisel] Capture instructions into locals and related infrastructure for multiple instructions matches.

Summary:
Prepare the way for nested instruction matching support by having actions
like CopyRenderer look up operands in the RuleMatcher rather than a
specific InstructionMatcher. This allows actions to reference any operand
from any matched instruction.

It works by checking the 'shape' of the match and capturing
each matched instruction to a local variable. If the shape is wrong
(not enough operands, leaf nodes where non-leafs are expected, etc.), then
the rule exits early without checking the predicates. Once we've captured
the instructions, we then test the predicates as before (except using the
local variables). If the match is successful, then we render the new
instruction as before using the local variables.

It's not noticable in this patch but by the time we support multiple
instruction matching, this patch will also cause a significant improvement
to readability of the emitted code since
MRI.getVRegDef(I->getOperand(0).getReg()) will simply be MI1 after
emitCxxCaptureStmts().

This isn't quite NFC because I've also fixed a bug that I'm surprised we
haven't encountered yet. It now checks there are at least the expected
number of operands before accessing them with getOperand().

Depends on D30531

Reviewers: t.p.northover, qcolombet, aditya_nandakumar, ab, rovka

Reviewed By: rovka

Subscribers: dberris, kristof.beyls, llvm-commits

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

llvm-svn: 298257

7 years ago[OpenCL] Fix extension guards for atomic functions
Anastasia Stulova [Mon, 20 Mar 2017 15:02:54 +0000 (15:02 +0000)]
[OpenCL] Fix extension guards for atomic functions

Review: D30830

Patch by James Price!

llvm-svn: 298256