platform/upstream/llvm.git
7 years ago[X86][AVX512] Add 512-bit vector bitreverse costs + tests
Simon Pilgrim [Wed, 17 May 2017 19:20:20 +0000 (19:20 +0000)]
[X86][AVX512] Add 512-bit vector bitreverse costs + tests

llvm-svn: 303283

7 years agoAdd back a dummy --use-processes.
Rafael Espindola [Wed, 17 May 2017 18:55:01 +0000 (18:55 +0000)]
Add back a dummy --use-processes.

Some bots are using it.

llvm-svn: 303282

7 years agoMake next/prev/advance/distance operations on iterators be constexpr. I missed this...
Marshall Clow [Wed, 17 May 2017 18:51:36 +0000 (18:51 +0000)]
Make next/prev/advance/distance operations on iterators be constexpr. I missed this when I implemented the rest of P0031R0

llvm-svn: 303281

7 years agoAlways use the multiprocess module.
Rafael Espindola [Wed, 17 May 2017 18:20:01 +0000 (18:20 +0000)]
Always use the multiprocess module.

This seems to work on freebsd and openbsd these days.

llvm-svn: 303280

7 years agoRe-land r303274: "[CrashRecovery] Use SEH __try instead of VEH when available"
Reid Kleckner [Wed, 17 May 2017 18:16:17 +0000 (18:16 +0000)]
Re-land r303274: "[CrashRecovery] Use SEH __try instead of VEH when available"

We have to check gCrashRecoveryEnabled before using __try.

In other words, SEH works too well and we ended up recovering from
crashes in implicit module builds that we weren't supposed to. Only
libclang is supposed to enable CrashRecoveryContext to allow implicit
module builds to crash.

llvm-svn: 303279

7 years agoFix error string set in AddName to take a StringRef.
Ted Woodward [Wed, 17 May 2017 17:48:55 +0000 (17:48 +0000)]
Fix error string set in AddName to take a StringRef.

llvm-svn: 303278

7 years ago[GISel]: Fix undefined behavior in IRTranslator
Aditya Nandakumar [Wed, 17 May 2017 17:41:55 +0000 (17:41 +0000)]
[GISel]: Fix undefined behavior in IRTranslator

Make sure IRTranslator->MachineIRBuilder->DebugLoc doesn't
outlive the DILocation. Clear it at the end of
IRTranslator::runOnMachineFunction

llvm-svn: 303277

7 years agoGenerate ubsan shared libraries.
Leo Li [Wed, 17 May 2017 17:17:41 +0000 (17:17 +0000)]
Generate ubsan shared libraries.

Summary: Those libraries are required by aosp (https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+/master/Android.mk). Currenly the shared libraries are generated by aosp Makefile system. We are looking forward to using cmake to generate them.

Reviewers: llvm-commits, vsk

Reviewed By: vsk

Subscribers: filcab, vsk, srhines, kubamracek, mgorny, krytarowski

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

llvm-svn: 303276

7 years agoRevert "[CrashRecovery] Use SEH __try instead of VEH when available"
Reid Kleckner [Wed, 17 May 2017 17:15:00 +0000 (17:15 +0000)]
Revert "[CrashRecovery] Use SEH __try instead of VEH when available"

This reverts commit r303274, it appears to break some clang tests.

llvm-svn: 303275

7 years ago[CrashRecovery] Use SEH __try instead of VEH when available
Reid Kleckner [Wed, 17 May 2017 17:02:16 +0000 (17:02 +0000)]
[CrashRecovery] Use SEH __try instead of VEH when available

Summary:
It avoids problems when other libraries raise exceptions. In particular,
OutputDebugString raises an exception that the debugger is supposed to
catch and suppress. VEH kicks in first right now, and that is entirely
incorrect.

Unfortunately, GCC does not support SEH, so I've kept the old buggy VEH
codepath around. We could fix it with SetUnhandledExceptionFilter, but
that is not per-thread, so a well-behaved library shouldn't set it.

Reviewers: zturner

Subscribers: llvm-commits, mgorny

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

llvm-svn: 303274

7 years agoInclude setjmp.h unconditionally in asan_test_utils.h
Hans Wennborg [Wed, 17 May 2017 16:44:08 +0000 (16:44 +0000)]
Include setjmp.h unconditionally in asan_test_utils.h

It's used in asan_test.cc also on Windows, and my build was failing
with:

