platform/upstream/llvm.git
6 years ago[IR] Upgrade comment token in objc retain release marker for asm call
Gerolf Hoflehner [Tue, 17 Apr 2018 04:02:24 +0000 (04:02 +0000)]
[IR] Upgrade comment token in objc retain release marker for asm call

Older compiler issued '#' instead of ';'

llvm-svn: 330173

6 years agoCOFF: Make SectionChunk::Relocs field an ArrayRef. NFCI.
Peter Collingbourne [Tue, 17 Apr 2018 01:54:34 +0000 (01:54 +0000)]
COFF: Make SectionChunk::Relocs field an ArrayRef. NFCI.

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

llvm-svn: 330172

6 years agoCODE_OWNERS: Take ownership of C API.
whitequark [Tue, 17 Apr 2018 01:09:12 +0000 (01:09 +0000)]
CODE_OWNERS: Take ownership of C API.

llvm-svn: 330171

6 years ago[Statistics] Relax the test output a little bit.
Davide Italiano [Mon, 16 Apr 2018 23:59:01 +0000 (23:59 +0000)]
[Statistics] Relax the test output a little bit.

We don't really care about the order as this is a dictionary.
It should be more resilient to changes (adding/shuffling stats
around).

Pointed out by Jason Molenda in a post-commit review (thanks Jason).

llvm-svn: 330170

6 years ago[ARM] Compute a target feature which corresponds to the ARM version.
Eli Friedman [Mon, 16 Apr 2018 23:52:58 +0000 (23:52 +0000)]
[ARM] Compute a target feature which corresponds to the ARM version.

Currently, the interaction between the triple, the CPU, and the
supported features is a mess: the driver edits the triple to indicate
the supported architecture version, and the LLVM backend uses this to
figure out what instructions are legal.  This makes it difficult to
understand what's happening, and makes it impossible to LTO together two
modules with different computed architectures.

Instead of relying on triple rewriting to get the correct target
features, we should add the right target features explicitly.

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

llvm-svn: 330169

6 years ago[DebugInfo] Follow-up bug fix on "Fixing a couple of DI duplication bugs of CloneModule"
Roman Tereshin [Mon, 16 Apr 2018 23:39:44 +0000 (23:39 +0000)]
[DebugInfo] Follow-up bug fix on "Fixing a couple of DI duplication bugs of CloneModule"

Apparently, DebugInfoFinder::processCompileUnit doesn't process all
of the possible kinds of DIImportedEntit'ies, e.g. DIGlobalVariable's.

Previously introduced `llvm_unreachable` is therefore incorrect.
Removing it here.

llvm-svn: 330167

6 years ago[Availability] Improve availability to consider functions run at load time
Steven Wu [Mon, 16 Apr 2018 23:34:18 +0000 (23:34 +0000)]
[Availability] Improve availability to consider functions run at load time

Summary:
There are some functions/methods that run when the application launches
or the library loads. Those functions will run reguardless the OS
version as long as it satifies the minimum deployment target. Annotate
them with availability attributes doesn't really make sense because they
are essentially available on all targets since minimum deployment
target.

rdar://problem/36093384

Reviewers: arphaman, erik.pilkington

Reviewed By: erik.pilkington

Subscribers: erik.pilkington, cfe-commits

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

llvm-svn: 330166

6 years ago[Commands] Expose statistics through the SBAPI.
Davide Italiano [Mon, 16 Apr 2018 22:55:34 +0000 (22:55 +0000)]
[Commands] Expose statistics through the SBAPI.

The API is `SBStructuredData GetStatistics()`. This allows
the command to be used in scripts.

<rdar://problem/36555975>

llvm-svn: 330165

6 years agoRevert r329960 "Do not keep shared symbols created from garbage-collected eliminated...
Reid Kleckner [Mon, 16 Apr 2018 22:45:23 +0000 (22:45 +0000)]
Revert r329960 "Do not keep shared symbols created from garbage-collected eliminated DSOs."

This is causing large numbers of Chromium test executables to crash on
shutdown. The relevant symbol seems to be __cxa_finalize, which gets
removed from the dynamic symbol table for some of the support libraries.

llvm-svn: 330164

6 years agoMake sure deleting all breakpoints clears their sites first
Eugene Zemtsov [Mon, 16 Apr 2018 22:26:21 +0000 (22:26 +0000)]
Make sure deleting all breakpoints clears their sites first

Bug: https://bugs.llvm.org/show_bug.cgi?id=36430

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

llvm-svn: 330163

6 years ago[libc++abi] Replace __sync_* functions with __libcpp_atomic_* functions.
Eli Friedman [Mon, 16 Apr 2018 22:00:14 +0000 (22:00 +0000)]
[libc++abi] Replace __sync_* functions with __libcpp_atomic_* functions.

This is basically part 2 of r313694.

It's a little unfortunate that I had to copy-paste atomic_support.h,
but I don't really see any alternative.

The refstring.h changes are the same as the libcxx changes in r313694.

llvm-svn: 330162

6 years agoRevert "build: reserve `--color-diagnostics` for lld"
Saleem Abdulrasool [Mon, 16 Apr 2018 21:57:10 +0000 (21:57 +0000)]
Revert "build: reserve `--color-diagnostics` for lld"

This reverts SVN r330158.

Seems that there was a change to linker flags handling in SVN r316972.
That would alter the behaviour to correct the linker flag handling in
CMake (requiring CMake 3.4.3+).  Since that is already the minimum
version required for LLVM, hard coding the knowledge of the linker is
not required, which is a strictly better solution.

llvm-svn: 330161

6 years agoLimit types of builtins that can be redeclared.
Erich Keane [Mon, 16 Apr 2018 21:30:08 +0000 (21:30 +0000)]
Limit types of builtins that can be redeclared.

As reported here: https://bugs.llvm.org/show_bug.cgi?id=37033
Any usage of a builtin function that uses a va_list by reference
will cause an assertion when redeclaring it.

After discussion in the review, it was concluded that the correct
way of accomplishing this fix is to make attempts to redeclare certain
builtins an error. Unfortunately, doing this limitation for all builtins
is likely a breaking change, so this commit simply limits it to
types with custom type checking and those that take a reference.

Two tests needed to be updated to make this work.

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

llvm-svn: 330160

