platform/upstream/llvm.git
4 years ago[lld-macho] Delete dylink-lazy test for now
Jez Ng [Sun, 10 May 2020 09:22:33 +0000 (02:22 -0700)]
[lld-macho] Delete dylink-lazy test for now

Summary: It's breaking Windows builds

4 years ago[lld-macho] Try to unbreak dylink-lazy test on Windows
Jez Ng [Sun, 10 May 2020 07:22:36 +0000 (00:22 -0700)]
[lld-macho] Try to unbreak dylink-lazy test on Windows

4 years agoAdd missing pass initialization
Arthur Eubanks [Sat, 9 May 2020 03:19:05 +0000 (20:19 -0700)]
Add missing pass initialization

Summary: This was preventing MemorySanitizerLegacyPass from appearing in --print-after-all.

Reviewers: vitalybuka

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[lld-macho] Support pc-relative section relocations
Jez Ng [Mon, 27 Apr 2020 19:59:20 +0000 (12:59 -0700)]
[lld-macho] Support pc-relative section relocations

Summary: So far we've only supported symbol relocations.

Reviewers: ruiu, pcc, MaskRay, smeenai, alexshap, gkm, Ktwu, christylee

Subscribers: llvm-commits

Tags: #llvm

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

4 years ago[lld-macho] Use export trie instead of symtab when linking against dylibs
Jez Ng [Thu, 23 Apr 2020 03:00:57 +0000 (20:00 -0700)]
[lld-macho] Use export trie instead of symtab when linking against dylibs

Summary:
This allows us to link against stripped dylibs. Moreover, it's simply
more correct: The symbol table includes symbols that the dylib uses but
doesn't export.

This temporarily regresses our ability to do lazy symbol binding because
dyld_stub_binder isn't in libSystem's export trie. Rather, it is in one
of the sub-libraries libSystem re-exports. (This doesn't affect our
tests since we are mocking out dyld_stub_binder there.) A follow-up diff
will address this by adding support for sub-libraries.

Depends on D79114.

Reviewers: ruiu, pcc, MaskRay, smeenai, alexshap, gkm, Ktwu, christylee

Subscribers: mgorny, llvm-commits

Tags: #llvm

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

4 years ago[lld-macho] Dylib symbols should always replace undefined symbols
Jez Ng [Wed, 29 Apr 2020 12:30:47 +0000 (05:30 -0700)]
[lld-macho] Dylib symbols should always replace undefined symbols

Summary:
Otherwise we get undefined symbol errors depending on the order of
arguments on the command line.

Depends on D78270.

Reviewers: ruiu, pcc, MaskRay, smeenai, alexshap, gkm, Ktwu, christylee

Subscribers: llvm-commits

Tags: #llvm

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

4 years ago[lld-macho] Support calls to functions in dylibs
Jez Ng [Wed, 6 May 2020 00:38:10 +0000 (17:38 -0700)]
[lld-macho] Support calls to functions in dylibs

Summary:
This diff implements lazy symbol binding -- very similar to the PLT
mechanism in ELF.

ELF's .plt section is broken up into two sections in Mach-O:
StubsSection and StubHelperSection. Calls to functions in dylibs will
end up calling into StubsSection, which contains indirect jumps to
addresses stored in the LazyPointerSection (the counterpart to ELF's
.plt.got).

Initially, the LazyPointerSection contains addresses that point into one
of the entry points in the middle of the StubHelperSection. The code in
StubHelperSection will push on the stack an offset into the
LazyBindingSection. The push is followed by a jump to the beginning of
the StubHelperSection (similar to PLT0), which then calls into
dyld_stub_binder. dyld_stub_binder is a non-lazily bound symbol, so this
call looks it up in the GOT.

The stub binder will look up the bind opcodes in the LazyBindingSection
at the given offset. The bind opcodes will tell the binder to update the
address in the LazyPointerSection to point to the symbol, so that
subsequent calls don't have to redo the symbol resolution. The binder
will then jump to the resolved symbol.

Depends on D78269.

Reviewers: ruiu, pcc, MaskRay, smeenai, alexshap, gkm, Ktwu, christylee

Subscribers: llvm-commits

Tags: #llvm

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

4 years ago[lld-macho] Follow-up to D77893
Jez Ng [Wed, 6 May 2020 00:25:58 +0000 (17:25 -0700)]
[lld-macho] Follow-up to D77893

Summary:
1. Don't have isHidden() depend on isNeeded(). Whether a section is
  hidden is orthogonal from whether it is needed: hidden sections will
  never have a header regardless of whether they have a body. (I know we
  override this method with return false for synthetic sections, but
  regardless I think it's confusing to write it this way for non-synthetic
  sections.)

2. Don't call writeTo() on unneeded sections. D78270 assumes that this
  is true when implementing the stub helper section.

3. Filter out the unneeded sections early on to avoid having to deal
   with them in multiple places.

4. Remove assumption in test that the referenced file has no other symbols.
  (We should create separate input files for future tests to avoid such
  issues.)

Reviewers: ruiu, pcc, MaskRay, smeenai, alexshap, gkm, Ktwu, christylee

Subscribers: llvm-commits

Tags: #llvm

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

4 years ago[sanitizer] Enable whitelist/blacklist in new PM
Jinsong Ji [Sun, 10 May 2020 02:33:57 +0000 (02:33 +0000)]
[sanitizer] Enable whitelist/blacklist in new PM

https://reviews.llvm.org/D63616 added `-fsanitize-coverage-whitelist`
and `-fsanitize-coverage-blacklist` for clang.

However, it was done only for legacy pass manager.
This patch enable it for new pass manager as well.

Reviewed By: vitalybuka

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

4 years ago[X86] Add test cases for vXi16 PMULH opportunities that don't end in truncate.
Craig Topper [Sun, 10 May 2020 00:04:34 +0000 (17:04 -0700)]
[X86] Add test cases for vXi16 PMULH opportunities that don't end in truncate.

We already have matching for extend+mul+shift+trunc. But we could
also match up to the shift without the truncate and just extend the
result. That would still be a savings.

4 years agoGlobalISel: Handle more cases in lowerUnmergeValues
Matt Arsenault [Sun, 29 Mar 2020 22:04:53 +0000 (18:04 -0400)]
GlobalISel: Handle more cases in lowerUnmergeValues

Handle scalar sources, as well as vectors.

4 years ago[BreakFalseDeps] Harden pickBestRegisterForUndef against changing tied operands or...
Craig Topper [Sat, 9 May 2020 22:33:08 +0000 (15:33 -0700)]
[BreakFalseDeps] Harden pickBestRegisterForUndef against changing tied operands or physical registers that aren't renamable.

I don't have any test cases since X86 doesn't return any tied
operands from getUndefRegClearance today. But conceivably we could
want BreakFalseDeps to insert a dependency breaking XOR for
a tied operand in the future.