C:/src/llvm/projects/compiler-rt/lib/asan/tests/asan_test.cc:549:28: error: unknown type name 'jmp_buf'
NOINLINE void LongJmpFunc1(jmp_buf buf) {
                           ^
C:/src/llvm/projects/compiler-rt/lib/asan/tests/asan_test.cc:569:10: error: unknown type name 'jmp_buf'
  static jmp_buf buf;
         ^

I couldn't find what changed to make this not work anymore, but this should fix
it.

llvm-svn: 303273

7 years agoWorkaround for incorrect Win32 header on GCC.
Zachary Turner [Wed, 17 May 2017 16:39:33 +0000 (16:39 +0000)]
Workaround for incorrect Win32 header on GCC.

llvm-svn: 303272

7 years ago[CodeView] Simplify the use of visiting type records & streams.
Zachary Turner [Wed, 17 May 2017 16:39:06 +0000 (16:39 +0000)]
[CodeView] Simplify the use of visiting type records & streams.

There is often a lot of boilerplate code required to visit a type
record or type stream.  The #1 use case is that you have a sequence
of bytes that represent one or more records, and you want to
deserialize each one, switch on it, and call a callback with the
deserialized record that the user can examine.  Currently this
requires at least 6 lines of code:

  codeview::TypeVisitorCallbackPipeline Pipeline;
  Pipeline.addCallbackToPipeline(Deserializer);
  Pipeline.addCallbackToPipeline(MyCallbacks);

  codeview::CVTypeVisitor Visitor(Pipeline);
  consumeError(Visitor.visitTypeRecord(Record));

With this patch, it becomes one line of code:

  consumeError(codeview::visitTypeRecord(Record, MyCallbacks));

This is done by having the deserialization happen internally inside
of the visitTypeRecord function.  Since this is occasionally not
desirable, the function provides a 3rd parameter that can be used
to change this behavior.

Hopefully this can significantly reduce the barrier to entry
to using the visitation infrastructure.

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

llvm-svn: 303271

7 years agoRevert r303225 "Garbage collect dllimported symbols."
Hans Wennborg [Wed, 17 May 2017 16:22:03 +0000 (16:22 +0000)]
Revert r303225 "Garbage collect dllimported symbols."

and follow-up r303226 "Fix Windows buildbots."

This broke the sanitizer-windows buildbot.

> Previously, the garbage collector (enabled by default or by explicitly
> passing /opt:ref) did not kill dllimported symbols. As a result,
> dllimported symbols could be added to resulting executables' dllimport
> list even if no one was actually using them.
>
> This patch implements dllexported symbol garbage collection. Just like
> COMDAT sections, dllimported symbols now have Live bits to manage their
> liveness, and MarkLive marks reachable dllimported symbols.
>
> Fixes https://bugs.llvm.org/show_bug.cgi?id=32950
>
> Reviewers: pcc
>
> Subscribers: llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D33264

llvm-svn: 303270

7 years ago[BitVector] Add find_[first,last]_[set,unset]_in.
Zachary Turner [Wed, 17 May 2017 15:49:45 +0000 (15:49 +0000)]
[BitVector] Add find_[first,last]_[set,unset]_in.

A lot of code is duplicated between the first_last and the
next / prev methods.  All of this code can be shared if they
are implemented in terms of find_first_in(Begin, End) etc,
in which case find_first = find_first_in(0, Size) and find_next
is find_first_in(Prev+1, Size), with similar reductions for
the other methods.

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

llvm-svn: 303269

7 years agoMark the copy constructor and move
Marshall Clow [Wed, 17 May 2017 15:30:01 +0000 (15:30 +0000)]
Mark the copy constructor and move
constructor to be constexpr. This only works when the contained type has a constexpr copy/move ctor.

llvm-svn: 303268

7 years agoclang-cl: Fix path-based MSVC version detection
Hans Wennborg [Wed, 17 May 2017 15:27:44 +0000 (15:27 +0000)]
clang-cl: Fix path-based MSVC version detection

The code wasn't taking the architecture-specific subdirectory into
account.

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

llvm-svn: 303267

7 years agoRevert "Implement tls scanning for darwin LSan"
Francis Ricci [Wed, 17 May 2017 15:25:41 +0000 (15:25 +0000)]
Revert "Implement tls scanning for darwin LSan"

This reverts r303262, due to TSan buildbot breakages.

llvm-svn: 303266

7 years ago[Frontend] Remove unused TemporaryFiles
Krasimir Georgiev [Wed, 17 May 2017 14:51:44 +0000 (14:51 +0000)]
[Frontend] Remove unused TemporaryFiles

Summary:
OnDiskData.TemporaryFiles is filled only by ASTUnit::addTemporaryFile, which is
dead. Also these files are used nowhere in the frontend nor in libclang.

Reviewers: bkramer, ilya-biryukov

Reviewed By: bkramer, ilya-biryukov

Subscribers: cfe-commits

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

llvm-svn: 303265

7 years agoChange getChecksFilter() interface to hide implementation details.
Alexander Kornienko [Wed, 17 May 2017 14:39:47 +0000 (14:39 +0000)]
Change getChecksFilter() interface to hide implementation details.

llvm-svn: 303264

7 years ago[clang-tidy] Replace matchesName with hasName where no regex is needed
Alexander Kornienko [Wed, 17 May 2017 14:39:39 +0000 (14:39 +0000)]
[clang-tidy] Replace matchesName with hasName where no regex is needed

llvm-svn: 303263

7 years agoImplement tls scanning for darwin LSan
Francis Ricci [Wed, 17 May 2017 14:35:17 +0000 (14:35 +0000)]
Implement tls scanning for darwin LSan

Summary:
This required for any users who call exit() after creating
thread-specific data, as tls destructors are only called when
pthread_exit() or pthread_cancel() are used. This should also
match tls behavior on linux.

Getting the base address of the tls section is straightforward,
as it's stored as a section offset in %gs. The size is a bit trickier
to work out, as there doesn't appear to be any official documentation
or source code referring to it. The size used in this patch was determined
by taking the difference between the base address and the address of the
subsequent memory region returned by vm_region_recurse_64, which was
1024 * sizeof(uptr) on all threads except the main thread, where it was
larger. Since the section must be the same size on all of the threads,
1024 * sizeof(uptr) seemed to be a reasonable size to use, barring
a more programtic way to get the size.

1024 seems like a reasonable number, given that PTHREAD_KEYS_MAX
is 512 on darwin, so pthread keys will fit inside the region while
leaving space for other tls data. A larger size would overflow the
memory region returned by vm_region_recurse_64, and a smaller size
wouldn't leave room for all the pthread keys. In addition, the
stress test added here passes, which means that we are scanning at
least the full set of possible pthread keys, and probably
the full tls section.

Reviewers: alekseyshl, kubamracek

Subscribers: krytarowski, llvm-commits

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

llvm-svn: 303262

7 years ago[InstCombine] add isCanonicalPredicate() helper function and use it; NFCI
Sanjay Patel [Wed, 17 May 2017 14:21:19 +0000 (14:21 +0000)]
[InstCombine] add isCanonicalPredicate() helper function and use it; NFCI

There should be a slight efficiency improvement from handling icmp/fcmp with one matcher and reducing duplicated code.

The larger motivation is that there are questions about how predicate canonicalization is handled, and the refactoring
should make it easier if we want to change any of that behavior.

1. As noted in the code comment, we've chosen 3 of the 16 FCMP preds as not canonical. Why those 3? It goes back to
   rL32751 from what I can tell, but I'm not sure if there's a justification for that rule.
2. We currently do not canonicalize integer select conditions. Should we use the same rule that applies to branches
   for selects?
3. We currently do canonicalize some FP select conditions, and those rules would conflict with the rule shown here.
   Should one or both be changed?

No-functional-change-intended, but adding tests anyway because there's no coverage for most of the predicates.

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

llvm-svn: 303261

7 years agoRecommit "[include-fixer] Don't throw exception when parsing unknown ar… …guments...
Haojian Wu [Wed, 17 May 2017 14:13:59 +0000 (14:13 +0000)]
Recommit "[include-fixer] Don't throw exception when parsing unknown ar… …guments in vim script."

Summary: To make it work in neovim.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits

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

llvm-svn: 303260

7 years ago[globalisel][tablegen] Import rules containing intrinsic_wo_chain.
Daniel Sanders [Wed, 17 May 2017 13:39:49 +0000 (13:39 +0000)]
[globalisel][tablegen] Import rules containing intrinsic_wo_chain.

Summary:
As of this patch, 1018 out of 3938 rules are currently imported.

Depends on D32275

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

Reviewed By: qcolombet

Subscribers: dberris, igorb, llvm-commits

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

llvm-svn: 303259

7 years ago[x86] Update tests in psubus.ll; NFC
Sanjay Patel [Wed, 17 May 2017 13:39:16 +0000 (13:39 +0000)]
[x86] Update tests in psubus.ll; NFC

Remove unnecessary memops to minimize tests.

Patch by Yulia Koval!

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

llvm-svn: 303258

7 years ago[PPC] Properly update register save area offsets
Krzysztof Parzyszek [Wed, 17 May 2017 13:25:09 +0000 (13:25 +0000)]
[PPC] Properly update register save area offsets

The variables MinGPR/MinG8R were not updated properly when resetting the
offsets, which in the included testcase lead to saving the CR register
in the same location as R30.

This fixes another issue reported in PR26519.

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

llvm-svn: 303257

7 years ago[clang-tidy] A bit of refactoring of modernize-replace-auto-ptr. NFC
Alexander Kornienko [Wed, 17 May 2017 12:57:06 +0000 (12:57 +0000)]
[clang-tidy] A bit of refactoring of modernize-replace-auto-ptr. NFC

llvm-svn: 303256

7 years ago[GlobalISel][X86] Support add i64 in IA32.
Igor Breger [Wed, 17 May 2017 12:48:08 +0000 (12:48 +0000)]
[GlobalISel][X86] Support add i64 in IA32.

Summary: support G_UADDE instruction selection.

Reviewers: zvi, guyblank

Reviewed By: guyblank

Subscribers: rovka, kristof.beyls, llvm-commits

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

llvm-svn: 303255

7 years ago[SystemZ] Modelling of costs of divisions with a constant power of 2.
Jonas Paulsson [Wed, 17 May 2017 12:46:26 +0000 (12:46 +0000)]
[SystemZ]  Modelling of costs of divisions with a constant power of 2.

Such divisions will eventually be implemented with shifts which should
be reflected in the cost function.

Review: Ulrich Weigand
llvm-svn: 303254

7 years ago[globalisel][tablegen] Require that all registers between instructions of a match...
Daniel Sanders [Wed, 17 May 2017 12:43:30 +0000 (12:43 +0000)]
[globalisel][tablegen] Require that all registers between instructions of a match are virtual.

Summary:
Without this, it's possible to encounter multiple defs for a register.

This is triggered by the current version of D32868 when applied to trunk.

Reviewers: qcolombet, ab, t.p.northover, rovka, kristof.beyls

Reviewed By: qcolombet

Subscribers: llvm-commits, igorb

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

llvm-svn: 303253

7 years agoReland r303247: [ARM] GlobalISel: Remove dead instruction selection code
Diana Picus [Wed, 17 May 2017 12:42:52 +0000 (12:42 +0000)]
Reland r303247: [ARM] GlobalISel: Remove dead instruction selection code

It only failed on llvm-clang-x86_64-expensive-checks-win, probably
because the TableGen stuff hasn't been regenerated.
Requires a clean build.

llvm-svn: 303252

7 years ago[DWARF] - Cleanup relocations proccessing.
George Rimar [Wed, 17 May 2017 12:10:51 +0000 (12:10 +0000)]
[DWARF] - Cleanup relocations proccessing.

RelocAddrMap was a pair of <width, address>, where width is relocation size (4/8/x, x < 8),
and width field was never used in code.

Relocations proccessing loop had checks for width field. Does not look like DWARF parser
should do that. There is probably no much sense to validate relocations during proccessing
them in parser.

Patch removes relocation's width relative code from DWARFContext.

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

llvm-svn: 303251

7 years agoConstify.
Vassil Vassilev [Wed, 17 May 2017 12:09:11 +0000 (12:09 +0000)]
Constify.

llvm-svn: 303250

7 years agoRevert "[ARM] GlobalISel: Remove dead instruction selection code"
Diana Picus [Wed, 17 May 2017 11:56:07 +0000 (11:56 +0000)]
Revert "[ARM] GlobalISel: Remove dead instruction selection code"

This reverts commit r303247 because the tests are failing on some bots.
Sorry!

llvm-svn: 303249

7 years agoMake TestConflictingSymbol run on non-darwin targets
Pavel Labath [Wed, 17 May 2017 11:47:44 +0000 (11:47 +0000)]
Make TestConflictingSymbol run on non-darwin targets

For remote targets we need to call registerSharedLibrariesWithTarget to
make sure they are installed alongside main executable. This also
required a small fixup in the the mentioned function as in this case
"One" was both a directory name and a library name template. I fixed it
to make sure it checks that the string refers to a file before it
assumed it was a full library path.

llvm-svn: 303248

7 years ago[ARM] GlobalISel: Remove dead instruction selection code
Diana Picus [Wed, 17 May 2017 11:39:26 +0000 (11:39 +0000)]
[ARM] GlobalISel: Remove dead instruction selection code

We can now generate code for selecting G_ADD, G_SUB and G_MUL. Remove
the hand-written versions.

llvm-svn: 303247

7 years ago[Lexer] Ensure that the token is not an annotation token when
Alex Lorenz [Wed, 17 May 2017 11:08:36 +0000 (11:08 +0000)]
[Lexer] Ensure that the token is not an annotation token when
retrieving the identifer info for an Objective-C keyword

This commit fixes an assertion that's triggered in getIdentifier when the token
is an annotation token.

rdar://32225463

llvm-svn: 303246

7 years ago[Sparc] Remove execute permissions from non-executable text files
Daniel Cederman [Wed, 17 May 2017 11:05:20 +0000 (11:05 +0000)]
[Sparc] Remove execute permissions from non-executable text files

Reviewers: jyknight, lero_chris, venkatra

Reviewed By: jyknight

Subscribers: llvm-commits

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

llvm-svn: 303245

7 years agoFixup r303240: Use llvm::to_string instead of std::to_string
Diana Picus [Wed, 17 May 2017 09:25:08 +0000 (09:25 +0000)]
Fixup r303240: Use llvm::to_string instead of std::to_string

It turns out some of the buildbots don't have std::to_string around,
even in this day and age...

llvm-svn: 303243

7 years agoRevert "[include-fixer] Don't throw exception when parsing unknown arguments in vim...
Benjamin Kramer [Wed, 17 May 2017 09:24:28 +0000 (09:24 +0000)]
Revert "[include-fixer] Don't throw exception when parsing unknown arguments in vim script."

This reverts commit r302934. It's wrong, edits the wrong file and was
committed without review.

llvm-svn: 303242

7 years ago[DebugInfo/DWARF] - Make comments to be in doxygen style. NFCi.
George Rimar [Wed, 17 May 2017 09:00:10 +0000 (09:00 +0000)]
[DebugInfo/DWARF] - Make comments to be in doxygen style. NFCi.

This changes "//" to "///" in llvm/DebugInfo/DWARF folder where appropriate
and also removes few trailing whitespaces.

llvm-svn: 303241

7 years ago[GlobalISel][TableGen] Fix handling of default operands
Diana Picus [Wed, 17 May 2017 08:57:28 +0000 (08:57 +0000)]
[GlobalISel][TableGen] Fix handling of default operands

When looping through a destination pattern's operands to decide how many
default operands we need to introduce, we used to count the "expanded"
number of operands. So if one default operand would be rendered as 2
values, we'd count it as 2 operands, when in fact it needs to count as
only 1 operand regardless of how many values it expands to.

This turns out to be a problem only in some very specific cases, e.g.
when we have one operand with multiple default values followed by more
operands with default values (see the new test). In such a situation
we'd stop looping before looking at all the operands, and then error out
assuming that we don't have enough default operands to make up the
shortfall.

At the moment this only affects ARM.

The patch removes the loop counting default operands entirely and
assumes that we'll have to introduce values for any default operand that
we find (i.e. we're assuming it cannot be given as a child at all). It
also extracts the code for adding renderers for default operands into a
helper method.

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

llvm-svn: 303240

7 years ago[RuntimeDyld] Fix debug section relocation (pr20457)
Pavel Labath [Wed, 17 May 2017 08:47:28 +0000 (08:47 +0000)]
[RuntimeDyld] Fix debug section relocation (pr20457)

Summary:
Debug info sections, (or non-SHF_ALLOC sections in general) should be
linked as if their load address was zero to emulate the behavior of the
static linker.

This bug was discovered because it was breaking lldb expression evaluation on
linux.

Reviewers: lhames

Subscribers: aprantl, eugene, clayborg, lldb-commits, llvm-commits

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

llvm-svn: 303239

7 years agoMake sure -optimize-regalloc=false is used correctly by user.
Jonas Paulsson [Wed, 17 May 2017 07:36:03 +0000 (07:36 +0000)]
Make sure -optimize-regalloc=false is used correctly by user.

Don't allow -optimize-regalloc=false with -regalloc given for anything other
than 'fast'. The other register allocators depend on the supporting passes
added by addOptimizedRegAlloc().

Reviewers: Quentin Colombet, Matthias Braun
https://reviews.llvm.org/D33181

llvm-svn: 303238

7 years ago[ELF] - Detemplate Thunk creation.
George Rimar [Wed, 17 May 2017 07:10:59 +0000 (07:10 +0000)]
[ELF] - Detemplate Thunk creation.

Nothing special here, just detemplates code that became possible
to detemplate after recent commits in a straghtforward way.

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

llvm-svn: 303237

7 years ago[APInt] Use getWord to shorten some code. NFC
Craig Topper [Wed, 17 May 2017 06:45:30 +0000 (06:45 +0000)]
[APInt] Use getWord to shorten some code. NFC

llvm-svn: 303236

7 years ago[SCEV] Always sort AddRecExprs from different loops by dominance
Max Kazantsev [Wed, 17 May 2017 04:09:14 +0000 (04:09 +0000)]
[SCEV] Always sort AddRecExprs from different loops by dominance

Sorting of AddRecExprs by loop nesting does not make sense since we only invoke
the CompareSCEVComplexity for AddRecExprs that are used by one SCEV. This
guarantees that there is always a dominance relationship between them. This
patch removes the sorting by nesting which is a dead code in current usage of
this function.

Reviewed By: sanjoy

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

llvm-svn: 303235

7 years ago[SCEV][NFC] Replace redundant dyn_cast with cast in getAddExpr
Max Kazantsev [Wed, 17 May 2017 03:58:42 +0000 (03:58 +0000)]
[SCEV][NFC] Replace redundant dyn_cast with cast in getAddExpr

Replace dyn_cast which is ensured by isa just one line above with cast.

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

llvm-svn: 303234

7 years ago[ODRHash] Support NestedNameSpecifier
Richard Trieu [Wed, 17 May 2017 03:23:35 +0000 (03:23 +0000)]
[ODRHash] Support NestedNameSpecifier

llvm-svn: 303233

7 years ago[coroutines] Handle spills before catchswitch
Gor Nishanov [Wed, 17 May 2017 03:09:22 +0000 (03:09 +0000)]
[coroutines] Handle spills before catchswitch

If we need to spill the result of the PHI instruction, we insert the spill after
all of the PHIs and EHPads, however, in a catchswitch block there is no
room to insert the spill. Make room by splitting away catchswitch into a separate
block.

Before the fix:

    catch.dispatch:
       %val = phi i32 [ 1, %if.then ], [ 2, %if.else ]
       %switch = catchswitch within none [label %catch] unwind label %cleanuppad

After:

    catch.dispatch:
       %val = phi i32 [ 1, %if.then ], [ 2, %if.else ]
       %tok = cleanuppad within none []
       ; spill goes here
       cleanupret from %tok unwind label %catch.dispatch.switch
    catch.dispatch.switch:
       %switch = catchswitch within none [label %catch] unwind label %cleanuppad

https://reviews.llvm.org/D31846

llvm-svn: 303232

7 years ago[ODRHash] Support more types in the ODR checker.
Richard Trieu [Wed, 17 May 2017 02:29:02 +0000 (02:29 +0000)]
[ODRHash] Support more types in the ODR checker.

Added support for TagType, TypeWithKeyword, and all children types.

llvm-svn: 303231

7 years ago[clang-tidy] Optimize misc-unused-parameters. NFCI
Alexander Kornienko [Wed, 17 May 2017 02:25:11 +0000 (02:25 +0000)]
[clang-tidy] Optimize misc-unused-parameters. NFCI

Don't traverse AST each time we need to find references to a certain function.
Traverse the AST once using RAV and cache the index of function references.

The speed up on a particular large file was about 1000x.

llvm-svn: 303230

7 years agoAdded LLVM_DUMP_METHOD attributes for MatchableInfo::dump(). Defined it only if dump...
Galina Kistanova [Wed, 17 May 2017 02:20:05 +0000 (02:20 +0000)]
Added LLVM_DUMP_METHOD attributes for MatchableInfo::dump(). Defined it only if dump is enabled.

llvm-svn: 303229

7 years ago(1) Fixed mismatch in intrinsics names in declarations and in doxygen comments.
Ekaterina Romanova [Wed, 17 May 2017 01:46:11 +0000 (01:46 +0000)]
(1) Fixed mismatch in intrinsics names in declarations and in doxygen comments.
(2) Removed uncessary anymore \c commands, since the same effect will be achived by <c> ... </c> sequence.

I got an OK from Eric Christopher to commit doxygen comments without prior code
review upstream.

llvm-svn: 303228

7 years agoBitVector: add iterators for set bits
Francis Visoiu Mistrih [Wed, 17 May 2017 01:07:53 +0000 (01:07 +0000)]
BitVector: add iterators for set bits

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

llvm-svn: 303227

7 years agoFix Windows buildbots.
Rui Ueyama [Wed, 17 May 2017 01:05:56 +0000 (01:05 +0000)]
Fix Windows buildbots.

llvm-svn: 303226

7 years agoGarbage collect dllimported symbols.
Rui Ueyama [Wed, 17 May 2017 00:35:50 +0000 (00:35 +0000)]
Garbage collect dllimported symbols.

Summary:
Previously, the garbage collector (enabled by default or by explicitly
passing /opt:ref) did not kill dllimported symbols. As a result,
dllimported symbols could be added to resulting executables' dllimport
list even if no one was actually using them.

This patch implements dllexported symbol garbage collection. Just like
COMDAT sections, dllimported symbols now have Live bits to manage their
liveness, and MarkLive marks reachable dllimported symbols.

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

Reviewers: pcc

Subscribers: llvm-commits

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

llvm-svn: 303225

7 years ago[modules] When creating a declaration, cache its owning module immediately
Richard Smith [Wed, 17 May 2017 00:24:14 +0000 (00:24 +0000)]
[modules] When creating a declaration, cache its owning module immediately
rather than waiting until it's queried.

Currently this is only applied to local submodule visibility mode, as we don't
yet allocate storage for the owning module in non-local-visibility modules
compilations.

This reinstates r302965, reverted in r303037, with a fix for the reported
crash, which occurred when reparenting a local declaration to be a child of
a hidden imported declaration (specifically during template instantiation).

llvm-svn: 303224

7 years ago[Expression parser] Look up module symbols before hunting globally
Sean Callanan [Tue, 16 May 2017 23:46:13 +0000 (23:46 +0000)]
[Expression parser] Look up module symbols before hunting globally

When it resolves symbol-only variables, the expression parser
currently looks only in the global module list. It should prefer
the current module.

I've fixed that behavior by making it search the current module
first, and only search globally if it finds nothing. I've also
added a test case.

After review, I moved the core of the lookup algorithm into
SymbolContext for use by other code that needs it.

Thanks to Greg Clayton and Pavel Labath for their help.

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

llvm-svn: 303223

7 years agoFix scope of namespaced DISubprograms when the function definition is out-of-line.
Adrian Prantl [Tue, 16 May 2017 23:46:10 +0000 (23:46 +0000)]
Fix scope of namespaced DISubprograms when the function definition is out-of-line.
This fixes a regression introduced in r302915.

Using the lexical decl context is not necessary here for what r302915
wast trying to achieve. Not canonicalizing the NamespaceDecl in
getOrCreateNamespace is suficient.

rdar://problem/29339538

llvm-svn: 303222

7 years ago[ADT] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC).
Eugene Zelenko [Tue, 16 May 2017 23:10:25 +0000 (23:10 +0000)]
[ADT] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC).