6 years agoDefer adding keywords to the identifier table until after the language options have...
Aaron Ballman [Mon, 16 Apr 2018 21:07:08 +0000 (21:07 +0000)]
Defer adding keywords to the identifier table until after the language options have been loaded from the AST file.

This fixes issues with "class" being reported as an identifier in "enum class" because the construct is not present when using default language options.

Patch by Johann Klähn.

llvm-svn: 330159

6 years agobuild: reserve `--color-diagnostics` for lld
Saleem Abdulrasool [Mon, 16 Apr 2018 21:05:56 +0000 (21:05 +0000)]
build: reserve `--color-diagnostics` for lld

When building out-of-tree compilers (e.g. swift), the linker check here
may yield incorrect values.  Ensure that we are using lld before we
attempt to use `--color-diagnostics` for the linker.  Other linkers (i.e
bfd, gold) do not support this flag and the test can pass in some cases
and then fail subsequently when building.

llvm-svn: 330158

6 years ago[PDB] Correctly use the target machine when writing DBI stream.
Zachary Turner [Mon, 16 Apr 2018 20:42:06 +0000 (20:42 +0000)]
[PDB] Correctly use the target machine when writing DBI stream.

Using Config->is64() will treat ARM64 as Amd64, which is incorrect.
Furthermore, there are more esoteric architectures that could
theoretically be encountered.  Just set it directly to the machine
type, which we already know anyway.

llvm-svn: 330157

6 years ago[OPENMP] Allow to use declare target variables in map clauses
Alexey Bataev [Mon, 16 Apr 2018 20:34:41 +0000 (20:34 +0000)]
[OPENMP] Allow to use declare target variables in map clauses

Global variables marked as declare target are allowed to be used in map
clauses. Patch fixes the crash of the compiler on the declare target
variables in map clauses.

llvm-svn: 330156

6 years ago[CodeGen] Fix a crash that occurs when a non-trivial C struct with a
Akira Hatanaka [Mon, 16 Apr 2018 20:23:52 +0000 (20:23 +0000)]
[CodeGen] Fix a crash that occurs when a non-trivial C struct with a
volatile array field is copied.

The crash occurs because method 'visitArray' passes a null FieldDecl to
method 'visit' and some of the methods called downstream expect a
non-null FieldDecl to be passed.

This reapplies r330151 with a fix to the test case.

rdar://problem/33599681

llvm-svn: 330155

6 years ago[OPENMP] General code improvements.
Alexey Bataev [Mon, 16 Apr 2018 20:16:21 +0000 (20:16 +0000)]
[OPENMP] General code improvements.

llvm-svn: 330154

6 years agoRevert "[CodeGen] Fix a crash that occurs when a non-trivial C struct with a"
Akira Hatanaka [Mon, 16 Apr 2018 19:53:59 +0000 (19:53 +0000)]
Revert "[CodeGen] Fix a crash that occurs when a non-trivial C struct with a"

This reverts commit r330151, which caused bots to fail.

llvm-svn: 330153

6 years agoUse export_as for autolinking frameworks
Bruno Cardoso Lopes [Mon, 16 Apr 2018 19:42:32 +0000 (19:42 +0000)]
Use export_as for autolinking frameworks

framework module SomeKitCore {
  ...
  export_as SomeKit
}

Given the module above, while generting autolink information during
codegen, clang should to emit '-framework SomeKitCore' only if SomeKit
was not imported in the relevant TU, otherwise it should use '-framework
SomeKit' instead.

rdar://problem/38269782

llvm-svn: 330152

6 years ago[CodeGen] Fix a crash that occurs when a non-trivial C struct with a
Akira Hatanaka [Mon, 16 Apr 2018 19:38:00 +0000 (19:38 +0000)]
[CodeGen] Fix a crash that occurs when a non-trivial C struct with a
volatile array field is copied.

The crash occurs because method 'visitArray' passes a null FieldDecl to
method 'visit' and some of the methods called downstream expect a
non-null FieldDecl to be passed.

rdar://problem/33599681

llvm-svn: 330151

6 years ago[Hexagon] Emit a warning when -fvectorize is given without -mhvx
Krzysztof Parzyszek [Mon, 16 Apr 2018 19:11:17 +0000 (19:11 +0000)]
[Hexagon] Emit a warning when -fvectorize is given without -mhvx

llvm-svn: 330150

6 years ago[lldb-private] Mark a function as inline to prevent multiple def errors.
Davide Italiano [Mon, 16 Apr 2018 19:07:14 +0000 (19:07 +0000)]
[lldb-private] Mark a function as inline to prevent multiple def errors.

llvm-svn: 330149

6 years ago[RISCV] Fix assert message operator
Mandeep Singh Grang [Mon, 16 Apr 2018 18:56:10 +0000 (18:56 +0000)]
[RISCV] Fix assert message operator

Summary:
Specifying assert message with an || operator makes the compiler interpret it
 as a bool. Changed it to &&.

Reviewers: asb, apazos

Reviewed By: asb

Subscribers: rbar, johnrusso, simoncook, jordy.potman.lists, sabuasal, niosHD, kito-cheng, shiva0217, zzheng, llvm-commits

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

llvm-svn: 330148

6 years ago[Statistics] Move GetStatDescription to an header file.
Davide Italiano [Mon, 16 Apr 2018 18:25:57 +0000 (18:25 +0000)]
[Statistics] Move GetStatDescription to an header file.

In preparation for using it in the API.

<rdar://problem/36555975>

llvm-svn: 330147

6 years ago[sanitizer] Fix OSX build failure post D45457
Kostya Kortchinsky [Mon, 16 Apr 2018 18:17:22 +0000 (18:17 +0000)]
[sanitizer] Fix OSX build failure post D45457

Summary:
It looks like OSX's UBSan needs a "NoHooks" version of
`RTSanitizerCommonSymbolizer` to work build properly.

Subscribers: kubamracek, mgorny, delcypher, llvm-commits, #sanitizers

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

llvm-svn: 330146

6 years agoResubmit "Fix some incorrect fields in our generated PDBs."
Zachary Turner [Mon, 16 Apr 2018 18:17:13 +0000 (18:17 +0000)]
Resubmit "Fix some incorrect fields in our generated PDBs."

This fixes the failing tests.  They simply hadn't been updated
to match the new output resulting from this patch.

llvm-svn: 330145