4 years ago[LAA] Remove unneeded PtrRtChecking argument (NFC).
Florian Hahn [Sat, 9 May 2020 21:07:51 +0000 (22:07 +0100)]
[LAA] Remove unneeded PtrRtChecking argument (NFC).

The argument is not required and simplifies D78460 a bit.

4 years ago[X86] isVectorShiftByScalarCheap - don't limit fast XOP vector shifts to 128-bit...
Simon Pilgrim [Sat, 9 May 2020 21:09:01 +0000 (22:09 +0100)]
[X86] isVectorShiftByScalarCheap - don't limit fast XOP vector shifts to 128-bit vectors

XOP targets have fast per-element vector shifts and we're better off splitting to 128-bit shifts where necessary (which is what we already do in LowerShift).

4 years ago[Clang] Pass -z max-page-size to linker for Fuchsia
Petr Hosek [Sat, 9 May 2020 20:44:20 +0000 (13:44 -0700)]
[Clang] Pass -z max-page-size to linker for Fuchsia

Currently all Fuchsia ABIs use a 4k page size, departing from
the recommended page sizes in the respective psABI documents.

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

4 years ago[Clang] Pass --pack-dyn-relocs=relr to lld for Fuchsia
Petr Hosek [Sat, 9 May 2020 20:42:19 +0000 (13:42 -0700)]
[Clang] Pass --pack-dyn-relocs=relr to lld for Fuchsia

The compact format is fully supported on Fuchsia and is the
preferred default.

Patch By: mcgrathr

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

4 years agoGlobalISel: Move code into lowering for G_MERGE_VALUES
Matt Arsenault [Sun, 29 Mar 2020 19:51:54 +0000 (15:51 -0400)]
GlobalISel: Move code into lowering for G_MERGE_VALUES

Currently this code exists in widenScalar for G_MERGE_VALUE
sources. I'm not sure if the existing expansion in widenScalar should
be removed or not. The widenScalar variant tries to extend to the
requested size, but this just uses the original bitwidth.

4 years agoGlobalISel: Combine G_UNMERGE_VALUES with G_TRUNC
Matt Arsenault [Sat, 4 Apr 2020 19:07:28 +0000 (15:07 -0400)]
GlobalISel: Combine G_UNMERGE_VALUES with G_TRUNC

G_BITCAST can be lowered with a pair of G_UNMERGE_VALUES and
G_MERGE_VALUES with different types, but G_UNMERGE_VALUES of a vector
can also be implemented with a bitcast to a scalar, which introduces
the possibility for infinite loops. Try to eliminate an illegal source
register type in the artifact combiner to avoid this from happening.

Avoids infinite looping in the legalizer in a future patch which
allows lowering G_UNMERGE_VALUES of a vector source with a G_BITCAST.

4 years agoInstCombine: Broaden copy-constant-to-alloca optimization
Matt Arsenault [Fri, 8 May 2020 19:35:41 +0000 (15:35 -0400)]
InstCombine: Broaden copy-constant-to-alloca optimization

Consider any constant memory type, not just global constants. AMDGPU
kernel parameters are effectively global constants, but appear as
either reads from an intrinsic derived pointer or function argument.

4 years agoFix typo
Matt Arsenault [Wed, 6 May 2020 00:25:03 +0000 (20:25 -0400)]
Fix typo

4 years agoAMDGPU: Skip GetUnderlyingObject check in pointsToConstantMemory
Matt Arsenault [Fri, 8 May 2020 19:53:41 +0000 (15:53 -0400)]
AMDGPU: Skip GetUnderlyingObject check in pointsToConstantMemory

Check the address space first before searching for the object
definition to save compile time. As an added bonus, this will now
treat casts to constant addrspace as constant.

We also seemed to be missing targeted tests for this, so add a few
missing other cases too.

4 years ago[CodeGenPrepare][X86] Add x16i16, v32i8 and XOP vector shift by scalar amount tests
Simon Pilgrim [Sat, 9 May 2020 14:54:53 +0000 (15:54 +0100)]
[CodeGenPrepare][X86] Add x16i16, v32i8 and XOP vector shift by scalar amount tests

Helps improve test coverage of the XOP modes in X86TargetLowering::isVectorShiftByScalarCheap (and where we always return false for vXi8 vector shifts).

4 years ago[X86] Add XOP vector shift by scalar amount tests
Simon Pilgrim [Sat, 9 May 2020 14:53:06 +0000 (15:53 +0100)]
[X86] Add XOP vector shift by scalar amount tests

Helps improve test coverage of the XOP modes in X86TargetLowering::isVectorShiftByScalarCheap

4 years ago[X86] Teach getUndefRegClearance that we use undef for inputs to PUNPCK in some cases.
Craig Topper [Sat, 9 May 2020 18:25:36 +0000 (11:25 -0700)]
[X86] Teach getUndefRegClearance that we use undef for inputs to PUNPCK in some cases.

This enables the register to be changed from XMM/YMM/ZMM0 to
instead match the other source. This prevents a false
dependency.

I added all the integer unpck instructions, but the tests
only show changes for BW and WD.

Unfortunately, we can have undef on operand 1 or 2 of the AVX
instructions. This breaks the interface with hasUndefRegUpdate
which used to tell which operand to check.

Now we scan the input operands looking for an undef register and
then ask hasUndefRegUpdate if its an instruction we care about
and which operands of that instruction we care about.

I also had to make some changes to the load folding code to
always pass operand 1 to hasUndefRegUpdate. I've updated
hasUndefRegUpdate to return false when ForLoadFold is set for
instructions that are not explicitly blocked for load folding in
isel patterns.

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

4 years ago[X86] Add an assert that v32i16/v64i8 splitting in LowerVSETCC should only occur...
Craig Topper [Sat, 9 May 2020 18:23:27 +0000 (11:23 -0700)]
[X86] Add an assert that v32i16/v64i8 splitting in LowerVSETCC should only occur when AVX512BW is disabled. NFC

With BWI we should only get a v32i1/v64i1 result type.

4 years ago[ARM] Convert VDUPLANE to VDUP under MVE
David Green [Sat, 9 May 2020 14:17:50 +0000 (15:17 +0100)]
[ARM] Convert VDUPLANE to VDUP under MVE

Unlike Neon, MVE does not have a way of duplicating from a vector lane,
so a VDUPLANE currently selects to a VDUP(move_from_lane(..)). This
forces that to be done earlier as a dag combine to allow other folds to
happen.

It converts to a VDUP(EXTRACT). On FP16 this is then folded to a
VGETLANEu to prevent it from creating a vmovx;vmovhr pair, using a
single move_from_reg instead.

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

4 years ago[NFC] Small rework to RenamerClangTidyCheck addUsage
Nathan James [Sat, 9 May 2020 17:57:05 +0000 (18:57 +0100)]
[NFC] Small rework to RenamerClangTidyCheck addUsage