llvm-svn: 303221

7 years agoFix for compilers with older CRT header libraries.
Zachary Turner [Tue, 16 May 2017 22:59:34 +0000 (22:59 +0000)]
Fix for compilers with older CRT header libraries.

llvm-svn: 303220

7 years ago[Support] Ignore OutputDebugString exceptions in our crash recovery.
Zachary Turner [Tue, 16 May 2017 22:50:32 +0000 (22:50 +0000)]
[Support] Ignore OutputDebugString exceptions in our crash recovery.

Since we use AddVectoredExceptionHandler, we get notified of
every exception that gets raised by a program.  Sometimes these
are not necessarily errors though, and this can be especially
true when linking against a library that we have no control
over, and may raise an exception internally which it intends
to catch.

In particular, the Windows API OutputDebugString does exactly
this.  It raises an exception inside of a __try / __except,
giving the debugger a chance to handle the exception to print
the message to the debug console.

But this doesn't interoperate nicely with our vectored exception
handler, which just sees another exception and decides that we
need to terminate the program.

Add a special case for this so that we ignore ODS exceptions
and continue normally.

Note that a better fix is to simply not use vectored exception
handlers and use SEH instead, but given that MinGW doesn't support
SEH, this is the only solution for MinGW.

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

llvm-svn: 303219