6 years ago[X86] Remove unnecessary -mattr to enable avx512bw when the -mcpu already enabled...
Craig Topper [Mon, 16 Apr 2018 18:14:19 +0000 (18:14 +0000)]
[X86] Remove unnecessary -mattr to enable avx512bw when the -mcpu already enabled it. NFC

This makes the test similar to the arith-sub.ll and arith-mul.ll tests.

llvm-svn: 330144

6 years ago[SLP] Use getExtractWithExtendCost() to compute the scalar cost of extractelement...
Haicheng Wu [Mon, 16 Apr 2018 18:09:49 +0000 (18:09 +0000)]
[SLP] Use getExtractWithExtendCost() to compute the scalar cost of extractelement/ext pair

We use getExtractWithExtendCost to calculate the cost of extractelement and
s|zext together when computing the extract cost after vectorization, but we
calculate the cost of extractelement and s|zext separately when computing the
scalar cost which is larger than it should be.

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

llvm-svn: 330143

6 years ago[ORC] Add a MaterializationResponsibility class to track responsibility for
Lang Hames [Mon, 16 Apr 2018 18:05:24 +0000 (18:05 +0000)]
[ORC] Add a MaterializationResponsibility class to track responsibility for
materializing function definitions.

MaterializationUnit instances are responsible for resolving and finalizing
symbol definitions when their materialize method is called. By contract, the
MaterializationUnit must materialize all definitions it is responsible for and
no others. If it can not materialize all definitions (because of some error)
then it must notify the associated VSO about each definition that could not be
materialized. The MaterializationResponsibility class tracks this
responsibility, asserting that all required symbols are resolved and finalized,
and that no extraneous symbols are resolved or finalized. In the event of an
error it provides a convenience method for notifying the VSO about each
definition that could not be materialized.

llvm-svn: 330142

6 years ago[ORC] Merge VSO notifyResolutionFailed and notifyFinalizationFailed in to
Lang Hames [Mon, 16 Apr 2018 18:05:22 +0000 (18:05 +0000)]
[ORC] Merge VSO notifyResolutionFailed and notifyFinalizationFailed in to
notifyMaterializationFailed.

The notifyMaterializationFailed method can determine which error to raise by
looking at which queue the pending queries are in (resolution or finalization).

llvm-svn: 330141

6 years ago[OPENMP] General code improvements.
Alexey Bataev [Mon, 16 Apr 2018 17:59:34 +0000 (17:59 +0000)]
[OPENMP] General code improvements.

llvm-svn: 330140

6 years ago[Hexagon] Turn off flag enabling auto-vectorization
Krzysztof Parzyszek [Mon, 16 Apr 2018 17:35:30 +0000 (17:35 +0000)]
[Hexagon] Turn off flag enabling auto-vectorization

It was turned on for testing and was accidentally left on in the commit.

llvm-svn: 330139

6 years ago[NFC] Move verificaiton check for f128 conversion into LowerINT_TO_FP()
Lei Huang [Mon, 16 Apr 2018 17:30:24 +0000 (17:30 +0000)]
[NFC] Move verificaiton check for f128 conversion into LowerINT_TO_FP()

Move veriication check for legal conversions to f128 into LowerINT_TO_FP()
and fix some indentations to match other sections of the code for readability.

llvm-svn: 330138

6 years ago[InstCombine] simplify code in SimplifyAssociativeOrCommutative; NFCI
Sanjay Patel [Mon, 16 Apr 2018 17:15:13 +0000 (17:15 +0000)]
[InstCombine] simplify code in SimplifyAssociativeOrCommutative; NFCI

llvm-svn: 330137

6 years ago[Attributes] Fix a bug in AttributeList::get so it can handle a mix of FunctionIndex...
Craig Topper [Mon, 16 Apr 2018 17:05:01 +0000 (17:05 +0000)]
[Attributes] Fix a bug in AttributeList::get so it can handle a mix of FunctionIndex and ReturnIndex/arg indices at the same time

The code uses the index of the last element in the sorted array to determine the maximum size needed for the vector. But if the last index is a FunctionIndex(~0), attrIdxToArrayIdx will return 0 and the vector will have size 1. If there are any indices before FunctionIndex, those values would return a value larger than 0 from attrIdxToArrayIdx. So in this case we need to look in front of the FunctionIndex to get the true size needed.

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

llvm-svn: 330136

6 years agoRemove faulty assertion in llvm-pdbutil
Adrian McCarthy [Mon, 16 Apr 2018 17:01:18 +0000 (17:01 +0000)]
Remove faulty assertion in llvm-pdbutil

If a class's first data member is an instance of an empty class, then an
assertion in the PrettyClassLayoutGraphicalDumper would fail. The
storage is reserved, but it's not marked as in use.

As far as I understand, it's the assertion that's faulty, so I removed it
and updated the nearby comment.

Found by running llvm-pdbutil against its own PDB, and this assertion would
fail on HashAdjusters, which is a HashTable whose first data member is a
TraitsT, which is a PdbHashTraits<T>, which is an empty struct. (The struct
has a specialization for uint32_t, but that specialization doesn't apply
here because the T is actually ulittle32_t.)

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

llvm-svn: 330135

6 years ago[sanitizer] Build failures fixes post D45457
Kostya Kortchinsky [Mon, 16 Apr 2018 16:58:34 +0000 (16:58 +0000)]
[sanitizer] Build failures fixes post D45457

Summary: Adding a couple missed RTSanitizerCommonSymbolizer in makefiles.

Subscribers: kubamracek, mgorny, delcypher, llvm-commits, #sanitizers

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

llvm-svn: 330134

6 years agoRevert "Fix some incorrect fields in our generated PDBs."
Zachary Turner [Mon, 16 Apr 2018 16:55:41 +0000 (16:55 +0000)]
Revert "Fix some incorrect fields in our generated PDBs."

There are a couple of failing tests which slipped under my radar
so I'm reverting this while I attempt to fix.

llvm-svn: 330133

6 years ago[CodeView] Initial support for emitting S_THUNK32 symbols for compiler...
Brock Wyma [Mon, 16 Apr 2018 16:53:57 +0000 (16:53 +0000)]
[CodeView] Initial support for emitting S_THUNK32 symbols for compiler...

When emitting CodeView debug information, compiler-generated thunk routines
should be emitted using S_THUNK32 symbols instead of S_GPROC32_ID symbols so
Visual Studio can properly step into the user code.  This initial support only
handles standard thunk ordinals.

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

