platform/upstream/llvm.git
7 years agoRevert "[lit] Refactor out some more common lit configuration code."
Zachary Turner [Thu, 21 Sep 2017 21:45:45 +0000 (21:45 +0000)]
Revert "[lit] Refactor out some more common lit configuration code."

This is breaking several bots.  I have enough information to
investigate, so I'm reverting to green until I get it figured
out.

llvm-svn: 313922

7 years agoFix a bug in llvm-objdump when disassembling using the wrong default CPU
Kevin Enderby [Thu, 21 Sep 2017 21:45:02 +0000 (21:45 +0000)]
Fix a bug in llvm-objdump when disassembling using the wrong default CPU
in the second slice of a Mach-O universal file.

The code in llvm-objdump in in DisassembleMachO() was getting the default
CPU then incorrectly setting into the global variable used for the -mcpu option
if that was not set.  This caused a second call to DisassembleMachO() to use
the wrong default CPU when disassembling the next slice in a Mach-O universal
file.  And would result in bad disassembly and an error message about an
recognized processor for the target:

% llvm-objdump -d -m -arch all  fat.macho-armv7s-arm64
fat.macho-armv7s-arm64 (architecture armv7s):
(__TEXT,__text) section
armv7:
       0: 60 47  bx r12
fat.macho-armv7s-arm64 (architecture arm64):
'cortex-a7' is not a recognized processor for this target (ignoring processor)
'cortex-a7' is not a recognized processor for this target (ignoring processor)
(__TEXT,__text) section
___multc3:
       0: .long 0x1e620810

rdar://34439149

llvm-svn: 313921

7 years ago[libunwind] Partially revert r297174 to fix build on at least FreeBSD.
John Baldwin [Thu, 21 Sep 2017 21:28:48 +0000 (21:28 +0000)]
[libunwind] Partially revert r297174 to fix build on at least FreeBSD.

The changes in r297174 moved the #include of <link.h> on FreeBSD (and
probably other systems) inside of the open 'libunwind' namespace
causing various system-provided types such as pid_t to be declared in
this namespace rather than the global namespace.  Fix this by moving
the relevant declarations before the 'libunwind' namespace is opened,
but still using the cleaned up declarations from r297174.

Reviewed By: ed, compnerd

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

llvm-svn: 313920

7 years ago[lit] Refactor out some more common lit configuration code.
Zachary Turner [Thu, 21 Sep 2017 21:27:31 +0000 (21:27 +0000)]
[lit] Refactor out some more common lit configuration code.

debuginfo-tests has need to reuse a lot of common configuration
from clang and lld, and in general it seems like all of the
projects which are tightly coupled (e.g. lld, clang, llvm, lldb,
etc) can benefit from knowing about one other.  For example,
lldb needs to know various things about how to run clang in its
test suite.  Since there's a lot of common substitutions and
operations that need to be shared among projects, sinking this
up into LLVM makes sense.

In addition, this patch introduces a function add_tool_substitution
which handles all the dirty intricacies of matching tool names
which was previously copied around the various config files.  This
is now a simple straightforward interface which is hard to mess
up.

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

llvm-svn: 313919

7 years ago[lit] Actually do normalize the case of files in the config map.
Zachary Turner [Thu, 21 Sep 2017 21:27:11 +0000 (21:27 +0000)]
[lit] Actually do normalize the case of files in the config map.