7 years ago[IR] Prefer use_empty() to !hasNUsesOrMore(1) for clarity.
Davide Italiano [Tue, 16 May 2017 22:38:40 +0000 (22:38 +0000)]
[IR] Prefer use_empty() to !hasNUsesOrMore(1) for clarity.

llvm-svn: 303218

7 years ago[NewGVN] Re-enable test now that the nondeterminism has been fixed.
Davide Italiano [Tue, 16 May 2017 22:27:06 +0000 (22:27 +0000)]
[NewGVN] Re-enable test now that the nondeterminism has been fixed.

llvm-svn: 303217

7 years agollvm/test/Transforms/InstCombine/debuginfo-skip.ll REQUIRES +asserts.
NAKAMURA Takumi [Tue, 16 May 2017 22:19:56 +0000 (22:19 +0000)]
llvm/test/Transforms/InstCombine/debuginfo-skip.ll REQUIRES +asserts.

llvm-svn: 303216

7 years agoAdd test for FixedStreamArrayIterator::operator->
Adrian McCarthy [Tue, 16 May 2017 22:11:25 +0000 (22:11 +0000)]
Add test for FixedStreamArrayIterator::operator->

The operator-> implementation comes from iterator_facade_base, so it should
just work given that the iterator has a tested operator*.  But r302257 showed
that required careful handling of for the const qualifier.  This patch ensures
the fix in r302257 doesn't regress.

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