llvm-svn: 330132

6 years ago[sanitizer] Split Symbolizer/StackTraces from core RTSanitizerCommon
Kostya Kortchinsky [Mon, 16 Apr 2018 16:32:19 +0000 (16:32 +0000)]
[sanitizer] Split Symbolizer/StackTraces from core RTSanitizerCommon

Summary:
Host symbolizer & stacktraces related code in their own RT:
`RTSanitizerCommonSymbolizer`, which is "libcdep" by nature. Symbolizer &
stacktraces specific code that used to live in common files is moved to a new
file `sanitizer_symbolizer_report.cc` as is.

The purpose of this is the enforce a separation between code that relies on
symbolization and code that doesn't. This saves the inclusion of spurious code
due to the interface functions with default visibility, and the extra data
associated.

The following sanitizers makefiles were modified & tested locally:
- dfsan: doesn't require the new symbolizer RT
- esan: requires it
- hwasan: requires it
- lsan: requires it
- msan: requires it
- safestack: doesn't require it
- xray: doesn't require it
- tsan: requires it
- ubsan: requires it
- ubsan_minimal: doesn't require it
- scudo: requires it (but not for Fuchsia that has a minimal runtime)

This was tested locally on Linux, Android, Fuchsia.

Reviewers: alekseyshl, eugenis, dberris, kubamracek, vitalybuka, dvyukov, mcgrathr

Reviewed By: alekseyshl, vitalybuka

Subscribers: srhines, kubamracek, mgorny, krytarowski, delcypher, llvm-commits, #sanitizers

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

llvm-svn: 330131

6 years agoFix some incorrect fields in our generated PDBs.
Zachary Turner [Mon, 16 Apr 2018 16:27:49 +0000 (16:27 +0000)]
Fix some incorrect fields in our generated PDBs.

Most of these are pretty trivial and obvious. Setting the toolchain
version to 14.11 is perhaps a little questionable, but we've been bitten
in the past where one of our version fields sidn't match MSVC's, and I
definitely don't want to go through that diagnosis again as it was
pretty time consuming and hard to track down.

I found all of these by using llvm-pdbutil export to dump the dbi and
pdb streams to a file, then using fc followed by llvm-pdbutil explain to
explain the mismatched bytes.

There are still some more, these are just the low hanging fruit.

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

llvm-svn: 330130

6 years ago[InstCombine] simplify getBinOpsForFactorization(); NFC
Sanjay Patel [Mon, 16 Apr 2018 15:19:24 +0000 (15:19 +0000)]
[InstCombine] simplify getBinOpsForFactorization(); NFC

llvm-svn: 330129

6 years agoSmallVectorMemoryBuffer: Fix some comments
David Blaikie [Mon, 16 Apr 2018 14:23:15 +0000 (14:23 +0000)]
SmallVectorMemoryBuffer: Fix some comments

llvm-svn: 330128

6 years ago[InstCombine] simplify fneg+fadd folds; NFC
Sanjay Patel [Mon, 16 Apr 2018 14:13:57 +0000 (14:13 +0000)]
[InstCombine] simplify fneg+fadd folds; NFC

Two cleanups:
1. As noted in D45453, we had tests that don't need FMF that were misplaced in the 'fast-math.ll' test file.
2. This removes the final uses of dyn_castFNegVal, so that can be deleted. We use 'match' now.

llvm-svn: 330126

6 years ago[InstCombine] fix formatting; NFC
Sanjay Patel [Mon, 16 Apr 2018 13:21:15 +0000 (13:21 +0000)]
[InstCombine] fix formatting; NFC

llvm-svn: 330124

6 years ago[AMDGPU][MC][VI][GFX9] Added support of SDWA/DPP for v_cndmask_b32
Dmitry Preobrazhensky [Mon, 16 Apr 2018 12:41:38 +0000 (12:41 +0000)]
[AMDGPU][MC][VI][GFX9] Added support of SDWA/DPP for v_cndmask_b32

See bug 36356: https://bugs.llvm.org/show_bug.cgi?id=36356

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

Reviewers: artem.tamazov, arsenm, timcorringham
llvm-svn: 330123

6 years agotsan: add support for linux/powerpc64 in buildgo.sh
Dmitry Vyukov [Mon, 16 Apr 2018 11:43:00 +0000 (11:43 +0000)]
tsan: add support for linux/powerpc64 in buildgo.sh

The current implementation of the Go sanitizer only works on x86_64.
Added some modifications to the buildgo.sh script and the Tsan code
to make it work on powerpc64/linux.

Author: cseo (Carlos Eduardo Seo)
Reviewed in: https://reviews.llvm.org/D43025

llvm-svn: 330122

6 years ago[test] Avoid spurious failure in debug-names-find.s. NFC.
Pavel Labath [Mon, 16 Apr 2018 11:16:41 +0000 (11:16 +0000)]
[test] Avoid spurious failure in debug-names-find.s. NFC.

Have llvm-dwarfdump take input from stdin to avoid leaking the host paths into
the tests, causing nondeterministic failures.

llvm-svn: 330121

6 years ago[AArch64][SVE] Asm: Support for structured LD4 (scalar+imm) load instructions.
Sander de Smalen [Mon, 16 Apr 2018 10:46:18 +0000 (10:46 +0000)]
[AArch64][SVE] Asm: Support for structured LD4 (scalar+imm) load instructions.

Reviewers: fhahn, rengolin, javed.absar, huntergr, SjoerdMeijer, t.p.northover, echristo, evandro

Reviewed By: rengolin

Subscribers: tschuett, llvm-commits, kristof.beyls

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

llvm-svn: 330120

6 years ago[LatencyPriorityQueue] Fix build: missing override
Roman Lebedev [Mon, 16 Apr 2018 10:40:56 +0000 (10:40 +0000)]
[LatencyPriorityQueue] Fix build: missing override