This has gone back and forth, but it seems this is necessary
after all.  realpath is not sufficient because if you have a
file named 'C:\foo.txt', then both realpath('c:\foo.txt') and
realpath(C:\foo.txt') return the string that was passed to them
exactly as is, meaning the case of the drive-letter won't match.

The problem before was not that we were normalizing the case of
items going into the config map, but rather that we were
normalizing the case of something we needed to print.  The value
that is used to key on the config map should never be printed.

llvm-svn: 313918

7 years ago[AArch64] Fix bug in store of vector 0 DAGCombine.
Geoff Berry [Thu, 21 Sep 2017 21:10:06 +0000 (21:10 +0000)]
[AArch64] Fix bug in store of vector 0 DAGCombine.

Summary:
Avoid using XZR/WZR directly as operands to split stores of zero
vectors.  Doing so can lead to the XZR/WZR being used by an instruction
that doesn't allow it (e.g. add).

Fixes bug 34674.

Reviewers: t.p.northover, efriedma, MatzeB

Subscribers: aemerson, rengolin, javed.absar, mcrosier, eraman, llvm-commits, kristof.beyls

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

llvm-svn: 313916

7 years ago[ELF] Fix edge condition in thunk offset calculation
Shoaib Meenai [Thu, 21 Sep 2017 21:04:42 +0000 (21:04 +0000)]
[ELF] Fix edge condition in thunk offset calculation

For ARM thunks, the `movt` half of the relocation was using an incorrect
offset (it was off by 4 bytes). The original intent seems to have been
for the offset to have been relative to the current instruction, in
which case the difference of 4 makes sense. As the code stands, however,
the offset is always calculated relative to the start of the thunk
(`P`), and so the `movw` and `movt` halves should use the same offset.
This requires a very particular offset between the thunk and its target
to be triggered, and it results in the `movt` half of the relocation
being off-by-one.

The tests here use ARM-Thumb interworking thunks, since those are the
only ARM thunks currently implemented. I actually encountered this with
a range extension thunk (having Peter's patches cherry-picked locally),
but the underlying issue is identical.

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

llvm-svn: 313915

7 years ago[libclang] Keep track of TranslationUnit instance when annotating tokens
Jonathan Coe [Thu, 21 Sep 2017 20:48:43 +0000 (20:48 +0000)]
[libclang] Keep track of TranslationUnit instance when annotating tokens

Summary:
Previously the `_tu` was not propagated to the returned cursor, leading to errors when calling any
method on that cursor (e.g. `cursor.referenced`).

Reviewers: jbcoe, rsmith

Reviewed By: jbcoe

Subscribers: cfe-commits

Tags: #clang

Patch by jklaehn (Johann Klähn)

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

llvm-svn: 313913

7 years ago[llvm-readobj] Fix big-endian byte swap in WindowsResourceDumper.
Marek Sokolowski [Thu, 21 Sep 2017 20:36:38 +0000 (20:36 +0000)]
[llvm-readobj] Fix big-endian byte swap in WindowsResourceDumper.

The previous version of dumper implemented UTF-16 byte swap incorrectly
on big-endian machines. This now gets fixed.

Thanks to Bill Seurer for testing the patch locally.

Differential Review: https://reviews.llvm.org/D38150

llvm-svn: 313912

7 years agoRemove svn-properties for file added in 313909 (NFC)
Erich Keane [Thu, 21 Sep 2017 20:31:01 +0000 (20:31 +0000)]
Remove svn-properties for file added in 313909 (NFC)

llvm-svn: 313911

7 years ago[dwarfdump] Add verbose output for .debug-line section
Jonas Devlieghere [Thu, 21 Sep 2017 20:15:30 +0000 (20:15 +0000)]
[dwarfdump] Add verbose output for .debug-line section

This patch adds dumping of line table instructions as well as the final
state at each specified pc value in verbose mode. This is essentially
the same as the default in Darwin's dwarfdump. Dumping the actual line
table opcodes can be particularly useful for something like debugging a
bad `.debug_line` section.

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

llvm-svn: 313910

7 years agoAdd testcase I forgot to add in R313907.
Erich Keane [Thu, 21 Sep 2017 20:14:08 +0000 (20:14 +0000)]
Add testcase I forgot to add in R313907.

llvm-svn: 313909

7 years ago[DAGCombiner] Slightly simplify some code by using APInt::isMask() and countTrailingO...
Craig Topper [Thu, 21 Sep 2017 20:12:19 +0000 (20:12 +0000)]
[DAGCombiner] Slightly simplify some code by using APInt::isMask() and countTrailingOnes instead of getting active bits and checking if all the bits below that make a mask.

At least for the 64-bit and less case, we should be able to determine if we even have a mask without counting any bits. This also removes the need to explicitly check for 0 active bits, isMask will return false for 0.

llvm-svn: 313908

7 years agoSuppress Wsign-conversion for enums with matching underlying type
Erich Keane [Thu, 21 Sep 2017 19:58:55 +0000 (19:58 +0000)]
Suppress Wsign-conversion for enums with matching underlying type

As reported here: https://bugs.llvm.org/show_bug.cgi?id=34692

A non-defined enum with a backing type was always defaulting to
being treated as a signed type. IN the case where it IS defined,
the signed-ness of the actual items is used.

This patch uses the underlying type's signed-ness in the non-defined
case to test signed-comparision.

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

llvm-svn: 313907

7 years ago[Sema] Prevent InstantiateClass from checking unrelated exception specs.
Volodymyr Sapsai [Thu, 21 Sep 2017 19:54:12 +0000 (19:54 +0000)]
[Sema] Prevent InstantiateClass from checking unrelated exception specs.

Sema::InstantiateClass should check only exception specs added during
class instantiation and ignore already present delayed specs. This fixes
a case where we instantiate a class before parsing member initializers,
check exceptions for a different class and fail to find a member
initializer. Which is required for comparing exception specs for
explicitly-defaulted and implicit default constructor. With the fix we
are still checking exception specs but only after member initializers
are present.

Removing errors in crash-unparsed-exception.cpp is acceptable according
to discussion in PR24000 because other compilers accept code in
crash-unparsed-exception.cpp as valid.

rdar://problem/34167492

Reviewers: davide, rsmith

Reviewed By: rsmith

Subscribers: dim, cfe-commits

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

llvm-svn: 313906

7 years agoRe-land r313825: "[IR] Add llvm.dbg.addr, a control-dependent version of llvm.dbg...
Reid Kleckner [Thu, 21 Sep 2017 19:52:03 +0000 (19:52 +0000)]
Re-land r313825: "[IR] Add llvm.dbg.addr, a control-dependent version of llvm.dbg.declare"

The fix is to avoid invalidating our insertion point in
replaceDbgDeclare:
     Builder.insertDeclare(NewAddress, DIVar, DIExpr, Loc, InsertBefore);
+    if (DII == InsertBefore)
+      InsertBefore = &*std::next(InsertBefore->getIterator());
     DII->eraseFromParent();

I had to write a unit tests for this instead of a lit test because the
use list order matters in order to trigger the bug.

The reduced C test case for this was:
  void useit(int*);
  static inline void inlineme() {
    int x[2];
    useit(x);
  }
  void f() {
    inlineme();
    inlineme();
  }

llvm-svn: 313905

7 years ago[LLDB] Implement interactive command interruption
Adrian McCarthy [Thu, 21 Sep 2017 19:36:52 +0000 (19:36 +0000)]
[LLDB] Implement interactive command interruption

The core of this change is the new CommandInterpreter::m_command_state, which
models the state transitions for interactive commands, including an
"interrupted" state transition.

In general, command interruption requires cooperation from the code executing
the command, which needs to poll for interruption requests through
CommandInterpreter::WasInterrupted().

CommandInterpreter::PrintCommandOutput() implements an optionally
interruptible printing of the command output, which for large outputs was
likely the longest blocking part.  (ex. target modules dump symtab on a
complex binary could take 10+ minutes)

patch by lemo

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

llvm-svn: 313904

7 years ago[DeLICM] Allow non-injective PHIRead->PHIWrite mapping.
Michael Kruse [Thu, 21 Sep 2017 19:08:23 +0000 (19:08 +0000)]
[DeLICM] Allow non-injective PHIRead->PHIWrite mapping.

Remove an assertion that tests the injectivity of the
PHIRead -> PHIWrite relation.  That is, allow a single PHI write to be
used by multiple PHI reads.  This may happen due to some statements
containing the PHI write not having the statement instances that would
overwrite the previous incoming value due to (assumed/invalid) contexts.
This result in that PHI write is mapped to multiple targets which is not
supported.  Codegen will select one one of the targets using
getAddressFunction().  However, the runtime check should protect us from
this case ever being executed.

We therefore allow injective PHI relations.  Additional calculations to
detect/santitize this case would probably not be worth the compuational
effort.

This fixes llvm.org/PR34485

llvm-svn: 313902

7 years ago[SelectionDAG] Pick correct frame index in LowerArguments
Bjorn Pettersson [Thu, 21 Sep 2017 18:52:08 +0000 (18:52 +0000)]
[SelectionDAG] Pick correct frame index in LowerArguments

Summary:
SelectionDAGISel::LowerArguments is associating arguments
with frame indices (FuncInfo->setArgumentFrameIndex). That
information is later on used by EmitFuncArgumentDbgValue to
create DBG_VALUE instructions that denotes that a variable
can be found on the stack.

I discovered that for our (big endian) out-of-tree target
the association created by SelectionDAGISel::LowerArguments
sometimes is wrong. I've seen this happen when a 64-bit value
is passed on the stack. The argument will occupy two stack
slots (frame index X, and frame index X+1). The fault is
that a call to setArgumentFrameIndex is associating the
64-bit argument with frame index X+1. The effect is that the
debug information (DBG_VALUE) will point at the least significant
part of the arguement on the stack. When printing the
argument in a debugger I will get the wrong value.

I managed to create a test case for PowerPC that seems to
show the same kind of problem.

The bugfix will look at the datalayout, taking endianness into
account when examining a BUILD_PAIR node, assuming that the
least significant part is in the first operand of the BUILD_PAIR.
For big endian targets we should use the frame index from
the second operand, as the most significant part will be stored
at the lower address (using the highest frame index).

Reviewers: bogner, rnk, hfinkel, sdardis, aprantl

Reviewed By: aprantl

Subscribers: nemanjai, aprantl, llvm-commits, igorb

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

llvm-svn: 313901

7 years agollvm-dwarfdump support --debug-frame=<offset> and --eh-frame=<offset>
Adrian Prantl [Thu, 21 Sep 2017 18:52:03 +0000 (18:52 +0000)]
llvm-dwarfdump support --debug-frame=<offset> and --eh-frame=<offset>

llvm-svn: 313900

7 years ago[CUDA] Fixed order of words in the names of shfl builtins.
Artem Belevich [Thu, 21 Sep 2017 18:46:39 +0000 (18:46 +0000)]
[CUDA] Fixed order of words in the names of shfl builtins.

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

llvm-svn: 313899

7 years ago[NVPTX] Implemented bar.warp.sync, barrier.sync, and vote{.sync} instructions/intrins...
Artem Belevich [Thu, 21 Sep 2017 18:44:49 +0000 (18:44 +0000)]
[NVPTX] Implemented bar.warp.sync, barrier.sync, and vote{.sync} instructions/intrinsics/builtins.

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

llvm-svn: 313898

7 years ago[Sema] Fix using old initializer during switch statement transformation.
Volodymyr Sapsai [Thu, 21 Sep 2017 17:58:27 +0000 (17:58 +0000)]
[Sema] Fix using old initializer during switch statement transformation.

It fixes a crash in CodeGen when we are trying to generate code for
initializer expression created before template instantiation, like

    CallExpr '<dependent type>'
    |-UnresolvedLookupExpr '<overloaded function type>' lvalue (ADL) = 'parse'
    `-DeclRefExpr 'Buffer<N>' lvalue ParmVar 'buffer' 'Buffer<N>'

rdar://problem/33888545

Reviewers: rsmith, ahatanak

Reviewed By: ahatanak

Subscribers: aemerson, kristof.beyls, cfe-commits

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

llvm-svn: 313896

7 years agoUse ArrayRef. NFC.
Rafael Espindola [Thu, 21 Sep 2017 17:51:07 +0000 (17:51 +0000)]
Use ArrayRef. NFC.

llvm-svn: 313895

7 years ago[fixup][Sema] Allow in C to define tags inside enumerations.
Volodymyr Sapsai [Thu, 21 Sep 2017 17:41:30 +0000 (17:41 +0000)]
[fixup][Sema] Allow in C to define tags inside enumerations.

Fix for too aggressive error err_type_defined_in_enum introduced in
r313386. Defining tags inside enumerations is prohibited in C++ but
allowed in C.

Reviewers: aaron.ballman, rnk, doug.gregor

Reviewed By: rnk

Subscribers: alberto_magni, cfe-commits

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

llvm-svn: 313894

7 years ago[x86] add more tests for node-level FMF; NFC
Sanjay Patel [Thu, 21 Sep 2017 17:40:58 +0000 (17:40 +0000)]
[x86] add more tests for node-level FMF; NFC

llvm-svn: 313893

7 years ago[lit] Rename lld and clang lit configs to end in .py
Zachary Turner [Thu, 21 Sep 2017 17:38:13 +0000 (17:38 +0000)]
[lit] Rename lld and clang lit configs to end in .py

This follows in line with a previous patch of renaming LLVM's.

Working on these files is difficult in certain operating systems
and/or environments that don't like handling python code with a
non .py file extension.

llvm-svn: 313892

7 years ago[DAGCombiner] Remove duplicate code from visitZERO_EXTEND
Craig Topper [Thu, 21 Sep 2017 17:30:02 +0000 (17:30 +0000)]
[DAGCombiner] Remove duplicate code from visitZERO_EXTEND

This exact block of code exists right below.

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

llvm-svn: 313891

7 years agoFix buildbot failures, add mtriple to gpr-vsr-spill.ll
Zaara Syeda [Thu, 21 Sep 2017 17:05:47 +0000 (17:05 +0000)]
Fix buildbot failures, add mtriple to gpr-vsr-spill.ll

llvm-svn: 313890

7 years ago[lit] Don't norm case when inserting into the config map.
Zachary Turner [Thu, 21 Sep 2017 17:02:08 +0000 (17:02 +0000)]
[lit] Don't norm case when inserting into the config map.

This makes all paths lowercase on Windows, which seemed like a
good idea at the time, but it means that tests can't properly
use FileCheck to match expected path names.

llvm-svn: 313889

7 years agollvm-dwarfdump: Add support for the --arch command line option.
Adrian Prantl [Thu, 21 Sep 2017 16:26:18 +0000 (16:26 +0000)]
llvm-dwarfdump: Add support for the --arch command line option.

llvm-svn: 313888

7 years ago[lit] Add a test for the builtin config map.
Zachary Turner [Thu, 21 Sep 2017 16:18:28 +0000 (16:18 +0000)]
[lit] Add a test for the builtin config map.

Config map is not exposed through the command line, so testing this
is somewhat tricky.  But basically we need a test that if a custom
driver builds a config map and passes it to main, it gets respected.

A config map allows config files in the source tree to be mapped
to alternate config files in the build tree.  This particular test
works by having two config files in separate directories, and
setting up a config map to have that redirects A/lit.site.cfg
to B/altconfig.  Then, we print a message in A/lit.site.cfg
and B/altconfig and check that we do see the output from B
but don't see the output from A.  Additionally we test that
the test suite specified by A's config map is properly discovered.

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

llvm-svn: 313887

7 years ago[Power9] Spill gprs to vector registers rather than stack
Zaara Syeda [Thu, 21 Sep 2017 16:12:33 +0000 (16:12 +0000)]
[Power9] Spill gprs to vector registers rather than stack

This patch updates register allocation to enable spilling gprs to
volatile vector registers rather than the stack. It can be enabled
 for Power9 with option -ppc-enable-gpr-to-vsr-spills.

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

llvm-svn: 313886

7 years agoAdd missing file from r313884.
Benjamin Kramer [Thu, 21 Sep 2017 15:32:05 +0000 (15:32 +0000)]
Add missing file from r313884.

llvm-svn: 313885

7 years ago[DWARF] Shrink AttributeSpec from 24 to 16 bytes.
Benjamin Kramer [Thu, 21 Sep 2017 15:27:45 +0000 (15:27 +0000)]
[DWARF] Shrink AttributeSpec from 24 to 16 bytes.

This is a bit ugly because we can't put Optional into a union. Hide all
of that behind a set of accessors and make accesses safer using asserts.

llvm-svn: 313884

7 years ago[X86][SSE] Add PSHUFLW/PSHUFHW tests inspired by PR34686
Simon Pilgrim [Thu, 21 Sep 2017 15:11:51 +0000 (15:11 +0000)]
[X86][SSE] Add PSHUFLW/PSHUFHW tests inspired by PR34686

llvm-svn: 313883

7 years ago[MIPS] Explicitly list supported relocations for MIPS target. NFC
Simon Atanasyan [Thu, 21 Sep 2017 14:40:32 +0000 (14:40 +0000)]
[MIPS] Explicitly list supported relocations for MIPS target. NFC

This is change is inspired by the D28611 patch. New supported
relocations have been added to the switch statement.

llvm-svn: 313882

7 years ago[ScopInfo] Use map for value def/PHI read accesses.
Michael Kruse [Thu, 21 Sep 2017 14:23:11 +0000 (14:23 +0000)]
[ScopInfo] Use map for value def/PHI read accesses.

Before this patch, ScopInfo::getValueDef(SAI) used
getStmtFor(Instruction*) to find the MemoryAccess that writes a
MemoryKind::Value. In cases where the value is synthesizable within the
statement that defines, the instruction is not added to the statement's
instruction list, which means getStmtFor() won't return anything.

If the synthesiable instruction is not synthesiable in a different
statement (due to being defined in a loop that and ScalarEvolution
cannot derive its escape value), we still need a MemoryKind::Value
and a write to it that makes it available in the other statements.
Introduce a separate map for this purpose.

This fixes MultiSource/Benchmarks/MallocBench/cfrac where
-polly-simplify could not find the writing MemoryAccess for a use. The
write was not marked as required and consequently was removed.

Because this could in principle happen as well for PHI scalars,
add such a map for PHI reads as well.

llvm-svn: 313881

7 years ago[OPENMP] Use canonical declarations for redeclarations checks.
Alexey Bataev [Thu, 21 Sep 2017 14:06:59 +0000 (14:06 +0000)]
[OPENMP] Use canonical declarations for redeclarations checks.

If the captured variable has some redeclarations we may run into the
situation where the redeclaration is used instead of the canonical
declaration and we may consider this variable as one not captured
before.

llvm-svn: 313880

7 years ago[mips] Implement generation of relocations "chains" used by N32 ABI
Simon Atanasyan [Thu, 21 Sep 2017 14:04:53 +0000 (14:04 +0000)]
[mips] Implement generation of relocations "chains" used by N32 ABI

In case of using a "nested" relocation expressions like this
`%hi(%neg(%gp_rel()))`, N32 ABI requires generation of three consecutive
relocations. That differs from the N64 ABI case where all relocations
are packed into the single relocation record.

llvm-svn: 313879

7 years ago[mips] Do not pass redundant IsN64 flag to MCELFObjectTargetWriter. NFC
Simon Atanasyan [Thu, 21 Sep 2017 14:04:47 +0000 (14:04 +0000)]
[mips] Do not pass redundant IsN64 flag to MCELFObjectTargetWriter. NFC

Now we pass the 'Is64_' flag to the MCELFObjectTargetWriter ctor iif
when we make deal with N64 ABI. So it is redundant to pass additional
'IsN64' flag.

llvm-svn: 313878

7 years ago[SystemZ] Improve optimizeCompareZero()
Jonas Paulsson [Thu, 21 Sep 2017 13:52:24 +0000 (13:52 +0000)]
[SystemZ]  Improve optimizeCompareZero()

More conversions to load-and-test can be made with this patch by adding a
forward search in optimizeCompareZero().

Review: Ulrich Weigand
https://reviews.llvm.org/D38076

llvm-svn: 313877

7 years agoRevert r313825: "[IR] Add llvm.dbg.addr, a control-dependent version of llvm.dbg...
Daniel Jasper [Thu, 21 Sep 2017 12:07:33 +0000 (12:07 +0000)]
Revert r313825: "[IR] Add llvm.dbg.addr, a control-dependent version of llvm.dbg.declare"

.. as well as the two subsequent changes r313826 and r313875.

This leads to segfaults in combination with ASAN. Will forward repro
instructions to the original author (rnk).

llvm-svn: 313876

7 years ago[SROA] Really remove associated dbg.declare when removing dead alloca
Mikael Holmen [Thu, 21 Sep 2017 11:14:27 +0000 (11:14 +0000)]
[SROA] Really remove associated dbg.declare when removing dead alloca

Summary:
There already was code that tried to remove the dbg.declare, but that code
was placed after we had called
 I->replaceAllUsesWith(UndefValue::get(I->getType()));
on the alloca, so when we searched for the relevant dbg.declare, we
couldn't find it.

Now we do the search before we call RAUW so there is a chance to find it.

An existing testcase needed update due to this. Two dbg.declare with undef
were removed and then suddenly one of the two CHECKS failed.

Before this patch we got

  call void @llvm.dbg.declare(metadata i24* undef, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 24)), !dbg !15
  call void @llvm.dbg.declare(metadata %struct.prog_src_register* undef, metadata !14, metadata !DIExpression()), !dbg !15
  call void @llvm.dbg.value(metadata i32 0, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg !15
  call void @llvm.dbg.value(metadata i32 0, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 24)), !dbg !15

and with it we get

  call void @llvm.dbg.value(metadata i32 0, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg !15
  call void @llvm.dbg.value(metadata i32 0, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 24)), !dbg !15

However, the CHECKs in the testcase checked things in a silly order, so
they only passed since they found things in the first dbg.declare. Now
we changed the order of the checks and the test passes.

Reviewers: rnk

Reviewed By: rnk

Subscribers: llvm-commits

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

llvm-svn: 313875

7 years ago[TableGen] Tidy up CodeGenRegisters
Javed Absar [Thu, 21 Sep 2017 10:51:47 +0000 (10:51 +0000)]
[TableGen] Tidy up CodeGenRegisters

Replacing range loops.

Reviewed by: @MatzeB
Differential Revision: https://reviews.llvm.org/D38091

llvm-svn: 313874

7 years ago[mips] Fix relocation record format and ELF header for N32 ABI
Simon Atanasyan [Thu, 21 Sep 2017 10:44:26 +0000 (10:44 +0000)]
[mips] Fix relocation record format and ELF header for N32 ABI

The N32 ABI uses RELA relocation format, do not use 3-in-1 relocation's
encoding, and uses ELFCLASS32. This change passes the `IsN32` flag
to the `MCAsmBackend` to distinguish usage of N32 ABI.

We still do not handle some cases like providing the `-target-abi=o32`
command line option with the `mips64` target triple. That's why
elf_header.s contains some "FIXME" strings. This case will be fixed in
a separate patch.

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

llvm-svn: 313873

7 years ago[dsymutil] Don't resolve DIE reference to NULL DIE.
Jonas Devlieghere [Thu, 21 Sep 2017 10:28:33 +0000 (10:28 +0000)]
[dsymutil] Don't resolve DIE reference to NULL DIE.

This patch prevents dsymutil from resolving a reference to a NULL DIE
when a bogus reference happens to be coincidentally referencing a NULL
DIE. Now this is detected as an invalid reference and a warning is
printed.

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

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

llvm-svn: 313872

7 years ago[XRay][compiler-rt] Remove non-trivial globals from xray_log_interface.cc
Dean Michael Berris [Thu, 21 Sep 2017 10:16:56 +0000 (10:16 +0000)]
[XRay][compiler-rt] Remove non-trivial globals from xray_log_interface.cc

Summary:
Remove dependency on std::unique_ptr<...> for the global representing
the installed XRay implementation.

Reviewers: dblaikie, kpw, pelikan

Subscribers: llvm-commits

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

llvm-svn: 313871

7 years agoFixed reverted commit rL312318
Strahinja Petrovic [Thu, 21 Sep 2017 10:04:02 +0000 (10:04 +0000)]
Fixed reverted commit rL312318

This patch contains fix for reverted commit
rL312318 which was causing failure due to use
of unchecked dyn_cast to CIInit.

Patch by: Nikola Prica.

llvm-svn: 313870

7 years ago[X86] Adding a testpoint for fast-math flags propagation.
Jatin Bhateja [Thu, 21 Sep 2017 09:53:21 +0000 (09:53 +0000)]
[X86] Adding a testpoint for fast-math flags propagation.

Reviewers: jbhateja

Reviewed By: jbhateja

Subscribers: llvm-commits

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

llvm-svn: 313869

7 years ago[yaml2obj] - Don't crash on one more invalid document.
George Rimar [Thu, 21 Sep 2017 08:25:59 +0000 (08:25 +0000)]
[yaml2obj] - Don't crash on one more invalid document.

This fixes one more crash I faced.
Testcase contains minimal reduced case.

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

llvm-svn: 313868

7 years ago[analyzer] Fix an assertion fail in VirtualCallChecker
Gabor Horvath [Thu, 21 Sep 2017 08:18:59 +0000 (08:18 +0000)]
[analyzer] Fix an assertion fail in VirtualCallChecker

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

llvm-svn: 313866

7 years agoAMDGPU: Add option to stress calls
Matt Arsenault [Thu, 21 Sep 2017 07:00:48 +0000 (07:00 +0000)]
AMDGPU: Add option to stress calls

This inverts the behavior of the AlwaysInline pass to mark
every function not already marked alwaysinline as noinline.

llvm-svn: 313865

7 years ago[MIPS] Restore checking of the disassembler output. NFC
Simon Atanasyan [Thu, 21 Sep 2017 04:55:27 +0000 (04:55 +0000)]
[MIPS] Restore checking of the disassembler output. NFC

llvm-svn: 313864

7 years ago[X86] Remove execute permissions from a couple files.
Craig Topper [Thu, 21 Sep 2017 04:55:08 +0000 (04:55 +0000)]
[X86] Remove execute permissions from a couple files.

llvm-svn: 313863

7 years ago[X86] Remove windows line endings.
Craig Topper [Thu, 21 Sep 2017 04:55:07 +0000 (04:55 +0000)]
[X86] Remove windows line endings.

llvm-svn: 313862

7 years ago[X86] Remove unused tablegen class.
Craig Topper [Thu, 21 Sep 2017 04:55:06 +0000 (04:55 +0000)]
[X86] Remove unused tablegen class.

llvm-svn: 313861

7 years ago[TableGen] Use CHAR_BIT instead of hardcoded 8 with sizeof. NFC
Craig Topper [Thu, 21 Sep 2017 04:55:04 +0000 (04:55 +0000)]
[TableGen] Use CHAR_BIT instead of hardcoded 8 with sizeof. NFC

llvm-svn: 313860

7 years ago[TableGen] Include StringMap.h instead of StringSet.h since that's the data structure...
Craig Topper [Thu, 21 Sep 2017 04:55:03 +0000 (04:55 +0000)]
[TableGen] Include StringMap.h instead of StringSet.h since that's the data structure we use.

llvm-svn: 313859

7 years agoRevert r313782 "[TableGen] Add a DenseMapInfo for MachineValueType."
Craig Topper [Thu, 21 Sep 2017 04:54:59 +0000 (04:54 +0000)]
Revert r313782 "[TableGen] Add a DenseMapInfo for MachineValueType."

We aren't making a DenseSet/DenseMap of MVT anywhere. This was added due to an earlier revision of D37957.

llvm-svn: 313858

7 years agoRevert "Re-enable "[IRCE] Identify loops with latch comparison against current IV...
Serguei Katkov [Thu, 21 Sep 2017 04:50:41 +0000 (04:50 +0000)]
Revert "Re-enable "[IRCE] Identify loops with latch comparison against current IV value""

Revert the patch causing the functional failures.
The patch owner is notified with test cases which fail.
Test case has been provided to Maxim offline.

llvm-svn: 313857

7 years agoRevert "Give external linkage and mangling to lambdas inside inline variables and...
Vitaly Buka [Thu, 21 Sep 2017 02:51:56 +0000 (02:51 +0000)]
Revert "Give external linkage and mangling to lambdas inside inline variables and variable templates."

To fix: runtime error: load of value 15, which is not a valid value for type 'clang::LVComputationKind'

This reverts commit r313827.

llvm-svn: 313856

7 years ago[lit/Win] Check if a path was found before attempting to use it.
David L. Jones [Thu, 21 Sep 2017 01:26:16 +0000 (01:26 +0000)]
[lit/Win] Check if a path was found before attempting to use it.

Summary:
This appears to break some bots, when getToolsPath fails to find some or
all of the tools (for example, an incomplete GnuWin32 installation).

Reviewers: zturner, modocache

Subscribers: sanjoy, llvm-commits

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

llvm-svn: 313854

7 years ago[llvm-cov] Improve error messaging for function mismatches
Vedant Kumar [Thu, 21 Sep 2017 01:11:30 +0000 (01:11 +0000)]
[llvm-cov] Improve error messaging for function mismatches

Passing "-dump" to llvm-cov will now print more detailed information
about function hash and counter mismatches. This should make it easier
to debug *.profdata files which contain incorrect records, and to debug
other scenarios where coverage goes missing due to mismatch issues.

llvm-svn: 313853

7 years agoAMDGPU: Fix crash on immediate operand
Matt Arsenault [Thu, 21 Sep 2017 00:45:59 +0000 (00:45 +0000)]
AMDGPU: Fix crash on immediate operand

We can have a v_mac with an immediate src0.
We can still fold if it's an inline immediate,
otherwise it already uses the constant bus.

llvm-svn: 313852

7 years ago[ubsan] Split ubsan_init_standalone
Vitaly Buka [Thu, 21 Sep 2017 00:35:22 +0000 (00:35 +0000)]
[ubsan] Split ubsan_init_standalone

Summary:
On Linux we may need preinit_array in static lib and
ubsan_standalone_initializer in shared lib.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits, mgorny

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

llvm-svn: 313851

7 years ago[AArch64] Properly check alignment for AARCH64_LD_PREL_LO19.
Davide Italiano [Thu, 21 Sep 2017 00:26:28 +0000 (00:26 +0000)]
[AArch64] Properly check alignment for AARCH64_LD_PREL_LO19.

Follow-up suggested by Peter Smith.

llvm-svn: 313850

7 years ago[lit] Make lit support config files with .py extension.
Zachary Turner [Thu, 21 Sep 2017 00:24:52 +0000 (00:24 +0000)]
[lit] Make lit support config files with .py extension.

Many editors and Python-related diagnostics tools such as
debuggers break or fail in mysterious ways when python files
don't end in .py.  This is especially true on Windows, but
still exists on other platforms.  I don't want to be too heavy
handed in changing everything across the board, but I do want
to at least *allow* lit configs to have .py extensions.  This
patch makes the discovery process first look for a config file
with a .py extension, and if one is not found, then looks for
a config file using the old method.  So for existing users, there
should be no functional change.

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

llvm-svn: 313849

7 years ago[X86] Replace a condition that can never be true with an assert.
Craig Topper [Thu, 21 Sep 2017 00:18:48 +0000 (00:18 +0000)]
[X86] Replace a condition that can never be true with an assert.

llvm-svn: 313848

7 years ago[SelectionDAG] Replace a flag that can never be true with an assert.
Craig Topper [Thu, 21 Sep 2017 00:18:46 +0000 (00:18 +0000)]
[SelectionDAG] Replace a flag that can never be true with an assert.

llvm-svn: 313847

7 years ago[AArch64] Include test for out of range LD_PREL_LO19.
Davide Italiano [Thu, 21 Sep 2017 00:16:29 +0000 (00:16 +0000)]
[AArch64] Include test for out of range LD_PREL_LO19.

llvm-svn: 313846

7 years ago[asan] Remove trailing spaces
Vitaly Buka [Thu, 21 Sep 2017 00:14:17 +0000 (00:14 +0000)]
[asan] Remove trailing spaces

llvm-svn: 313845

7 years ago[asan] Remove "COLLISION" workaround for datarace in asan
Vitaly Buka [Thu, 21 Sep 2017 00:11:30 +0000 (00:11 +0000)]
[asan] Remove "COLLISION" workaround for datarace in asan

"nested bug in the same thread" is not expected in case like this and was caused
by https://github.com/google/sanitizers/issues/858

llvm-svn: 313844

7 years ago[asan] Remove "rm -f" in tests where it was needed only because of >>
Vitaly Buka [Thu, 21 Sep 2017 00:06:08 +0000 (00:06 +0000)]
[asan] Remove "rm -f" in tests where it was needed only because of >>

llvm-svn: 313843

7 years agoCheck whether IslAstInfo and DependenceInfo were computed for the same Scop.
Michael Kruse [Thu, 21 Sep 2017 00:01:13 +0000 (00:01 +0000)]
Check whether IslAstInfo and DependenceInfo were computed for the same Scop.

Since -polly-codegen reports itself to preserve DependenceInfo and IslAstInfo,
we might get those analysis that were computed by a different ScopInfo for a
different Scop structure. This would be unfortunate because DependenceInfo and
IslAstInfo hold references to resources allocated by
ScopInfo/ScopBuilder/Scop (e.g. isl_id). If -polly-codegen and
DependenceInfo/IslAstInfo do not agree on which Scop to use, unpredictable
things can happen.

When the ScopInfo/Scop object is freed, there is a high probability that the
new ScopInfo/Scop object will be created at the same heap position with the
same address. Comparing whether the Scop or ScopInfo address is the expected
therefore is unreliable.

Instead, we compare the address of the isl_ctx object. Both, DependenceInfo
and IslAstInfo must hold a reference to the isl_ctx object to ensure it is
not freed before the destruction of those analyses which might happen after
the destruction of the Scop/ScopInfo they refer to.  Hence, the isl_ctx
will not be freed and its address not reused as long there is a
DependenceInfo or IslAstInfo around.

This fixes llvm.org/PR34441

llvm-svn: 313842

7 years ago[AArch64] Implement R_AARCH64_ LD_PREL_LO19.
Davide Italiano [Wed, 20 Sep 2017 23:49:50 +0000 (23:49 +0000)]
[AArch64] Implement R_AARCH64_ LD_PREL_LO19.

Fixes PR34660.

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

llvm-svn: 313841

7 years ago[InstCombine] Teach getDemandedBitsLHSMask to handle constant splat vectors
Craig Topper [Wed, 20 Sep 2017 23:48:58 +0000 (23:48 +0000)]
[InstCombine] Teach getDemandedBitsLHSMask to handle constant splat vectors

This replaces a ConstantInt dyn_cast with m_APInt

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

llvm-svn: 313840

7 years ago[SelectionDAG] Use APInt::getActivebits instead of Bitwidth - leading zeros.
Craig Topper [Wed, 20 Sep 2017 23:48:56 +0000 (23:48 +0000)]
[SelectionDAG] Use APInt::getActivebits instead of Bitwidth - leading zeros.

llvm-svn: 313839

7 years ago[WebAssembly] Weak symbols should be defined in SF_Global
Sam Clegg [Wed, 20 Sep 2017 23:39:44 +0000 (23:39 +0000)]
[WebAssembly] Weak symbols should be defined in SF_Global

Summary:
This manifested itself in lld since it meant that weak
symbols were not appearing in archive symbol tables.

Subscribers: jfb, dschuff, jgravelle-google, aheejin

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

llvm-svn: 313838

7 years agotypo
Adrian Prantl [Wed, 20 Sep 2017 23:29:47 +0000 (23:29 +0000)]
typo

llvm-svn: 313837

7 years agollvm-dwarfdump: move -eh-frame into the right section in the help output.
Adrian Prantl [Wed, 20 Sep 2017 23:29:31 +0000 (23:29 +0000)]
llvm-dwarfdump: move -eh-frame into the right section in the help output.

llvm-svn: 313836

7 years ago[asan] Fix nested error detection
Vitaly Buka [Wed, 20 Sep 2017 23:27:38 +0000 (23:27 +0000)]
[asan] Fix nested error detection

Summary: Fixes https://github.com/google/sanitizers/issues/858

Reviewers: eugenis, dvyukov

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 313835

7 years ago[llvm-readobj] Fix 'Teach readobj to dump .res files', pt 3.
Marek Sokolowski [Wed, 20 Sep 2017 23:26:05 +0000 (23:26 +0000)]
[llvm-readobj] Fix 'Teach readobj to dump .res files', pt 3.

Fix (r313790) missing ulittle{}_t error on some buildbots.

llvm-svn: 313834

7 years ago[llvm-readobj] Fix 'Teach readobj to dump .res files', pt 2.
Marek Sokolowski [Wed, 20 Sep 2017 23:07:39 +0000 (23:07 +0000)]
[llvm-readobj] Fix 'Teach readobj to dump .res files', pt 2.

Another fix-up for r313790. Big-endian hosts swapped byte order in
UTF16 words.

llvm-svn: 313833

7 years agoInclude thin --whole-archive members in --reproduce.
Rafael Espindola [Wed, 20 Sep 2017 22:59:50 +0000 (22:59 +0000)]
Include thin --whole-archive members in --reproduce.

We were only including the thin archive members used via a lazy symbol
before.

llvm-svn: 313832

7 years ago[MSan] Disable sanitization for __sanitizer_dtor_callback.
Matt Morehouse [Wed, 20 Sep 2017 22:53:08 +0000 (22:53 +0000)]
[MSan] Disable sanitization for __sanitizer_dtor_callback.

Summary:
Eliminate unnecessary instrumentation at __sanitizer_dtor_callback
call sites.  Fixes https://github.com/google/sanitizers/issues/861.

Reviewers: eugenis, kcc

Reviewed By: eugenis

Subscribers: vitalybuka, llvm-commits, cfe-commits, hiraditya

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

llvm-svn: 313831

7 years agoRemove references to response file argument in CommandLine.rst
Dave Lee [Wed, 20 Sep 2017 22:41:34 +0000 (22:41 +0000)]
Remove references to response file argument in CommandLine.rst

Summary:
The documentation refers to a boolean that controls whether response files are
handled, but this is incorrect. Since r165535, response files are always
enabled.

Reviewers: compnerd, rafael

Reviewed By: compnerd

Subscribers: llvm-commits

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

llvm-svn: 313830

7 years ago[SimplifyCFG] don't create a no-op subtract
Sanjay Patel [Wed, 20 Sep 2017 22:31:35 +0000 (22:31 +0000)]
[SimplifyCFG] don't create a no-op subtract

I noticed this inefficiency while investigating PR34603:
https://bugs.llvm.org/show_bug.cgi?id=34603

This fix will likely push another bug (we don't maintain state of 'LateSimplifyCFG')
into hiding, but I'll try to clean that up with a follow-up patch anyway.

llvm-svn: 313829

7 years ago[MS Compat]Allow __interfaces to have properties.
Erich Keane [Wed, 20 Sep 2017 22:28:24 +0000 (22:28 +0000)]
[MS Compat]Allow __interfaces to have properties.

__interface types are allowed in MSVC to have "property" data members
(marked with declspec property). This patch alters Sema to allow property
data members.

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

llvm-svn: 313828

7 years agoGive external linkage and mangling to lambdas inside inline variables and variable...
Richard Smith [Wed, 20 Sep 2017 22:17:55 +0000 (22:17 +0000)]
Give external linkage and mangling to lambdas inside inline variables and variable templates.

This implements the proposed approach in https://github.com/itanium-cxx-abi/cxx-abi/issues/33

llvm-svn: 313827

7 years agoCommit local changes that missed llvm.dbg.addr
Reid Kleckner [Wed, 20 Sep 2017 21:56:21 +0000 (21:56 +0000)]
Commit local changes that missed llvm.dbg.addr

llvm-svn: 313826

7 years ago[IR] Add llvm.dbg.addr, a control-dependent version of llvm.dbg.declare
Reid Kleckner [Wed, 20 Sep 2017 21:52:33 +0000 (21:52 +0000)]
[IR] Add llvm.dbg.addr, a control-dependent version of llvm.dbg.declare

Summary:
This implements the design discussed on llvm-dev for better tracking of
variables that live in memory through optimizations:
  http://lists.llvm.org/pipermail/llvm-dev/2017-September/117222.html

This is tracked as PR34136

llvm.dbg.addr is intended to be produced and used in almost precisely
the same way as llvm.dbg.declare is today, with the exception that it is
control-dependent. That means that dbg.addr should always have a
position in the instruction stream, and it will allow passes that
optimize memory operations on local variables to insert llvm.dbg.value
calls to reflect deleted stores. See SourceLevelDebugging.rst for more
details.

The main drawback to generating DBG_VALUE machine instrs is that they
usually cause LLVM to emit a location list for DW_AT_location. The next
step will be to teach DwarfDebug.cpp how to recognize more DBG_VALUE
ranges as not needing a location list, and possibly start setting
DW_AT_start_offset for variables whose lifetimes begin mid-scope.

Reviewers: aprantl, dblaikie, probinson

Subscribers: eraman, hiraditya, llvm-commits

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

llvm-svn: 313825

7 years ago[docs] llvm-cov: Document -show-instantiation-summary
Vedant Kumar [Wed, 20 Sep 2017 21:52:09 +0000 (21:52 +0000)]
[docs] llvm-cov: Document -show-instantiation-summary

llvm-svn: 313824

7 years ago[ARM] Fix some Clang-tidy modernize-use-using and Include What You Use warnings;...
Eugene Zelenko [Wed, 20 Sep 2017 21:35:51 +0000 (21:35 +0000)]
[ARM] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 313823

7 years agoRevert "Revert "ExecutionEngine: add R_AARCH64_ABS{16,32}""
Saleem Abdulrasool [Wed, 20 Sep 2017 21:32:44 +0000 (21:32 +0000)]
Revert "Revert "ExecutionEngine: add R_AARCH64_ABS{16,32}""

This reverts commit SVN r313668.  The original test case attempted to
write a pointer value into 16-bits, although the value may exceed the
range representable in 16-bits.  Ensure that the symbol is located in
the address space such that its absolute address is representable in
16-bits.  This should fix the assertion failure that was seen on the
Windows hosts.

llvm-svn: 313822

7 years ago[SimplifyCFG] auto-generate full checks; NFC
Sanjay Patel [Wed, 20 Sep 2017 21:25:02 +0000 (21:25 +0000)]
[SimplifyCFG] auto-generate full checks; NFC

llvm-svn: 313821

7 years ago[NVPTX] Implemented shfl.sync instruction and supporting intrinsics/builtins.
Artem Belevich [Wed, 20 Sep 2017 21:23:07 +0000 (21:23 +0000)]
[NVPTX] Implemented shfl.sync instruction and supporting intrinsics/builtins.

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

llvm-svn: 313820

7 years ago[InstCombine] Handle (X & C2) < C1 --> (X & C2) == 0
Craig Topper [Wed, 20 Sep 2017 21:18:17 +0000 (21:18 +0000)]
[InstCombine] Handle (X & C2) < C1 --> (X & C2) == 0

We already did (X & C2) > C1 --> (X & C2) != 0, if any bit set in (X & C2) will produce a result greater than C1. But there is an equivalent inverse condition with <= C1 (which will be canonicalized to < C1+1)

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

llvm-svn: 313819

7 years ago[InstCombine] Pre-commit test cases for D38065.
Craig Topper [Wed, 20 Sep 2017 21:18:12 +0000 (21:18 +0000)]
[InstCombine] Pre-commit test cases for D38065.

llvm-svn: 313818

7 years ago[WebAssembly] Add support for local symbol bindings
Sam Clegg [Wed, 20 Sep 2017 21:17:04 +0000 (21:17 +0000)]
[WebAssembly] Add support for local symbol bindings

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

llvm-svn: 313817