llvm-svn: 303215

7 years agoUpdate doxygen description of a method. NFC
Paul Robinson [Tue, 16 May 2017 21:53:30 +0000 (21:53 +0000)]
Update doxygen description of a method. NFC

llvm-svn: 303214

7 years ago[InstSimplify] add folds for constant mask of value shifted by constant
Sanjay Patel [Tue, 16 May 2017 21:51:04 +0000 (21:51 +0000)]
[InstSimplify] add folds for constant mask of value shifted by constant

We would eventually catch these via demanded bits and computing known bits in InstCombine,
but I think it's better to handle the simple cases as soon as possible as a matter of efficiency.

This fold allows further simplifications based on distributed ops transforms. eg:
  %a = lshr i8 %x, 7
  %b = or i8 %a, 2
  %c = and i8 %b, 1

InstSimplify can directly fold this now:
  %a = lshr i8 %x, 7

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

llvm-svn: 303213

7 years agoThe patch exclude a case from zero check skip in
Evgeny Stupachenko [Tue, 16 May 2017 21:44:59 +0000 (21:44 +0000)]
The patch exclude a case from zero check skip in
 CTLZ idiom recognition (r303102).

Summary:

The following case:
i = 1;
if(n)
  while (n >>= 1)
    i++;
use(i);