4 years ago[lldb/debugserver] Include TargetConditionals.h where needed
Fred Riss [Sat, 9 May 2020 17:11:28 +0000 (10:11 -0700)]
[lldb/debugserver] Include TargetConditionals.h where needed

MachProcess.mm uses a TARGET_OS_ macro without directly including
TargetConditionals.h. This currently works as we get the header
as an indirect dependency, but might not in the future.

I just spent some time investigating an internal regression
caused by a similar issue, so I audited the codebase for such
cases.

4 years ago[clangd] Fix data race in BackgroundIndex test
Kadir Cetinkaya [Sat, 9 May 2020 16:14:48 +0000 (18:14 +0200)]
[clangd] Fix data race in BackgroundIndex test

MockFSProvider is not thread-safe. Make sure we don't modify it while
background index is working.

4 years ago[flang] Make implicit conversion explicit in assignment
Tim Keith [Sat, 9 May 2020 16:10:08 +0000 (09:10 -0700)]
[flang] Make implicit conversion explicit in assignment

When intrinsic types are assigned there are some implicit conversions
that take place. This change make them explicit in the types
representation of assignments.

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

4 years ago[clang-tidy] RenamerClangTidy now renames dependent member expr when the member can...
Nathan James [Fri, 8 May 2020 18:30:18 +0000 (19:30 +0100)]
[clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

Summary:
Sometimes in templated code Member references are reported as `DependentScopeMemberExpr` because that's what the standard dictates, however in many trivial cases it is easy to resolve the reference to its actual Member.
Take this code:
```
template<typename T>
class A{
  int value;
  A& operator=(const A& Other){
    value = Other.value;
    this->value = Other.value;
    return *this;
  }
};
```
When ran with `clang-tidy file.cpp -checks=readability-identifier-naming --config="{CheckOptions: [{key: readability-identifier-naming.MemberPrefix, value: m_}]}" -fix`
Current behaviour:
```
template<typename T>
class A{
  int m_value;
  A& operator=(const A& Other){
    m_value = Other.value;
    this->value = Other.value;
    return *this;
  }
};
```
As `this->value` and `Other.value` are Dependent they are ignored when creating the fix-its, however this can easily be resolved.
Proposed behaviour:
```
template<typename T>
class A{
  int m_value;
  A& operator=(const A& Other){
    m_value = Other.m_value;
    this->m_value = Other.m_value;
    return *this;
  }
};
```

Reviewers: aaron.ballman, JonasToth, alexfh, hokein, gribozavr2

Reviewed By: aaron.ballman

Subscribers: merge_guards_bot, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

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

4 years ago[libcxx testing] Make three locking tests more reliable
David Zarzycki [Sat, 9 May 2020 15:10:41 +0000 (11:10 -0400)]
[libcxx testing] Make three locking tests more reliable

The challenge with measuring time in tests is that slow and/or busy
machines can cause tests to fail in unexpected ways. After this change,
three tests should be much more robust. The only remaining and tiny race
that I can think of is preemption after `--countDown`. That being said,
the race isn't fixable because the standard library doesn't provide a
way to count threads that are waiting to acquire a lock.

Reviewers: ldionne, EricWF, howard.hinnant, mclow.lists, #libc

Reviewed By: ldionne, #libc

Subscribers: dexonsmith, jfb, broadwaylamb, libcxx-commits

Tags: #libc

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

4 years agoLTO.h - reduce includes to forward declarations. NFC.
Simon Pilgrim [Sat, 9 May 2020 14:10:51 +0000 (15:10 +0100)]
LTO.h - reduce includes to forward declarations. NFC.

Add missing ToolOutputFile.h dependency to BackendUtil.cpp

4 years agoLLParser.h - remove unused ValueHandle.h include. NFC.
Simon Pilgrim [Sat, 9 May 2020 14:08:48 +0000 (15:08 +0100)]
LLParser.h - remove unused ValueHandle.h include. NFC.

4 years ago[X86] Remove mul(abs(x),abs(x)) -> mul(x,x) tests
Simon Pilgrim [Sat, 9 May 2020 14:07:15 +0000 (15:07 +0100)]
[X86] Remove mul(abs(x),abs(x)) -> mul(x,x) tests

This is handled in InstCombine (D79319) and its unlikely that these can occur in DAG (see D79304).

4 years ago[X86] Allow combineVectorCompareAndMaskUnaryOp to handle 'all-bits' general case
Simon Pilgrim [Sat, 9 May 2020 13:53:07 +0000 (14:53 +0100)]
[X86] Allow combineVectorCompareAndMaskUnaryOp to handle 'all-bits' general case

For the sint_to_fp(and(X,C)) -> and(X,sint_to_fp(C)) fold, allow combineVectorCompareAndMaskUnaryOp to match any X that ComputeNumSignBits says is all-bits, not just SETCC.

Noticed while investigating mask promotion issues in PR45808

4 years ago[X86] Add test cases for 'abs from mul patterns' (PR45691)
Simon Pilgrim [Sat, 9 May 2020 13:41:27 +0000 (14:41 +0100)]
[X86] Add test cases for 'abs from mul patterns' (PR45691)

4 years ago[clangd] Fix a data race in RecordsLatencies test
Kadir Cetinkaya [Sat, 9 May 2020 13:42:15 +0000 (15:42 +0200)]
[clangd] Fix a data race in RecordsLatencies test

4 years ago[X86] Add tests showing failure of combineVectorCompareAndMaskUnaryOp to handle ...
Simon Pilgrim [Sat, 9 May 2020 13:24:38 +0000 (14:24 +0100)]
[X86] Add tests showing failure of combineVectorCompareAndMaskUnaryOp to handle 'all-bits' general case

For the sint_to_fp(and(X,C)) -> and(X,sint_to_fp(C)) fold, combineVectorCompareAndMaskUnaryOp only matches X against SETCC (with an all-bits result) when really it could accept anything that ComputeNumSignBits says is all-bits.

Noticed while investigating mask promotion issues in PR45808

4 years agoNativeFormatting.h - reduce raw_ostream.h include to forward declaration. NFC.
Simon Pilgrim [Sat, 9 May 2020 12:31:39 +0000 (13:31 +0100)]
NativeFormatting.h - reduce raw_ostream.h include to forward declaration. NFC.

4 years ago[clang-format] [PR34574] Handle [[nodiscard]] attribute in class declaration
mydeveloperday [Sat, 9 May 2020 10:26:38 +0000 (11:26 +0100)]
[clang-format] [PR34574] Handle [[nodiscard]] attribute in class declaration

Summary:
https://bugs.llvm.org/show_bug.cgi?id=34574
https://bugs.llvm.org/show_bug.cgi?id=38401

```
template <typename T>
class [[nodiscard]] result
{
  public:
    result(T&&)
    {
    }
};
```

formats incorrectly to

```
template <typename T>
class [[nodiscard]] result{public : result(T &&){}};
```

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang, #clang-format

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

4 years ago[MLIR] Register JIT event listeners with RTDyldObjectLinkingLayer
Eugene Zhulenev [Sat, 9 May 2020 09:13:50 +0000 (11:13 +0200)]
[MLIR] Register JIT event listeners with RTDyldObjectLinkingLayer

Use a new API to register JIT event listeners.

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

4 years ago[lldb] [testsuite] TestReproducerAttach.py: Fix dependency on external symbol files
Jan Kratochvil [Sat, 9 May 2020 07:06:37 +0000 (09:06 +0200)]
[lldb] [testsuite] TestReproducerAttach.py: Fix dependency on external symbol files

D55859 and D63339 prevented needless dependencies on system symbol
files. This testcase was checked-in afterwards and it brings back one
such unwanted dependency. Under some circumstances it may cause false
FAILs and/or excessive resource usage to run the testcase.

clang-format does not support .py so I have formatted it as I found most
compatible.

Also this is not a full testcase-style initialization, for example
--no-lldbinit ignores env("NO_LLDBINIT") setting which lldbtest.py does
implement:
  # If we spawn an lldb process for test (via pexpect), do not load the
  # init file unless told otherwise.
  if os.environ.get("NO_LLDBINIT") != "NO":
      self.lldbOption += " --no-lldbinit"

But this is what lldbpexpect.py does - it also ignores
env("NO_LLDBINIT"). Sure one could also fix lldbpexpect.py to unify the
initialization more with lldbtest.py but I find that outside of the
scope of this patch.

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

4 years ago[Driver] Don't pass -u__llvm_profile_runtime for clang -fprofile-arcs a.o
Fangrui Song [Sat, 9 May 2020 06:13:19 +0000 (23:13 -0700)]
[Driver] Don't pass -u__llvm_profile_runtime for clang -fprofile-arcs a.o

clang --coverage a.o       # InstrProfilingRuntime.cpp.o not linked in
clang --fprofile-arcs a.o  # InstrProfilingRuntime.cpp.o unexpectedly linked in

Fix --fprofile-arcs.

4 years ago[NFC] Clean up in MCObjectStreamer and X86AsmBackend
Shengchen Kan [Sat, 9 May 2020 04:47:44 +0000 (12:47 +0800)]
[NFC] Clean up in MCObjectStreamer and X86AsmBackend

4 years agoRevert "Relands "[YAMLVFSWriter][Test][NFC] Add couple tests""
Jan Korous [Sat, 9 May 2020 04:36:29 +0000 (21:36 -0700)]
Revert "Relands "[YAMLVFSWriter][Test][NFC] Add couple tests""

This reverts commit 49b32d80416288b6eb8e26f76c40a8e32c20a361.

4 years ago[DebugInfo] Dump raw data in a case of decoding error of an expression.
Igor Kudrin [Sat, 9 May 2020 03:03:38 +0000 (10:03 +0700)]
[DebugInfo] Dump raw data in a case of decoding error of an expression.

It looks like that was an initial intention, but some code paths in
`DWARFExpression::Operation::extract()` did not initialize `EndOffset`
properly.

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

4 years agoFix parsing of enum-base to follow C++11 rules.
Richard Smith [Sat, 9 May 2020 02:24:18 +0000 (19:24 -0700)]
Fix parsing of enum-base to follow C++11 rules.

Previously we implemented non-standard disambiguation rules to
distinguish an enum-base from a bit-field but otherwise treated a :
after an elaborated-enum-specifier as introducing an enum-base. That
misparses various examples (anywhere an elaborated-type-specifier can
appear followed by a colon, such as within a ternary operator or
_Generic).

We now implement the C++11 rules, with the old cases accepted as
extensions where that seemed reasonable. These amount to:
 * an enum-base must always be accompanied by an enum definition (except
   in a standalone declaration of the form 'enum E : T;')
 * in a member-declaration, 'enum E :' always introduces an enum-base,
   never a bit-field
 * in a type-specifier (or similar context), 'enum E :' is not
   permitted; the colon means whatever else it would mean in that
   context.

Fixed underlying types for enums are also permitted in Objective-C and
under MS extensions, plus as a language extension in all other modes.
The behavior in ObjC and MS extensions modes is unchanged (but the
bit-field disambiguation is a bit better); remaining language modes
follow the C++11 rules.

Fixes PR45726, PR39979, PR19810, PR44941, and most of PR24297, plus C++
core issues 1514 and 1966.

4 years agoRelands "[YAMLVFSWriter][Test][NFC] Add couple tests"
Jan Korous [Fri, 8 May 2020 02:11:51 +0000 (19:11 -0700)]
Relands "[YAMLVFSWriter][Test][NFC] Add couple tests"

Fixed test for Windows.

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

4 years agoclang: Cleanup usage of CreateMemCpy
Matt Arsenault [Fri, 8 May 2020 18:39:07 +0000 (14:39 -0400)]
clang: Cleanup usage of CreateMemCpy

It handles the the pointee type casts in preparation for opaque
pointers.

4 years ago[Driver] Add -fno-test-coverage
Fangrui Song [Fri, 8 May 2020 23:50:34 +0000 (16:50 -0700)]
[Driver] Add -fno-test-coverage

4 years ago[hwasan] Allow -hwasan-globals flag to appear more than once.
Evgenii Stepanov [Fri, 8 May 2020 23:30:45 +0000 (16:30 -0700)]
[hwasan] Allow -hwasan-globals flag to appear more than once.

4 years ago[hwasan] Untag destination address in hwasan_posix_memalign.
Evgenii Stepanov [Fri, 8 May 2020 23:29:46 +0000 (16:29 -0700)]
[hwasan] Untag destination address in hwasan_posix_memalign.

Required on X86 because no TBI.

4 years ago[Driver] Don't warn -Wunused-command-line-argument for --coverage -ftest-coverage...
Fangrui Song [Fri, 8 May 2020 23:14:41 +0000 (16:14 -0700)]
[Driver] Don't warn -Wunused-command-line-argument for --coverage -ftest-coverage -fprofile-arcs

4 years ago[LangRef] Describe linkage types, allocation size of declarations for global variables
Matthias Schiffer [Fri, 8 May 2020 23:20:43 +0000 (16:20 -0700)]
[LangRef] Describe linkage types, allocation size of declarations for global variables

Linkage type was only referenced for functions, not for global
variables.

Clarify that LLVM doesn't make assumption about the allocation size when
no definitive initializer for a global variable is known.

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

4 years ago[Driver] Reorganize --coverage -ftest-coverage -fprofile-arcs related tests
Fangrui Song [Fri, 8 May 2020 22:04:03 +0000 (15:04 -0700)]
[Driver] Reorganize --coverage -ftest-coverage -fprofile-arcs related tests

And fix a comment about __llvm_profile_runtime

4 years ago[SelectionDAG] Remove ConstantPoolSDNode::getAlignment.
Craig Topper [Fri, 8 May 2020 22:06:37 +0000 (15:06 -0700)]
[SelectionDAG] Remove ConstantPoolSDNode::getAlignment.

Use getAlign instead.

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

4 years ago[SelectionDAG] Use Align/MaybeAlign for ConstantPoolSDNode.
Craig Topper [Fri, 8 May 2020 22:06:15 +0000 (15:06 -0700)]
[SelectionDAG] Use Align/MaybeAlign for ConstantPoolSDNode.

This patch stores the alignment for ConstantPoolSDNode as an
Align and updates the getConstantPool interface to take a MaybeAlign.

Removing getAlignment() will be done as a follow up.

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

4 years agoAdd Operation::moveAfter
Geoffrey Martin-Noble [Fri, 8 May 2020 22:34:13 +0000 (22:34 +0000)]
Add Operation::moveAfter

This revision introduces an Operation::moveAfter mirroring
Operation::moveBefore to move an operation after another
existing operation or an iterator in a specified block.

Resolves https://bugs.llvm.org/show_bug.cgi?id=45799

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

4 years ago[AMDGPU] Vectorize alloca thru bitcast
Stanislav Mekhanoshin [Tue, 5 May 2020 23:17:53 +0000 (16:17 -0700)]
[AMDGPU] Vectorize alloca thru bitcast

This is mostly useful if alloca element type is not integer
and then casted to an integer for load or store. We now can
vectorize an [i32] alloca but cannot do so for [float].

There also a separate patch needed to properly lower 64 bit
types after they vectorized. At the moment these are lowered
via scratch anyway.

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

4 years ago[TRE][NFC] Refactor shared state into member variables.
Layton Kifer [Fri, 8 May 2020 21:18:53 +0000 (14:18 -0700)]
[TRE][NFC] Refactor shared state into member variables.

Separate functions that require shared state into a class to avoid
needing to pass them though multiple functions just to be available
where needed.

The main motivation for this is that we would like to remove the
limitation that accumulator values be dynamic constant, which would
require additional shared state between call eliminations in the same
function, compounding this issue.

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

4 years ago[COFF] Use Expected in COFFObjectFile creation
Reid Kleckner [Fri, 8 May 2020 20:58:56 +0000 (13:58 -0700)]
[COFF] Use Expected in COFFObjectFile creation

The constructor error out parameter was a bit awkward. Wrap it in a
factory method which can return an error. Make the constructor private.

4 years ago[COFF] Migrate COFFObjectFile to Expected<T>
Reid Kleckner [Fri, 8 May 2020 17:41:05 +0000 (10:41 -0700)]
[COFF] Migrate COFFObjectFile to Expected<T>

I noticed that std::error_code() does one-time initialization. Avoid
that overhead with Expected<T> and llvm::Error. Also, it is consistent
with the virtual interface and ELF, and generally cleaner.

Reviewed By: MaskRay

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

4 years ago[clang][WebAssembly] Only expose wait and notify builtins with atomics
Thomas Lively [Thu, 7 May 2020 00:17:48 +0000 (17:17 -0700)]
[clang][WebAssembly] Only expose wait and notify builtins with atomics

Summary:
Since the underlying wait and notify instructions are only available
when the atomics feature is enabled, it only makes sense to expose
their builtin functions when atomics are enabled.

Reviewers: aheejin, sunfish

Subscribers: dschuff, sbc100, jgravelle-google, jfb, cfe-commits

Tags: #clang

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

4 years ago[WebAssembly] Disallow 'shared-mem' rather than 'atomics'
Thomas Lively [Thu, 7 May 2020 02:33:24 +0000 (19:33 -0700)]
[WebAssembly] Disallow 'shared-mem' rather than 'atomics'

Summary:
The WebAssembly backend automatically lowers atomic operations and TLS
to nonatomic operations and non-TLS data when either are present and
the atomics or bulk-memory features are not present, respectively. The
resulting object is no longer thread-safe, so the linker has to be
told not to allow it to be linked into a module with shared
memory. This was previously done by disallowing the 'atomics' feature,
which prevented any objct with its atomic operations or TLS removed
from being linked with any object containing atomics or TLS, and
therefore preventing it from being linked into a module with shared
memory since shared memory requires atomics.

However, as of https://github.com/WebAssembly/threads/issues/144, the
validation rules are relaxed to allow atomic operations to validate
with unshared memories, which makes it perfectly safe to link an
object with stripped atomics and TLS with another object that still
contains TLS and atomics as long as the resulting module has an
unshared memory. To allow this kind of link, this patch disallows a
pseudo-feature 'shared-mem' rather than 'atomics' to communicate to
the linker that the object is not thread-safe. This means that the
'atomics' feature is available to accurately reflect whether or not an
object has atomics enabled.

As a drive-by tweak, this change also requires that bulk-memory be
enabled in addition to atomics in order to use shared memory. This is
because initializing shared memories requires bulk-memory operations.

Reviewers: aheejin, sbc100

Subscribers: dschuff, jgravelle-google, hiraditya, sunfish, jfb, llvm-commits

Tags: #llvm

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

4 years ago[Target][XCOFF] Correctly halt when mixing AIX or XCOFF with ppc64le
Hubert Tong [Fri, 8 May 2020 20:40:28 +0000 (16:40 -0400)]
[Target][XCOFF] Correctly halt when mixing AIX or XCOFF with ppc64le

The code to prevent using `PPCXCOFFMCAsmInfo` with little-endian targets
used an incorrect check. Also, there does not appear to be sufficient
earlier checking to prevent failing this check, so the check here is
upgraded to be a `report_fatal_error`.

`PPCAIXAsmPrinter` was also missing a check against use with
little-endian targets. This patch adds such a check in.

4 years ago[XCOFF] XCOFF constants, MCObjectFileInfo placeholder code for DWARF; NFC
Hubert Tong [Fri, 8 May 2020 20:32:12 +0000 (16:32 -0400)]
[XCOFF] XCOFF constants, MCObjectFileInfo placeholder code for DWARF; NFC

Summary:
This patch introduces the constants defined to identify DWARF sections
in XCOFF into `llvm/BinaryFormat/XCOFF.h` and adds (NFC) placeholder
code to `llvm/lib/MC/MCObjectFileInfo.cpp` where the DWARF sections for
XCOFF are to be set up.

Reviewers: jasonliu, sfertile, daltenty, DiggerLin, Xiangling_L

Reviewed By: jasonliu, sfertile, DiggerLin

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

4 years ago[AIX] Avoid structor alias; die before bad alias codegen
Hubert Tong [Fri, 8 May 2020 20:29:58 +0000 (16:29 -0400)]
[AIX] Avoid structor alias; die before bad alias codegen

Summary:
`AsmPrinter::emitGlobalIndirectSymbol` is dependent on
`MCStreamer::emitAssignment` to produce `.set` directives for alias
symbols; however, the `.set` pseudo-op on AIX is documented as not
usable with external relocatable terms or expressions, which limits its
applicability in generating alias symbols.

Disable generating aliases on AIX until a different implementation
strategy is available.

Reviewers: cebowleratibm, jasonliu, sfertile, daltenty, DiggerLin

Reviewed By: jasonliu

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

4 years ago[GlobalISel] Don't add duplicate successors to MBBs when translating indirectbr
Jessica Paquette [Thu, 7 May 2020 23:25:34 +0000 (16:25 -0700)]
[GlobalISel] Don't add duplicate successors to MBBs when translating indirectbr

This fixes a verifier failure on a bot:

http://green.lab.llvm.org/green/job/test-suite-verify-machineinstrs-aarch64-O0-g/

```
*** Bad machine code: MBB has duplicate entries in its successor list. ***
- function:    foo
- basic block: %bb.5 indirectgoto (0x7fe3d687ca08)
```

One of the GCC torture suite tests (pr70460.c) has an indirectbr instruction
which has duplicate blocks in its destination list.

According to the langref this is allowed:

> Blocks are allowed to occur multiple times in the destination list, though
> this isn’t particularly useful.
(https://www.llvm.org/docs/LangRef.html#indirectbr-instruction)

We don't allow this in MIR. So, when we translate such an instruction, the
verifier screams.

This patch makes `translateIndirectBr` check if a successor has already been
added to a block. If the successor is present, it is skipped rather than added
twice.

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

4 years ago[VectorCombine] scalarize binop of inserted elements into vector constants
Sanjay Patel [Fri, 8 May 2020 20:29:07 +0000 (16:29 -0400)]
[VectorCombine] scalarize binop of inserted elements into vector constants

As with the extractelement patterns that are currently in vector-combine,
there are going to be several possible variations on this theme. This
should be the clearest, simplest example.

Scalarization is the right direction for target-independent canonicalization,
and InstCombine has some of those folds already, but it doesn't do this.
I proposed a similar transform in D50992. Here in vector-combine, we can
check the cost model to be sure it's profitable, so there should be less risk.

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

4 years ago[lldb/Test] Update TestProcessList.py for reproducer replay
Jonas Devlieghere [Fri, 8 May 2020 20:12:22 +0000 (13:12 -0700)]
[lldb/Test] Update TestProcessList.py for reproducer replay

Because LLDB isn't the one spawning the subprocess, the PID is different
during replay. Exclude it form the substring check during replay.

Depends on D79646 to pass with reproducer replay.

4 years agoReland [libc++] Move abs and div into stdlib.h to fix header cycle.
Eric Fiselier [Sat, 15 Feb 2020 23:55:07 +0000 (18:55 -0500)]
Reland [libc++] Move abs and div into stdlib.h to fix header cycle.

This commit should will break libc++ without local submodule visibility, but
the LLVM+modules bots are now all using this mode. Before the Green Dragon
LLDB bot was failing to compile with a libc++ built with this commit as LSV
was disabled on macOS.

Original summary:

libc++ is careful to not fracture overload sets. When one overload
is visible to a user, all of them should be. Anything less causes
subtle bugs and ODR violations.

Previously, in order to support ::abs and ::div being supplied by
both <cmath> and <cstdlib> we had to do awful things that make
<math.h> and <stdlib.h> have header cycles and be non-modular.
This really breaks with modules.

Specifically the problem was that in C++ ::abs introduces overloads
for floating point numbers, these overloads forward to ::fabs,
which are defined in math.h. Therefore ::abs needed to be in math.h
too. But this required stdlib.h to include math.h and math.h to
include stdlib.h.

To avoid these problems the definitions have been moved to stddef.h
(which math includes), and the floating point overloads of ::abs
have been changed to call __builtin_fabs, which both Clang and GCC
support.

4 years ago[X86] Remove the mayLoad and mayStore flags from vzeroupper/vzeroall.
Craig Topper [Fri, 8 May 2020 19:32:19 +0000 (12:32 -0700)]
[X86] Remove the mayLoad and mayStore flags from vzeroupper/vzeroall.

But leave the hasUnmodelledSideEffects flag.

4 years ago[InstCombine] fix typo in comment; NFC
Sanjay Patel [Fri, 8 May 2020 19:42:54 +0000 (15:42 -0400)]
[InstCombine] fix typo in comment; NFC

4 years agoRe-commit: Mark values as trivially dead when their only use is a start or end lifeti...
zoecarver [Fri, 8 May 2020 19:22:39 +0000 (12:22 -0700)]
Re-commit: Mark values as trivially dead when their only use is a start or end lifetime intrinsic.

Summary:
If the only use of a value is a start or end lifetime intrinsic then mark the intrinsic as trivially dead. This should allow for that value to then be removed as well.

Currently, this only works for allocas, globals, and arguments.

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[InstCombine] add/adjust tests for fpext of casted value; NFC
Sanjay Patel [Fri, 8 May 2020 19:14:36 +0000 (15:14 -0400)]
[InstCombine] add/adjust tests for fpext of casted value; NFC

4 years ago[InstCombine] add helper for known exact cast to FP; NFC
Sanjay Patel [Fri, 8 May 2020 18:40:04 +0000 (14:40 -0400)]
[InstCombine] add helper for known exact cast to FP; NFC

As suggested in D79116 - there's shared logic between the
existing code and potential new folds. This could go in
ValueTracking if it seems generally useful.

4 years ago[libcxx] Delete pointer in shared_ptr deduction test.
zoecarver [Fri, 8 May 2020 19:18:21 +0000 (12:18 -0700)]
[libcxx] Delete pointer in shared_ptr deduction test.

Updates the dummy deleter in deduction.pass.cpp to delete the pointer argument. This will fix the asan bots.

4 years ago[lldb] Remove 'use_synthetic' parameters in ValueObject code
Raphael Isemann [Fri, 8 May 2020 17:09:30 +0000 (19:09 +0200)]
[lldb] Remove 'use_synthetic' parameters in ValueObject code

Summary:
`CalculateSyntheticValue` and `GetSyntheticValue` have a `use_synthetic` parameter
that makes the function do nothing when it's false. We obviously always pass true
to the function (or check that the value we pass is true), because there really isn't
any point calling with function with a `false`. This just removes all of this.

Reviewers: labath, JDevlieghere, davide

Reviewed By: davide

Subscribers: davide

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

4 years ago[X86] Add assembler support for {vex} prefix to match GNU as.
Craig Topper [Fri, 8 May 2020 18:49:30 +0000 (11:49 -0700)]
[X86] Add assembler support for {vex} prefix to match GNU as.

This does the same thing as {vex2}. Which is give an error
if the instruction can't be done with VEX. It doesn't force
the instruction to use 2 byte VEX. That's already the preference
if its possible. Therefore {vex} is a clearer name.

4 years ago[SampleFDO] For functions without profiles, provide an option to put
Wei Mi [Tue, 5 May 2020 00:17:34 +0000 (17:17 -0700)]
[SampleFDO] For functions without profiles, provide an option to put
them in a special text section.

For sampleFDO, because the optimized build uses profile generated from
previous release, previously we couldn't tell a function without profile
was truely cold or just newly created so we had to treat them conservatively
and put them in .text section instead of .text.unlikely. The result was when
we persuing the best performance by locking .text.hot and .text in memory,
we wasted a lot of memory to keep cold functions inside.

In https://reviews.llvm.org/D66374, we introduced profile symbol list to
discriminate functions being cold versus functions being newly added.
This mechanism works quite well for regular use cases in AutoFDO. However,
in some case, we can only have a partial profile when optimizing a target.
The partial profile may be an aggregated profile collected from many targets.
The profile symbol list method used for regular sampleFDO profile is not
applicable to partial profile use case because it may be too large and
introduce many false positives.

To solve the problem for partial profile use case, we provide an option called
--profile-unknown-in-special-section. For functions without profile, we will
still treat them conservatively in compiler optimizations -- for example,
treat them as warm instead of cold in inliner. When we use profile info to
add section prefix for functions, we will discriminate functions known to be
not cold versus functions without profile (being unknown), and we will put
functions being unknown in a special text section called .text.unknown.
Runtime system will have the flexibility to decide where to put the special
section in order to achieve a balance between performance and memory saving.

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

4 years ago[lld] Add a new output section ".text.unknown" for funtions with unknown hotness
Wei Mi [Thu, 7 May 2020 17:24:19 +0000 (10:24 -0700)]
[lld] Add a new output section ".text.unknown" for funtions with unknown hotness

For sampleFDO, because the optimized build uses profile generated from previous
release, often we couldn't tell a function without profile was truely cold or
just newly created so we had to treat them conservatively and put them in .text
section instead of .text.unlikely. The result was when we persue the best
performance by locking .text.hot and .text in memory, we wasted a lot of memory
to keep cold functions inside. This problem has been largely solved for regular
sampleFDO using profile-symbol-list (https://reviews.llvm.org/D66374), but for
the case when we use partial profile, we still waste a lot of memory because
of it.

In https://reviews.llvm.org/D62540, we propose to save functions with unknown
hotness information in a special section called ".text.unknown", so that
compiler will treat those functions as luck-warm, but runtime can choose not
to mlock the special section in memory or use other strategy to save memory.
That will solve most of the memory problem even if we use a partial profile.

The patch adds the support in lld for the special section.For sampleFDO,
because the optimized build uses profile generated from previous release,
often we couldn't tell a function without profile was truely cold or just
newly created so we had to treat them conservatively and put them in .text
section instead of .text.unlikely. The result was when we persue the best
performance by locking .text.hot and .text in memory, we wasted a lot of
memory to keep cold functions inside. This problem has been largely solved
for regular sampleFDO using profile-symbol-list
(https://reviews.llvm.org/D66374), but for the case when we use partial
profile, we still waste a lot of memory because of it.

In https://reviews.llvm.org/D62540, we propose to save functions with unknown
hotness information in a special section called ".text.unknown", so that
compiler will treat those functions as luck-warm, but runtime can choose not
to mlock the special section in memory or use other strategy to save memory.
That will solve most of the memory problem even if we use a partial profile.

The patch adds the support in lld for the special section.

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

4 years ago[SimplifyCFG] Remap rewritten debug intrinsic operands.
Ricky Zhou [Fri, 8 May 2020 17:55:27 +0000 (10:55 -0700)]
[SimplifyCFG] Remap rewritten debug intrinsic operands.

FoldBranchToCommonDest clones instructions to a different basic block,
but handles debug intrinsics in a separate path. Previously, when
cloning debug intrinsics, their operands were not updated to reference
the correct cloned values. As a result, we would emit debug.value
intrinsics with broken operand references which are discarded in later
passes. This leads to incorrect debuginfo that reports incorrect values
for variables.

Fix this by remapping debug intrinsic operands when cloning them.

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

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

4 years ago[DAG] SimplifyMultipleUseDemandedBits - remove superfluous bitcasts
Simon Pilgrim [Fri, 8 May 2020 18:04:29 +0000 (19:04 +0100)]
[DAG] SimplifyMultipleUseDemandedBits - remove superfluous bitcasts

If the SimplifyMultipleUseDemandedBits calls BITCASTs that peek through back to the original type then we can remove the BITCASTs entirely.

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

4 years ago[AIX] Make sure we use export lists for plugins
David Tenty [Fri, 8 May 2020 17:45:44 +0000 (13:45 -0400)]
[AIX] Make sure we use export lists for plugins

Summary:
Besides just generating and consuming the lists, this includes:

 * Calling  nm with the right options in extract_symbols.py. Such as not
  demangling C++ names, which AIX nm does by default, and accepting both
  32/64-bit names.
 * Not having nm sort the list of symbols or we may run in to memory
   issues on debug builds, as nm calls a 32-bit sort.
 * Defaulting to having LLVM_EXPORT_SYMBOLS_FOR_PLUGINS on for AIX
 * CMake versions prior to 3.16 set the -brtl linker flag globally on
   AIX. Clear it out early on so we don't run into failures. We will set
   it as needed.

Reviewers: jasonliu, DiggerLin, stevewan, hubert.reinterpretcast

Reviewed By: hubert.reinterpretcast

Subscribers: hubert.reinterpretcast, mgorny, llvm-commits

Tags: #llvm

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

4 years agoRe-land "get rid of PythonInteger::GetInteger()"
Lawrence D'Anna [Fri, 8 May 2020 17:56:30 +0000 (10:56 -0700)]
Re-land "get rid of PythonInteger::GetInteger()"

This was reverted due to a python2-specific bug.  Re-landing with a fix
for python2.

Summary:
One small step in my long running quest to improve python exception handling in
LLDB.  Replace GetInteger() which just returns an int with As<long long> and
friends, which return Expected types that can track python exceptions

Reviewers: labath, jasonmolenda, JDevlieghere, vadimcn, omjavaid

Reviewed By: labath, omjavaid

Subscribers: omjavaid, lldb-commits

Tags: #lldb

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

4 years agoAdd an API to construct an XcodeSDK from an SDK type.
Adrian Prantl [Thu, 7 May 2020 23:02:23 +0000 (16:02 -0700)]
Add an API to construct an XcodeSDK from an SDK type.

Also, this moves numSDKs out of the actual enum, as to not mess with
the switch-cases-covered warning.

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

4 years ago[InstCombine] add tests for known bits before FP casts; NFC
Sanjay Patel [Fri, 8 May 2020 17:44:03 +0000 (13:44 -0400)]
[InstCombine] add tests for known bits before FP casts; NFC

4 years agoRevert "[libc++] ECMAScript IdentityEscape is ambiguous (2584)"
zoecarver [Fri, 8 May 2020 17:35:18 +0000 (10:35 -0700)]
Revert "[libc++] ECMAScript IdentityEscape is ambiguous (2584)"

This reverts commit 6d2a66b10d458e34c852be46028092d2b46edc14.

The regex expressions in some lld tests need to be fixed. Reverting
until those are fixed.

4 years agoFix bugs when an included file name is typo corrected.
Nico Weber [Fri, 8 May 2020 17:03:14 +0000 (13:03 -0400)]
Fix bugs when an included file name is typo corrected.

D52774 fixed a bug with typo correction of includes, but didn't add
a test.

D65907 then broke recovery of typo correction of includes again,
because it extracted the code that writes to Filename to a separate
function that took the parameter not by reference.

Fix that, and also don't repeat the slash normalization computation
and fix both lookup and regular file name after recovery.

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

4 years ago[hwasan] Reset current thread pointer on thread exit.
Evgenii Stepanov [Thu, 7 May 2020 23:22:21 +0000 (16:22 -0700)]
[hwasan] Reset current thread pointer on thread exit.

Summary:
This is necessary to handle calls to free() after __hwasan_thread_exit,
which is possible in glibc.

Also, add a null check to GetCurrentThread, otherwise the logic in
GetThreadByBufferAddress turns it into a non-null value. This means that
all of the checks for GetCurrentThread() != nullptr do not have any
effect at all right now!

Reviewers: pcc, hctim

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers

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

4 years agoReland [lldb][cmake] Also use local submodule visibility on Darwin
Raphael Isemann [Mon, 27 Apr 2020 12:58:50 +0000 (14:58 +0200)]
Reland [lldb][cmake] Also use local submodule visibility on Darwin

Relanding this as D79632 should fix the macOS tests with this option.

Original commit:

Summary:
Currently building LLVM on macOS and on other platforms with LLVM_ENABLE_MODULES is using different module flags,
which means that a passing modules build on macOS might fail on Linux and vice versa. -fmodules-local-submodule-visibility
is the mode that has clearer semantics and is closer to the actual C++ module standard, so let's make this the default everywhere.

We can still test building without local submodule visibility on an additional bot by just changing the respective CMake flag. However,
if building without local-submodule-visibility breaks we won't revert other commits and we won't loose LLDB's/Clang's test run
information.

Reviewers: aprantl, bruno, Bigcheese

Reviewed By: Bigcheese

Subscribers: abidh, dexonsmith, JDevlieghere, lldb-commits, mgorny, llvm-commits

Tags: #llvm, #lldb

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

4 years ago[PDB] Optimize public symbol processing
Reid Kleckner [Sun, 3 May 2020 16:29:03 +0000 (09:29 -0700)]
[PDB] Optimize public symbol processing

Reduces time to link PGO instrumented net_unittets.exe by 11% (9.766s ->
8.672s, best of three). Reduces peak memory by 65.7MB (2142.71MB ->
2076.95MB).

Use a more compact struct, BulkPublic, for faster sorting. Sort in
parallel. Construct the hash buckets in parallel. Try to use one vector
to hold all the publics instead of copying them from one to another.
Allocate all the memory needed to serialize publics up front, and then
serialize them in place in parallel.

Reviewed By: aganea, hans

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

4 years ago[lldb/test][Darwin] Ask dyld where the real python is
Vedant Kumar [Thu, 7 May 2020 23:07:32 +0000 (16:07 -0700)]
[lldb/test][Darwin] Ask dyld where the real python is

Summary:
On macOS, we can't do the DYLD_INSERT_LIBRARIES trick with a shim
python binary as the ASan interceptors get loaded too late. Find the
"real" python binary, copy it, and invoke it.

Hopefully this makes the GreenDragon and swift-ci sanitizer bots
happy...

I tested this out by running `../llvm-macosx-x86_64/bin/llvm-lit test
--filter TestNSDictionarySynthetic.py` in an ASanified swift-lldb build
directory and it worked (i.e. no more "interceptors loaded too late"
messages).

Reviewers: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

4 years agoAMDGPU: Don't assert on unknown address spaces
Matt Arsenault [Thu, 7 May 2020 15:22:54 +0000 (11:22 -0400)]
AMDGPU: Don't assert on unknown address spaces

Assume unknown address spaces behave like some flavor of global
memory.

4 years agoUnbreak clang-tidy tests after D79599 / e9b4113902850.
Nico Weber [Fri, 8 May 2020 16:36:31 +0000 (12:36 -0400)]
Unbreak clang-tidy tests after D79599 / e9b4113902850.

4 years agoReland D79501 "[DebugInfo] Fix handling DW_OP_call_ref in DWARF64 units."
Fangrui Song [Fri, 8 May 2020 16:28:25 +0000 (09:28 -0700)]
Reland D79501 "[DebugInfo] Fix handling DW_OP_call_ref in DWARF64 units."

With a fix to uninitialized EndOffset.

DW_OP_call_ref is the only operation that has an operand which depends
on the DWARF format. The patch fixes handling that operation in DWARF64
units.

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

4 years ago[lldb][modules] Disable Clang Modules in source/Host directory on macOS
Raphael Isemann [Fri, 8 May 2020 16:13:43 +0000 (18:13 +0200)]
[lldb][modules] Disable Clang Modules in source/Host directory on macOS

Summary:
The arpa/inet.h header in macOS is providing an incorrect htonl
function with enabled local submodule visibility while building LLDB. This
caused several networking tests to fail as the IP addresses are now flipped
in LLDB.

This patch disables building with modules when local submodule visibility is
active and the current system is macOS for the source/Host directory (which
is the *only directory that includes arpa/inet.h).

* debugserver also includes arpa/inet.h but there we already disabled
modules.

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: mgorny, JDevlieghere

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

4 years ago[InstCombine] clean up foldItoFPtoI; NFC
Sanjay Patel [Fri, 8 May 2020 16:06:38 +0000 (12:06 -0400)]
[InstCombine] clean up foldItoFPtoI; NFC

Mostly cosmetic improvements to variable names and logic to ease
refactoring suggested in D79116.

4 years agoFix MSan test use-after-dtor.cpp under new pass manager
Arthur Eubanks [Thu, 7 May 2020 19:14:43 +0000 (12:14 -0700)]
Fix MSan test use-after-dtor.cpp under new pass manager

Summary: The new pass manager symbolizes the location as ~Simple instead of Simple::~Simple.

Reviewers: rnk, leonardchan, vitalybuka

Subscribers: #sanitizers

Tags: #sanitizers

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