[10/260] Building CXX object lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/PostRASchedulerList.cpp.o
FAILED: lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/PostRASchedulerList.cpp.o
/usr/local/bin/clang++  -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/CodeGen -I/build/llvm/lib/CodeGen -I/usr/include/libxml2 -Iinclude -I/build/llvm/include -g0 -fPIC -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fcolor-diagnostics -ffunction-sections -fdata-sections -O3 -g0  -fPIC   -UNDEBUG  -fno-exceptions -fno-rtti -MD -MT lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/PostRASchedulerList.cpp.o -MF lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/PostRASchedulerList.cpp.o.d -o lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/PostRASchedulerList.cpp.o -c /build/llvm/lib/CodeGen/PostRASchedulerList.cpp
In file included from /build/llvm/lib/CodeGen/PostRASchedulerList.cpp:26:
/build/llvm/include/llvm/CodeGen/LatencyPriorityQueue.h:87:27: error: 'dump' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
    LLVM_DUMP_METHOD void dump(ScheduleDAG *DAG) const {
                          ^
/build/llvm/include/llvm/CodeGen/ScheduleDAG.h:547:18: note: overridden virtual function is here
    virtual void dump(ScheduleDAG *) const {}
                 ^
1 error generated.

llvm-svn: 330119

6 years ago[mips] Prevent PIC to be set to level 2
Aleksandar Beserminji [Mon, 16 Apr 2018 10:21:24 +0000 (10:21 +0000)]
[mips] Prevent PIC to be set to level 2

MIPS does not use PIC level 2 for historical reasons,
even with -fPIC/-mxgot/multigot options. This patch
prevents PIC to be set to level 2 for MIPS.

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

llvm-svn: 330118

6 years ago[LatencyPriorityQueue] The LatencyPriorityQueue class is missing the implementation...
Stefan Pintilie [Mon, 16 Apr 2018 10:20:56 +0000 (10:20 +0000)]
[LatencyPriorityQueue] The LatencyPriorityQueue class is missing the implementation for the dump function

Added implementation of the dump function for LatencyPriorityQueue.

llvm-svn: 330117

6 years ago[AArch64][SVE] Asm: Support for structured LD3 (scalar+imm) load instructions.
Sander de Smalen [Mon, 16 Apr 2018 10:10:48 +0000 (10:10 +0000)]
[AArch64][SVE] Asm: Support for structured LD3 (scalar+imm) load instructions.

Reviewers: fhahn, rengolin, javed.absar, huntergr, SjoerdMeijer, t.p.northover, echristo, evandro

Reviewed By: rengolin

Subscribers: tschuett, kristof.beyls, llvm-commits

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

llvm-svn: 330116

6 years ago[MIR-Canon] Fixing a test failure caused by COPY Folding.
Puyan Lotfi [Mon, 16 Apr 2018 09:31:49 +0000 (09:31 +0000)]
[MIR-Canon] Fixing a test failure caused by COPY Folding.

llvm-svn: 330115

6 years ago[mips] Restrict certain trap instructions for micromipsr6
Stefan Maksimovic [Mon, 16 Apr 2018 09:22:20 +0000 (09:22 +0000)]
[mips] Restrict certain trap instructions for micromipsr6

Instructions removed from micromipsr6:
teqi, tgei, tgeiu, tlti, tltiu, tnei

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

llvm-svn: 330114

6 years ago[MIR-Canon] Adding ISA-Agnostic COPY Folding.
Puyan Lotfi [Mon, 16 Apr 2018 09:03:03 +0000 (09:03 +0000)]
[MIR-Canon] Adding ISA-Agnostic COPY Folding.

Transforms the following:

    %vreg1234:gpr32 = COPY %42
    %vreg1235:gpr32 = COPY %vreg1234
    %vreg1236:gpr32 = COPY %vreg1235
    $w0 = COPY %vreg1236

into:

    $w0 = COPY %42

Assuming %42 is also a gpr32

llvm-svn: 330113

6 years agoClean carriage returns from lib/ and include/. NFC.
Malcolm Parsons [Mon, 16 Apr 2018 08:31:08 +0000 (08:31 +0000)]
Clean carriage returns from lib/ and include/. NFC.

Summary:
Clean carriage returns from lib/ and include/. NFC.
(I have to make this change locally in order for `git diff` to show sane output after I edit a file, so I might as well ask for it to be committed. I don't have commit privs myself.)
(Without this patch, `git rebase`ing any change involving SemaDeclCXX.cpp is a real nightmare. :( So while I have no right to ask for this to be committed, geez would it make my workflow easier if it were.)

Here's the command I used to reformat things. (Requires bash and OSX/FreeBSD sed.)

    git grep -l $'\r' lib include | xargs sed -i -e $'s/\r//'
    find lib include -name '*-e' -delete

Reviewers: malcolm.parsons

Reviewed By: malcolm.parsons

Subscribers: emaste, krytarowski, cfe-commits

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

Patch by Arthur O'Dwyer.

llvm-svn: 330112

6 years ago[NFC][MIR-Canon] clang-format cleanup of Mir Canonicalizer Pass.
Puyan Lotfi [Mon, 16 Apr 2018 08:12:15 +0000 (08:12 +0000)]
[NFC][MIR-Canon] clang-format cleanup of Mir Canonicalizer Pass.

llvm-svn: 330111

6 years ago[X86] Introduce archs: goldmont-plus & tremont
Gabor Buella [Mon, 16 Apr 2018 08:10:10 +0000 (08:10 +0000)]
[X86] Introduce archs: goldmont-plus & tremont

Reviewers: craig.topper

Reviewed By: craig.topper

Subscribers: cfe-commits

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

llvm-svn: 330110

6 years ago[X86] Introduce archs: goldmont-plus & tremont
Gabor Buella [Mon, 16 Apr 2018 07:47:35 +0000 (07:47 +0000)]
[X86] Introduce archs: goldmont-plus & tremont

Using Goldmont's cost tables for these two upcoming
atom archs.

Reviewers: craig.topper

Reviewed By: craig.topper

Subscribers: llvm-commits

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

llvm-svn: 330109

6 years ago[AArch64][SVE] Asm: Support for structured LD2 (scalar+imm) load instructions.
Sander de Smalen [Mon, 16 Apr 2018 07:09:29 +0000 (07:09 +0000)]
[AArch64][SVE] Asm: Support for structured LD2 (scalar+imm) load instructions.

Reviewers: fhahn, rengolin, javed.absar, huntergr, SjoerdMeijer, t.p.northover, echristo, evandro

Reviewed By: rengolin

Subscribers: tschuett, kristof.beyls, llvm-commits

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

llvm-svn: 330108

6 years agoRename ObjectMemoryBuffer to SmallVectorMemoryBuffer; NFCI
Weiming Zhao [Mon, 16 Apr 2018 03:44:03 +0000 (03:44 +0000)]
Rename ObjectMemoryBuffer to SmallVectorMemoryBuffer; NFCI

Summary: As discussed in https://reviews.llvm.org/D45606, it makes more sense to name the class as SmallVectorMemoryBuffer

Reviewers: bkramer, dblaikie

Reviewed By: dblaikie

Subscribers: mehdi_amini, eraman, llvm-commits

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

llvm-svn: 330107

6 years ago[BasicAA] Return MayAlias for the pointer plus variable offset to
Shiva Chen [Mon, 16 Apr 2018 01:58:39 +0000 (01:58 +0000)]
[BasicAA] Return MayAlias for the pointer plus variable offset to
structure object member

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

llvm-svn: 330106

6 years ago[X86] Use APInt::isSubsetof instead of APInt::intersects to avoid a negation of an...
Craig Topper [Sun, 15 Apr 2018 19:11:25 +0000 (19:11 +0000)]
[X86] Use APInt::isSubsetof instead of APInt::intersects to avoid a negation of an APInt value. NFC

llvm-svn: 330105

6 years ago[X86] Use uint32_t instead of unsigned in GetLo32XForm for readability. NFC
Craig Topper [Sun, 15 Apr 2018 19:11:24 +0000 (19:11 +0000)]
[X86] Use uint32_t instead of unsigned in GetLo32XForm for readability. NFC

GetLo8XForm right next to it uses uint8_t so uint32_t is consistent.

llvm-svn: 330104

6 years ago[InstCombine] Simplify 'xor' to 'or' if no common bits are set.
Roman Lebedev [Sun, 15 Apr 2018 18:59:44 +0000 (18:59 +0000)]
[InstCombine] Simplify 'xor' to 'or' if no common bits are set.

Summary:
In order to get the whole fold as specified in [[ https://bugs.llvm.org/show_bug.cgi?id=6773 | PR6773 ]],
let's first handle the simple straight-forward things.
Let's start with the `and` -> `or` simplification.

The one obvious thing missing here: the constant mask is not handled.
I have an idea how to handle it, but it will require some thinking,
and is not strictly required here, so i've left that for later.

https://rise4fun.com/Alive/Pkmg

Reviewers: spatel, craig.topper, eli.friedman, jingyue

Reviewed By: spatel

Subscribers: llvm-commits

Was reviewed as part of https://reviews.llvm.org/D45631

llvm-svn: 330103

6 years ago[SelectionDAG][NFC] haveNoCommonBitsSet(): add FIXME notes
Roman Lebedev [Sun, 15 Apr 2018 18:59:38 +0000 (18:59 +0000)]
[SelectionDAG][NFC] haveNoCommonBitsSet(): add FIXME notes

As suggested in https://reviews.llvm.org/D45631#1068338

llvm-svn: 330102

6 years ago[InstCombine] Simplify 'add' to 'or' if no common bits are set.
Roman Lebedev [Sun, 15 Apr 2018 18:59:33 +0000 (18:59 +0000)]
[InstCombine] Simplify 'add' to 'or' if no common bits are set.

Summary:
In order to get the whole fold as specified in [[ https://bugs.llvm.org/show_bug.cgi?id=6773 | PR6773 ]],
let's first handle the simple straight-forward things.
Let's start with the `and` -> `or` simplification.

The one obvious thing missing here: the constant mask is not handled.
I have an idea how to handle it, but it will require some thinking,
and is not strictly required here, so i've left that for later.

https://rise4fun.com/Alive/Pkmg

Reviewers: spatel, craig.topper, eli.friedman, jingyue

Reviewed By: spatel

Subscribers: llvm-commits

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

llvm-svn: 330101

6 years ago[NFC] ConstantOffsetExtractor::CanTraceInto(): add FIXME: no tests
Roman Lebedev [Sun, 15 Apr 2018 18:59:27 +0000 (18:59 +0000)]
[NFC] ConstantOffsetExtractor::CanTraceInto(): add FIXME: no tests

As suggested in https://reviews.llvm.org/D45631#1068338,
looking at haveNoCommonBitsSet() users, and *trying* to
show the change effect elsewhere.

llvm-svn: 330100

6 years ago[MC] Moved all the remaining logic that computed instruction latency and reciprocal...
Andrea Di Biagio [Sun, 15 Apr 2018 17:32:17 +0000 (17:32 +0000)]
[MC] Moved all the remaining logic that computed instruction latency and reciprocal throughput from TargetSchedModel to MCSchedModel.

TargetSchedModel now always delegates to MCSchedModel the computation of
instruction latency and reciprocal throughput.
No functional change intended.

llvm-svn: 330099

6 years ago[DAGCombiner, PowerPC] allow X - (fpext(-Y) --> X + fpext(Y) with multiple uses
Sanjay Patel [Sun, 15 Apr 2018 16:43:48 +0000 (16:43 +0000)]
[DAGCombiner, PowerPC] allow X - (fpext(-Y) --> X + fpext(Y) with multiple uses

This is a transform that I limited in instcombine in rL329821 because it was
creating more instructions in IR when the cast has multiple uses.

But if the cast is free, then we can do the transform regardless of other
uses because it improves the potential throughput of the calculation by
removing a dependency on the fneg.

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

llvm-svn: 330098

6 years ago[InstCombine] simplify more code for distributive property; NFCI
Sanjay Patel [Sun, 15 Apr 2018 16:20:58 +0000 (16:20 +0000)]
[InstCombine] simplify more code for distributive property; NFCI

Also, fix capitalization to current style. Follow-up to:
rL330096

llvm-svn: 330097

6 years ago[InstCombine] simplify code for distributive property; NFCI
Sanjay Patel [Sun, 15 Apr 2018 15:39:57 +0000 (15:39 +0000)]
[InstCombine] simplify code for distributive property; NFCI

llvm-svn: 330096

6 years ago[analyzer] Do not invalidate the `this` pointer.
Henry Wong [Sun, 15 Apr 2018 10:34:06 +0000 (10:34 +0000)]
[analyzer] Do not invalidate the `this` pointer.

Summary:
`this` pointer is not an l-value, although we have modeled `CXXThisRegion` for `this` pointer, we can only bind it once, which is when we start to inline method. And this patch fixes https://bugs.llvm.org/show_bug.cgi?id=35506.

In addition, I didn't find any other cases other than loop-widen that could invalidate `this` pointer.

Reviewers: NoQ, george.karpenkov, a.sidorin, seaneveson, szepet

Reviewed By: NoQ

Subscribers: xazax.hun, rnkovacs, cfe-commits, MTC

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

llvm-svn: 330095

6 years ago[Support] Extend WithColor helpers
Jonas Devlieghere [Sun, 15 Apr 2018 08:44:15 +0000 (08:44 +0000)]
[Support] Extend WithColor helpers

Although printing warnings and errors to stderr is by far the most
common case, this patch makes it possible to specify any stream.

llvm-svn: 330094

6 years agoNFC: Move ObjectMemoryBuffer to support
Weiming Zhao [Sun, 15 Apr 2018 05:17:14 +0000 (05:17 +0000)]
NFC: Move ObjectMemoryBuffer to support

Summary:
Since the class is used by both MCJIT and LTO, it makes more sense to move it to Support lib.
This is a follow up patch to r329929 and https://reviews.llvm.org/D45244

Reviewers: bkramer, dblaikie

Reviewed By: bkramer

Subscribers: mehdi_amini, eraman, llvm-commits

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

llvm-svn: 330093

6 years ago[DebugInfo] Use WithColor to print errors/warnings
Jonas Devlieghere [Sat, 14 Apr 2018 22:07:23 +0000 (22:07 +0000)]
[DebugInfo] Use WithColor to print errors/warnings

Use the convenience methods from WithColor to consistently print errors
and warnings in libDebugInfo.

llvm-svn: 330092

6 years ago[Support] Add convenience functions to WithColor. NFC.
Jonas Devlieghere [Sat, 14 Apr 2018 21:36:42 +0000 (21:36 +0000)]
[Support] Add convenience functions to WithColor. NFC.

Create convenience functions for printing error, warning and note to
stdout. Previously we had similar functions being used in dsymutil, but
given that this pattern is so common it makes sense to make it available
globally.

llvm-svn: 330091

6 years ago[X86] Tests for unsigned saturation downconvert detection.
Artur Gainullin [Sat, 14 Apr 2018 20:10:17 +0000 (20:10 +0000)]
[X86] Tests for unsigned saturation downconvert detection.

One more test for smax(smin(x, C2), C1) pattern.

llvm-svn: 330090

6 years ago[InstCombine] Enable Add/Sub simplifications with only 'reassoc' FMF
Warren Ristow [Sat, 14 Apr 2018 19:18:28 +0000 (19:18 +0000)]
[InstCombine] Enable Add/Sub simplifications with only 'reassoc' FMF

These simplifications were previously enabled only with isFast(), but that
is more restrictive than required. Since r317488, FMF has 'reassoc' to
control these cases at a finer level.

llvm-svn: 330089

6 years ago[X86] Tests for unsigned saturation downconvert detection.
Artur Gainullin [Sat, 14 Apr 2018 19:09:02 +0000 (19:09 +0000)]
[X86] Tests for unsigned saturation downconvert detection.

llvm-svn: 330088

6 years ago[clangd] Fix label and snippet for funcs in the index
Ilya Biryukov [Sat, 14 Apr 2018 16:27:35 +0000 (16:27 +0000)]
[clangd] Fix label and snippet for funcs in the index

This is a follow-up to r330004 to fix functions with required template args,
e.g. std::make_shared.

llvm-svn: 330087

6 years ago[InstCombine] add shift+logic tests (PR37098); NFC
Sanjay Patel [Sat, 14 Apr 2018 13:39:02 +0000 (13:39 +0000)]
[InstCombine] add shift+logic tests (PR37098); NFC

It debateable whether instcombine should be in the business of
reassociation, but it is currently.

These tests and PR37098 demonstrate a missing ability to do a
simple reassociation that allows eliminating shifts.

If we decide that functionality belongs somewhere else, then we
should still have some tests to show that we've intentionally
limited instcombine to *not* include this ability.

llvm-svn: 330086

6 years ago[X86][MMX] Set PAVG/PHADD/PMIN/PMAX/PSIGN instructions to use same scheduler classes...
Simon Pilgrim [Sat, 14 Apr 2018 13:06:38 +0000 (13:06 +0000)]
[X86][MMX] Set PAVG/PHADD/PMIN/PMAX/PSIGN instructions to use same scheduler classes as SSE/AVX

llvm-svn: 330085

6 years agoReapply "Cleanup DWARFCompileUnit and DWARFUnit in preparation for adding DWARFTypeUnit".
Jan Kratochvil [Sat, 14 Apr 2018 11:12:52 +0000 (11:12 +0000)]
Reapply "Cleanup DWARFCompileUnit and DWARFUnit in preparation for adding DWARFTypeUnit".

This patch by Greg Clayton drops the virtualization for DWARFPartialUnit.
The virtualization of DWARFUnit now matches more its LLVM counterpart.
DWZ patchset is going to be implementable without DWARFPartialUnit remapping.
https://reviews.llvm.org/D40474

This reverts commit 329423.
This reapplies commit r329305.

llvm-svn: 330084

6 years ago[NFC] fix trivial typos in document and comments
Hiroshi Inoue [Sat, 14 Apr 2018 08:59:00 +0000 (08:59 +0000)]
[NFC] fix trivial typos in document and comments

"not not" -> "not" etc

llvm-svn: 330083

6 years ago[AMDGPU] Add gfx902 product names
Tony Tye [Sat, 14 Apr 2018 01:58:10 +0000 (01:58 +0000)]
[AMDGPU] Add gfx902 product names

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

llvm-svn: 330081

6 years agoRevert "[Serialization] Fix some Clang-tidy modernize and Include What You Use warnin...
Vedant Kumar [Sat, 14 Apr 2018 01:40:48 +0000 (01:40 +0000)]
Revert "[Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC)."

This reverts commit r330068. It breaks the lldb bots due to assertion
failures (more details on cfe-commits).

http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/
http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/6341/

stderr: Assertion failed: (M && "imported decl from no module file"), function loadPendingDeclChain, file /Users/vsk/src/llvm.org-lldbsan/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp, line 3861.
llvm-svn: 330080

6 years ago[WebAssembly] Fix a bug in MachineBasicBlock::findDebugLoc() call
Heejin Ahn [Sat, 14 Apr 2018 00:12:12 +0000 (00:12 +0000)]
[WebAssembly] Fix a bug in MachineBasicBlock::findDebugLoc() call

Summary:
InsertPos is within the bacic block `Header`, so `findDebugLoc()` should
be called on not `MBB` but `Header` instead.

Reviewers: yurydelendik

Subscribers: jfb, dschuff, aprantl, sbc100, jgravelle-google, sunfish, JDevlieghere, llvm-commits

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

llvm-svn: 330079

6 years ago[X86] Add the bizarro movsww and movzww mnemonics for the disassembler.
Craig Topper [Fri, 13 Apr 2018 23:57:54 +0000 (23:57 +0000)]
[X86] Add the bizarro movsww and movzww mnemonics for the disassembler.

The destination size of the movzx/movsx instruction is controlled by the normal operand size mechanisms. Only the input type is fixed.

This means that a 0x66 prefix on the encoding for zext/sext 16->32 should really produce a 16->16 instruction. Functionally this is equivalent to a GR16->GR16 move since bits 16 and above will be preserved. So nothing is actually extended.

llvm-svn: 330078

6 years ago[Driver] Export profiling symbols for -exported_symbols_list
Vedant Kumar [Fri, 13 Apr 2018 23:43:59 +0000 (23:43 +0000)]
[Driver] Export profiling symbols for -exported_symbols_list

When profiling is enabled and -exported_symbols_list is specified for
the Darwin linker, export the requisite set of profiling symbols.

rdar://39427167

llvm-svn: 330077

6 years ago[Fuzzer] Avoid C++ compiler checks for fuzzer C++ library
Petr Hosek [Fri, 13 Apr 2018 23:05:14 +0000 (23:05 +0000)]
[Fuzzer] Avoid C++ compiler checks for fuzzer C++ library

When bulding libFuzzer as part of the toolchain, C++ library may not
have been fully built yet so the C++ compiler checks will fail, but we
don't care since we don't need C++ library anyway as we're building
our own.

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

llvm-svn: 330075

6 years ago[ODRHash] Support pointer and reference types.
Richard Trieu [Fri, 13 Apr 2018 22:34:43 +0000 (22:34 +0000)]
[ODRHash] Support pointer and reference types.

Recommit r328404 which was reverted in rL328404.  r329869 fixed the issue that
caused the revert.

llvm-svn: 330074

6 years agoMachO: trap unreachable instructions
Tim Northover [Fri, 13 Apr 2018 22:25:20 +0000 (22:25 +0000)]
MachO: trap unreachable instructions

Debugability is more important than saving 4 bytes to let us to fall
through to nonense.

llvm-svn: 330073

6 years ago[InstCombine][NFC] masked-merge: add 'and' tests, too.
Roman Lebedev [Fri, 13 Apr 2018 21:57:01 +0000 (21:57 +0000)]
[InstCombine][NFC] masked-merge: add 'and' tests, too.

(and plain 'or', for completeness sake.)

After submitting D45631, i have realized that it will *already*
affect 'and' pattern, and it was obvious that there were no
good test patterns to show that.

Since the masked-merge.ll is getting kinda big,
unify naming schemes a bit, and split into 'xor'/'and'/'or'
testfiles, with the only difference being the last operation.

llvm-svn: 330072

6 years agoRevert "[debugserver] Remove dead function call. NFCI."
Davide Italiano [Fri, 13 Apr 2018 21:26:32 +0000 (21:26 +0000)]
Revert "[debugserver] Remove dead function call. NFCI."

This reverts commit r330066 as it was wrong and the call was
not dead. Thanks to Fred for pointing this out.

llvm-svn: 330071

6 years ago[DebugInfo][OPT] NFC follow-up on "Fixing a couple of DI duplication bugs of CloneModule"
Roman Tereshin [Fri, 13 Apr 2018 21:23:11 +0000 (21:23 +0000)]
[DebugInfo][OPT] NFC follow-up on "Fixing a couple of DI duplication bugs of CloneModule"

llvm-svn: 330070

6 years ago[DebugInfo][OPT] Fixing a couple of DI duplication bugs of CloneModule
Roman Tereshin [Fri, 13 Apr 2018 21:22:24 +0000 (21:22 +0000)]
[DebugInfo][OPT] Fixing a couple of DI duplication bugs of CloneModule

As demonstrated by the regression tests added in this patch, the
following cases are valid cases:

1. A Function with no DISubprogram attached, but various debug info
  related to its instructions, coming, for instance, from an inlined
  function, also defined somewhere else in the same module;
2. ... or coming exclusively from the functions inlined and eliminated
  from the module entirely.

The ValueMap shared between CloneFunctionInto calls within CloneModule
needs to contain identity mappings for all of the DISubprogram's to
prevent them from being duplicated by MapMetadata / RemapInstruction
calls, this is achieved via DebugInfoFinder collecting all the
DISubprogram's. However, CloneFunctionInto was missing calls into
DebugInfoFinder for functions w/o DISubprogram's attached, but still
referring DISubprogram's from within (case 1). This patch fixes that.

The fix above, however, exposes another issue: if a module contains a
DISubprogram referenced only indirectly from other debug info
metadata, but not attached to any Function defined within the module
(case 2), cloning such a module causes a DICompileUnit duplication: it
will be moved in indirecty via a DISubprogram by DebugInfoFinder first
(because of the first bug fix described above), without being
self-mapped within the shared ValueMap, and then will be copied during
named metadata cloning. So this patch makes sure DebugInfoFinder
visits DICompileUnit's referenced from DISubprogram's as it goes w/o
re-processing llvm.dbg.cu list over and over again for every function
cloned, and makes sure that CloneFunctionInto self-maps
DICompileUnit's referenced from the entire function, not just its own
DISubprogram attached that may also be missing.

The most convenient way of tesing CloneModule I found is to rely on
CloneModule call from `opt -run-twice`, instead of writing tedious
unit tests. That feature has a couple of properties that makes it hard
to use for this purpose though:

1. CloneModule doesn't copy source filename, making `opt -run-twice`
  report it as a difference.
2. `opt -run-twice` does the second run on the original module, not
  its clone, making the result of cloning completely invisible in opt's
  actual output with and without `-run-twice` both, which directly
  contradicts `opt -run-twice`s own error message.

This patch fixes this as well.

Reviewed By: aprantl

Reviewers: loladiro, GorNishanov, espindola, echristo, dexonsmith

Subscribers: vsk, debug-info, JDevlieghere, llvm-commits

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

llvm-svn: 330069