Was converted to:

i = 1;
if(n)
  i += builtin_ctlz(n >> 1, false);
use(i);

Which is not correct. The patch make it:

i = 1;
if(n)
  i += builtin_ctlz(n >> 1, true);
use(i);

From: Evgeny Stupachenko <evstupac@gmail.com>
llvm-svn: 303212

7 years agoRe-commit r302678, fixing PR33053.
Amara Emerson [Tue, 16 May 2017 21:29:22 +0000 (21:29 +0000)]
Re-commit r302678, fixing PR33053.

The issue was that the AArch64 TTI hook allowed unpacked integer cmp reductions
which didn't have a lowering.

llvm-svn: 303211

7 years ago[Inliner] Do not mix callsite and callee hotness based updates.
Easwaran Raman [Tue, 16 May 2017 21:18:09 +0000 (21:18 +0000)]
[Inliner] Do not mix callsite and callee hotness based updates.

Update threshold based on callee's hotness only when BFI is not available.
Otherwise use only callsite's hotness. This makes it easier to reason about
hotness related threshold updates.

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

llvm-svn: 303210

7 years ago[PPC] Add -ppc-asm-full-reg-names to atomic-2.ll. NFC.
Tim Shen [Tue, 16 May 2017 20:58:55 +0000 (20:58 +0000)]
[PPC] Add -ppc-asm-full-reg-names to atomic-2.ll. NFC.

Differential Revisions: https://reviews.llvm.org/D32763

llvm-svn: 303209

7 years agoTest for r303197
Matthias Braun [Tue, 16 May 2017 20:53:27 +0000 (20:53 +0000)]
Test for r303197

llvm-svn: 303208

