Commit Graph

353982 Commits

Author SHA1 Message Date
Matt Arsenault 69999605ee 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.
2020-05-09 16:39:37 -04:00
Matt Arsenault ee1a69824d 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.
2020-05-09 16:14:32 -04:00
Matt Arsenault 16295d521e 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.
2020-05-09 16:00:27 -04:00
Matt Arsenault a881dc1103 Fix typo 2020-05-09 16:00:17 -04:00
Matt Arsenault beda9d04c2 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.
2020-05-09 16:00:08 -04:00
Simon Pilgrim f8b09f7b52 [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).
2020-05-09 20:47:42 +01:00
Simon Pilgrim d7258c6a83 [X86] Add XOP vector shift by scalar amount tests
Helps improve test coverage of the XOP modes in X86TargetLowering::isVectorShiftByScalarCheap
2020-05-09 20:47:42 +01:00
Craig Topper c7be6a86f4 [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
2020-05-09 12:19:30 -07:00
Craig Topper 56bf0b58c2 [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.
2020-05-09 11:24:16 -07:00
David Green 6eee2d9b5b [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
2020-05-09 18:58:13 +01:00
Nathan James 0e49ac73ea [NFC] Small rework to RenamerClangTidyCheck addUsage 2020-05-09 18:57:05 +01:00
Fred Riss c9537b9cc8 [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.
2020-05-09 10:12:17 -07:00
Kadir Cetinkaya c746781f50
[clangd] Fix data race in BackgroundIndex test
MockFSProvider is not thread-safe. Make sure we don't modify it while
background index is working.
2020-05-09 18:15:27 +02:00
Tim Keith b05c8c5756 [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
2020-05-09 09:11:00 -07:00
Nathan James 82ddae061b [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
2020-05-09 16:21:49 +01:00
David Zarzycki 4f4ce13944 [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
2020-05-09 11:11:26 -04:00
Simon Pilgrim 0b9783350b LTO.h - reduce includes to forward declarations. NFC.
Add missing ToolOutputFile.h dependency to BackendUtil.cpp
2020-05-09 15:10:51 +01:00
Simon Pilgrim 4319c89551 LLParser.h - remove unused ValueHandle.h include. NFC. 2020-05-09 15:08:48 +01:00
Simon Pilgrim f4d4e246e0 [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).
2020-05-09 15:07:15 +01:00
Simon Pilgrim 0e8e731449 [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
2020-05-09 14:53:25 +01:00
Simon Pilgrim 7425bdbd2f [X86] Add test cases for 'abs from mul patterns' (PR45691) 2020-05-09 14:53:25 +01:00
Kadir Cetinkaya 84cbd472e5
[clangd] Fix a data race in RecordsLatencies test 2020-05-09 15:42:21 +02:00
Simon Pilgrim fccd796565 [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
2020-05-09 14:24:38 +01:00
Simon Pilgrim 65399cde4b NativeFormatting.h - reduce raw_ostream.h include to forward declaration. NFC. 2020-05-09 13:32:14 +01:00
mydeveloperday 31fd12aa09 [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
2020-05-09 11:27:23 +01:00
Eugene Zhulenev 3c5dd5863c [MLIR] Register JIT event listeners with RTDyldObjectLinkingLayer
Use a new API to register JIT event listeners.

Differential Revision: https://reviews.llvm.org/D78435
2020-05-09 11:17:22 +02:00
Jan Kratochvil 68a9356bde [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
2020-05-09 09:06:37 +02:00
Fangrui Song 6bf0ad78dc [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.
2020-05-08 23:36:29 -07:00
Shengchen Kan 99ac9ce701 [NFC] Clean up in MCObjectStreamer and X86AsmBackend 2020-05-09 12:50:44 +08:00
Jan Korous e4e3e41905 Revert "Relands "[YAMLVFSWriter][Test][NFC] Add couple tests""
This reverts commit 49b32d8041.
2020-05-08 21:36:29 -07:00
Igor Kudrin c6ed1fcf24 [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
2020-05-09 10:04:22 +07:00
Richard Smith c90e198107 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.
2020-05-08 19:32:00 -07:00
Jan Korous 49b32d8041 Relands "[YAMLVFSWriter][Test][NFC] Add couple tests"
Fixed test for Windows.

Differential Revision: https://reviews.llvm.org/D79552
2020-05-08 18:08:50 -07:00
Matt Arsenault 03cb328d6f clang: Cleanup usage of CreateMemCpy
It handles the the pointee type casts in preparation for opaque
pointers.
2020-05-08 20:57:56 -04:00
Fangrui Song 9a11174287 [Driver] Add -fno-test-coverage 2020-05-08 17:01:53 -07:00
Evgenii Stepanov 68a9308a0b [hwasan] Allow -hwasan-globals flag to appear more than once. 2020-05-08 16:35:48 -07:00
Evgenii Stepanov 9fcd2b68e7 [hwasan] Untag destination address in hwasan_posix_memalign.
Required on X86 because no TBI.
2020-05-08 16:35:48 -07:00
Fangrui Song 0d4a33ba61 [Driver] Don't warn -Wunused-command-line-argument for --coverage -ftest-coverage -fprofile-arcs 2020-05-08 16:31:15 -07:00
Matthias Schiffer a2247d42e4 [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
2020-05-08 16:21:30 -07:00
Fangrui Song e1815eb2e1 [Driver] Reorganize --coverage -ftest-coverage -fprofile-arcs related tests
And fix a comment about __llvm_profile_runtime
2020-05-08 16:06:33 -07:00
Craig Topper bebdc62c3f [SelectionDAG] Remove ConstantPoolSDNode::getAlignment.
Use getAlign instead.

Differential Revision: https://reviews.llvm.org/D79459
2020-05-08 16:04:11 -07:00
Craig Topper d1119980e5 [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
2020-05-08 16:04:11 -07:00
Geoffrey Martin-Noble 2280cb880d 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
2020-05-08 22:34:21 +00:00
Stanislav Mekhanoshin db7dea2b6f [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
2020-05-08 15:11:38 -07:00
Layton Kifer 23cbea9a04 [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
2020-05-08 14:36:02 -07:00
Reid Kleckner 39772063f5 [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.
2020-05-08 14:22:28 -07:00
Reid Kleckner 77ecf90c52 [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
2020-05-08 14:01:39 -07:00
Thomas Lively ebb69b8baf [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
2020-05-08 13:54:29 -07:00
Thomas Lively a1ae9566ea [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
2020-05-08 13:52:39 -07:00
Hubert Tong 601d5bd516 [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.
2020-05-08 16:51:34 -04:00