7 years agobuiltins: fix guard __AEABI__ -> __ARM_EABI__
Saleem Abdulrasool [Tue, 16 May 2017 20:25:07 +0000 (20:25 +0000)]
builtins: fix guard __AEABI__ -> __ARM_EABI__

llvm-svn: 303207

7 years ago[libunwind] Fix executable stack directive on Linux.
Manoj Gupta [Tue, 16 May 2017 20:18:57 +0000 (20:18 +0000)]
[libunwind] Fix executable stack directive on Linux.

Summary:
Disable executable stack on Linux. Also remove redundant Android check
as it is covered by Android.

Reviewers: phosek, compnerd, rs, rmaprath, EricWF, krytarowski

Reviewed By: krytarowski

Subscribers: srhines, llvm-commits, krytarowski

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

llvm-svn: 303206

7 years ago[PPC] Lower load acquire/seq_cst trailing fence to cmp + bne + isync.
Tim Shen [Tue, 16 May 2017 20:18:06 +0000 (20:18 +0000)]
[PPC] Lower load acquire/seq_cst trailing fence to cmp + bne + isync.

Summary:
This fixes pr32392.

The lowering pipeline is:
llvm.ppc.cfence in IR -> PPC::CFENCE8 in isel -> Actual instructions in
expandPostRAPseudo.

The reason why expandPostRAPseudo is chosen is because previous passes
are likely eliminating instructions like cmpw 3, 3 (early CSE) and bne-
7, .+4 (some branch pass(s)).

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

llvm-svn: 303205

7 years agoAdd hasProfileSummary and has{Sample|Instrumentation}Profile methods
Easwaran Raman [Tue, 16 May 2017 20:14:39 +0000 (20:14 +0000)]
Add hasProfileSummary and has{Sample|Instrumentation}Profile methods

ProfileSummaryInfo already checks whether the module has sample profile
in determining profile counts. This will also be useful in inliner to
clean up threshold updates.

llvm-svn: 303204

7 years ago[InstCombine] auto-generate better checks; NFC
Sanjay Patel [Tue, 16 May 2017 20:09:32 +0000 (20:09 +0000)]
[InstCombine] auto-generate better checks; NFC

llvm-svn: 303203

7 years agoIn debug builds non-trivial amount of time is spent in InstCombine processing
Dmitry Mikulin [Tue, 16 May 2017 20:08:49 +0000 (20:08 +0000)]
In debug builds non-trivial amount of time is spent in InstCombine processing
@llvm.dbg.* calls in visitCallInst(). They can be safely ignored.

llvm-svn: 303202

7 years agoNewGVN: Only do something in verifyStoreExpressions if assertions are enabled, to...
Daniel Berlin [Tue, 16 May 2017 20:02:45 +0000 (20:02 +0000)]
NewGVN: Only do something in verifyStoreExpressions if assertions are enabled, to avoid unused code warnings.

llvm-svn: 303201

7 years agoNewGVN: Fix PR 33051 by making sure we remove old store expressions
Daniel Berlin [Tue, 16 May 2017 19:58:47 +0000 (19:58 +0000)]
NewGVN: Fix PR 33051 by making sure we remove old store expressions
from the ExpressionToClass mapping.

llvm-svn: 303200

7 years agoRevert "[X86] Replace slow LEA instructions in X86"
Reid Kleckner [Tue, 16 May 2017 19:55:03 +0000 (19:55 +0000)]
Revert "[X86] Replace slow LEA instructions in X86"

This reverts commit r303183, it broke various buildbots and introduced
sanitizer errors.

llvm-svn: 303199

7 years agoElide stores which are overwritten without being observed.
Nirav Dave [Tue, 16 May 2017 19:43:56 +0000 (19:43 +0000)]
Elide stores which are overwritten without being observed.

Summary:
In SelectionDAG, when a store is immediately chained to another store
to the same address, elide the first store as it has no observable
effects. This is causes small improvements dealing with intrinsics
lowered to stores.

Test notes:

* Many testcases overwrite store addresses multiple times and needed
  minor changes, mainly making stores volatile to prevent the
  optimization from optimizing the test away.

* Many X86 test cases optimized out instructions associated with
  associated with va_start.

* Note that test_splat in CodeGen/AArch64/misched-stp.ll no longer has
  dependencies to check and can probably be removed and potentially
  replaced with another test.

Reviewers: rnk, john.brawn

Subscribers: aemerson, rengolin, qcolombet, jyknight, nemanjai, nhaehnle, javed.absar, llvm-commits

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

llvm-svn: 303198

7 years agoShrinkWrap: Add skipFunction() call
Matthias Braun [Tue, 16 May 2017 18:43:30 +0000 (18:43 +0000)]
ShrinkWrap: Add skipFunction() call

ShrinkWrapping is a performance optimization that can safely be skipped,
so we can add `if (!skipFunction()) return;`

llvm-svn: 303197

7 years ago[MetadataLoader] Remove unused Vector. NFCI.
Davide Italiano [Tue, 16 May 2017 18:41:46 +0000 (18:41 +0000)]
[MetadataLoader] Remove unused Vector. NFCI.

llvm-svn: 303196

7 years agobuiltins: one more case of a missing header
Saleem Abdulrasool [Tue, 16 May 2017 18:19:44 +0000 (18:19 +0000)]
builtins: one more case of a missing header

llvm-svn: 303195

7 years ago[libcxxabi] Fix the test case committed in r303175.
Akira Hatanaka [Tue, 16 May 2017 18:18:03 +0000 (18:18 +0000)]
[libcxxabi] Fix the test case committed in r303175.

Free the __cxa_exception object allocated with __cxa_allocate_exception.

This is an attempt to fix this asan bot:

http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-asan/builds/560

llvm-svn: 303194

7 years agoRevert "[ARM] Mark LEApcrel instructions as isAsCheapAsAMove"
Renato Golin [Tue, 16 May 2017 17:59:07 +0000 (17:59 +0000)]
Revert "[ARM] Mark LEApcrel instructions as isAsCheapAsAMove"

Revert "[ARM] Mark LEApcrel as not having side effects"

This reverts commit r303054 and r303053, as they broke the ARM
self-hosting buildbots:

http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/1550

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1349

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/1845

Offline investigation on course.

llvm-svn: 303193

7 years ago[index] Avoid another crash that happens when looking up a dependent name
Alex Lorenz [Tue, 16 May 2017 17:33:17 +0000 (17:33 +0000)]
[index] Avoid another crash that happens when looking up a dependent name
in a record that has a base without a definition

rdar://32224197

llvm-svn: 303192

7 years ago[clang-tidy] Speed up performance-unnecessary-value-param check
Alexander Kornienko [Tue, 16 May 2017 17:28:17 +0000 (17:28 +0000)]
[clang-tidy] Speed up performance-unnecessary-value-param check

Moved slower matchers closer to the end. The total speed up on a large file I
was interested in is not huge, just about 10%, since the check seems to be doing
a lot in the check() method.

llvm-svn: 303191

7 years agobuiltins: add missing includes
Saleem Abdulrasool [Tue, 16 May 2017 17:06:48 +0000 (17:06 +0000)]
builtins: add missing includes

This inclusion is needed to fix the ARM build.  The int_lib.h include is
slightly ugly, but allows us to use the `AEABI_RTABI` macro to decorate
the CC for the functions.

llvm-svn: 303190

7 years ago[ScopInfo] Remove unused MemoryAccess::BaseName. NFC.
Michael Kruse [Tue, 16 May 2017 16:52:24 +0000 (16:52 +0000)]
[ScopInfo] Remove unused MemoryAccess::BaseName. NFC.

llvm-svn: 303189

7 years agobuiltins: expand out the AEABI function stubs
Saleem Abdulrasool [Tue, 16 May 2017 16:41:37 +0000 (16:41 +0000)]
builtins: expand out the AEABI function stubs

These actually may change calling conventions.  We cannot simply provide
function aliases as the aliased function may have a different calling
convention.  Provide a forwarding function instead to permit the
compiler to synthesize the calling convention adjustment thunk.

Remove the `ARM_EABI_FNALIAS` macro as that is not safe to use.

Resolves PR33030!

llvm-svn: 303188

7 years ago[clang-tidy] Optimize readability-implicit-bool-cast, NFC
Alexander Kornienko [Tue, 16 May 2017 16:40:46 +0000 (16:40 +0000)]
[clang-tidy] Optimize readability-implicit-bool-cast, NFC

Rearrange matchers to put the most expensive ones closer to the end. Speed up
another 3-5x on some files.

llvm-svn: 303187

7 years ago[AMDGPU] Use GCNRPTracker dumper methods in scheduler
Stanislav Mekhanoshin [Tue, 16 May 2017 16:31:45 +0000 (16:31 +0000)]
[AMDGPU] Use GCNRPTracker dumper methods in scheduler

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

llvm-svn: 303186

7 years ago[InstCombine] add motivational comment for tests; NFC
Sanjay Patel [Tue, 16 May 2017 16:30:46 +0000 (16:30 +0000)]
[InstCombine] add motivational comment for tests; NFC

The referenced tests are derived from:
https://bugs.llvm.org/show_bug.cgi?id=32791
and:
https://reviews.llvm.org/D33172

The motivation for including negative tests may not be clear, so I'm adding an explanatory comment here.
In the post-commit thread for r303133:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20170515/453793.html
...it was mentioned that we don't want to add redundant tests. This is a valid point. But in this case,
we have a patch under review (D33172) that demonstrates that no existing regression tests are affected by
a proposed code change, but these are. Therefore, I think these tests have value not visible in any
existing regression tests regardless of whether they show a transform.

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

llvm-svn: 303185

7 years ago[AMDGPU] Cache live-ins and register pressure in scheduler
Stanislav Mekhanoshin [Tue, 16 May 2017 16:11:26 +0000 (16:11 +0000)]
[AMDGPU] Cache live-ins and register pressure in scheduler

Using LIS can be quite expensive, so caching of calculated region
live-ins and pressure is implemented. It does two things:

1. Caches the info for the second stage when we schedule with
   decreased target occupancy.
2. Tracks the basic block from top to bottom thus eliminating the
   need to scan whole register file liveness at every region split
   in the middle of the block.

The scheduling is now done in 3 stages instead of two, with the first
one being really a no-op and only used to collect scheduling regions
as sent by the scheduler driver.

There is no functional change to the current behavior, only compilation
speed is affected. In general computeBlockPressure() could be simplified
if we switch to backward RP tracker, because scheduler sends regions
within a block starting from the last upward. We could use a natural
order of upward tracker to seamlessly change between regions of the same
block, since live reg set of a previous tracked region would become a
live-out of the next region. That however requires fixing upward tracker
to properly account defs and uses of the same instruction as both are
contributing to the current pressure. When we converge on the produced
pressure we should be able to switch between them back and forth. In
addition, backward tracker is less expensive as it uses LIS in recede
less often than forward uses it in advance.

At the moment the worst known case compilation time has improved from 26
minutes to 8.5.

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

llvm-svn: 303184

7 years ago[X86] Replace slow LEA instructions in X86
Lama Saba [Tue, 16 May 2017 16:01:36 +0000 (16:01 +0000)]
[X86] Replace slow LEA instructions in X86

  According to Intel's Optimization Reference Manual for SNB+:
  " For LEA instructions with three source operands and some specific situations, instruction latency has increased to 3 cycles, and must
    dispatch via port 1:
  - LEA that has all three source operands: base, index, and offset
  - LEA that uses base and index registers where the base is EBP, RBP,or R13
  - LEA that uses RIP relative addressing mode
  - LEA that uses 16-bit addressing mode "
  This patch currently handles the first 2 cases only.

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

llvm-svn: 303183