platform/upstream/llvm.git
2 years ago[Preprocessor] Elide empty line(s) at start of file.
Michael Kruse [Wed, 25 Aug 2021 16:31:53 +0000 (11:31 -0500)]
[Preprocessor] Elide empty line(s) at start of file.

In -P mode, PrintPPOutputPPCallbacks::MoveToLine started at least one
newline if current and target line number mismatched. The method is also
called when entering a new file, be it the main file or an include file.
In this situation line numbers always almost mismatch, resulting in a
newline for each occurance even if no tokens have been printed
in-between.

Empty lines at the beginning of the output must be trimmed because it
may be parsed by scripts expecting the result to appear on the first
output line, as done by LibreOffice's configure script.

Fix by only emitting a newline if tokens have been printed so far using
the EmittedTokensOnThisLine flag. Also adding a test case of FileChanged
callbacks occuring with empty include files.

This fixes llvm.org/PR51616

2 years ago[Clang] add support for error+warning fn attrs
Nick Desaulniers [Wed, 25 Aug 2021 17:18:13 +0000 (10:18 -0700)]
[Clang] add support for error+warning fn attrs

Add support for the GNU C style __attribute__((error(""))) and
__attribute__((warning(""))). These attributes are meant to be put on
declarations of functions whom should not be called.

They are frequently used to provide compile time diagnostics similar to
_Static_assert, but which may rely on non-ICE conditions (ie. relying on
compiler optimizations). This is also similar to diagnose_if function
attribute, but can diagnose after optimizations have been run.

While users may instead simply call undefined functions in such cases to
get a linkage failure from the linker, these provide a much more
ergonomic and actionable diagnostic to users and do so at compile time
rather than at link time. Users instead may be able use inline asm .err
directives.

These are used throughout the Linux kernel in its implementation of
BUILD_BUG and BUILD_BUG_ON macros. These macros generally cannot be
converted to use _Static_assert because many of the parameters are not
ICEs. The Linux kernel still needs to be modified to make use of these
when building with Clang; I have a patch that does so I will send once
this feature is landed.

To do so, we create a new IR level Function attribute, "dontcall" (both
error and warning boil down to one IR Fn Attr).  Then, similar to calls
to inline asm, we attach a !srcloc Metadata node to call sites of such
attributed callees.

The backend diagnoses these during instruction selection, while we still
know that a call is a call (vs say a JMP that's a tail call) in an arch
agnostic manner.

The frontend then reconstructs the SourceLocation from that Metadata,
and determines whether to emit an error or warning based on the callee's
attribute.

Link: https://bugs.llvm.org/show_bug.cgi?id=16428
Link: https://github.com/ClangBuiltLinux/linux/issues/1173
Reviewed By: aaron.ballman

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

2 years ago[Sema][ObjC] Allow conversions between pointers to ObjC pointers and
Akira Hatanaka [Wed, 25 Aug 2021 16:55:50 +0000 (09:55 -0700)]
[Sema][ObjC] Allow conversions between pointers to ObjC pointers and
pointers to structs

clang was just being conservative and trying to prevent users from
messing up the qualifier on the inner pointer type. Lifting this
restriction enables using some of the libc++ templates with ObjC pointer
arguments, which clang currently rejects.

rdar://79018677

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

2 years ago[X86] pr51000 in-register struct return tailcalling
Nathan Sidwell [Fri, 9 Jul 2021 14:57:10 +0000 (07:57 -0700)]
[X86] pr51000 in-register struct return tailcalling

In-register structure returns are not special, and handled by lowering
to multiple-value tuples.  We can tail-call from non-sret fns to
structure-returning functions, except on i686 where the sret pointer
is callee-pop.

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

2 years ago[gn build] Add missing dependency required by 832aae73
Arthur Eubanks [Wed, 25 Aug 2021 17:12:51 +0000 (10:12 -0700)]
[gn build] Add missing dependency required by 832aae73

2 years ago[AMDGPU] Avoid assert for saved FP
Stanislav Mekhanoshin [Tue, 3 Aug 2021 21:50:10 +0000 (14:50 -0700)]
[AMDGPU] Avoid assert for saved FP

With spilling into AGPRs enabled we cannot reliably predict
if we need to save FP or not. We may finally spill everything
into AGPRs and never touch stack. In this case we still may
save FP. This is deficiency but not an error, so avoid the
assert.

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

2 years ago[SLP]No need to schedule/check parent for extract{element/value} instruction.
Alexey Bataev [Wed, 25 Aug 2021 14:27:03 +0000 (07:27 -0700)]
[SLP]No need to schedule/check parent for extract{element/value} instruction.

The instruction extractelement/extractvalue are not required to
be scheduled since they only depend on the source vector/aggregate (with
constant indices), smae applies to the parent basic block checks.
Improves compile time and saves scheduling budget.

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

2 years ago[SampleFDO] Set ProfileIsFS bit properly from the internal option
Rong Xu [Wed, 25 Aug 2021 16:07:34 +0000 (09:07 -0700)]
[SampleFDO] Set ProfileIsFS bit properly from the internal option

We have "-profile-isfs" internal option for text, binary, and
compactbinary format (mostly for debug and test purpose). We
need to set the related flag in FunctionSamples so that ProfileIsFS
is written to the header in extbinary format.

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

2 years ago[CSSPGO] Use probe inline tree to track zero size fully optimized context for pre...
Wenlei He [Thu, 19 Aug 2021 04:09:49 +0000 (21:09 -0700)]
[CSSPGO] Use probe inline tree to track zero size fully optimized context for pre-inliner

This is a follow up diff for BinarySizeContextTracker to track zero size for fully optimized inlinee. When an inlinee is fully optimized away, we won't be able to get its size through symbolizing instructions, hence we will treat the corresponding context size as unknown. However by traversing the inlined probe forest, we know what're original inlinees regardless of optimization. If a context show up in inlined probes, but not during symbolization, we know that it's fully optimized away hence its size is zero instead of unknown. It should provide more accurate size cost estimation for pre-inliner to make better inline decisions in llvm-profgen.

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

2 years ago[Transforms] Remove SplitCriticalEdge (NFC)
Kazu Hirata [Wed, 25 Aug 2021 15:59:12 +0000 (08:59 -0700)]
[Transforms] Remove SplitCriticalEdge (NFC)

These functions have not been in use for at least one year.

2 years ago[asan] Implemented intrinsic for the custom calling convention similar used by HWASan...
Kirill Stoimenov [Tue, 24 Aug 2021 20:23:47 +0000 (20:23 +0000)]
[asan] Implemented intrinsic for the custom calling convention similar used by HWASan for X86.

The implementation uses the int_asan_check_memaccess intrinsic to instrument the code. The intrinsic is replaced by a call to a function which performs the access check. The generated function names encode the input register name as a number using Reg - X86::NoRegister formula.

Reviewed By: vitalybuka

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

2 years ago[AMDGPU] Divergence-driven compare operations instruction selection
alex-t [Thu, 15 Jul 2021 16:43:56 +0000 (19:43 +0300)]
[AMDGPU] Divergence-driven compare operations instruction selection

Description: This change enables the compare operations to be selected to SALU/VALU form
             dependent of the SDNode divergence flag.

Reviewed By: rampitec

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

2 years ago[SystemZ] [NFC] Replace SpecialRegisters field with a unique_ptr instead of a raw...
Neumann Hon [Wed, 25 Aug 2021 15:24:02 +0000 (11:24 -0400)]
[SystemZ] [NFC] Replace SpecialRegisters field with a unique_ptr instead of a raw pointer.

This patch replaces the SpecialRegisters field with a unique_ptr instead of a raw pointer. This is better practice, and allows us to remove the definition of the dtor for the SystemZSubtarget class.

Reviewed By: uweigand, Kai

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

2 years agoRevert "Revert "[analyzer] Ignore IncompleteArrayTypes in getStaticSize() for FAMs""
Balazs Benics [Wed, 25 Aug 2021 14:47:13 +0000 (16:47 +0200)]
Revert "Revert "[analyzer] Ignore IncompleteArrayTypes in getStaticSize() for FAMs""

This reverts commit df1f4e0cc6ec9a734aae41ffd48ee8b2007fcabb.

Now the test case explicitly specifies the target triple.
I decided to use x86_64 for that matter, to have a fixed
bitwidth for `size_t`.

Aside from that, relanding the original changes of:
https://reviews.llvm.org/D105184

2 years ago[X86][SchedModel] Fix latency the Hi register write of MULX (PR51495).
Andrea Di Biagio [Wed, 25 Aug 2021 13:53:45 +0000 (14:53 +0100)]
[X86][SchedModel] Fix latency the Hi register write of MULX (PR51495).

Before this patch, WriteIMulH reported a latency value which is correct for the
RR variant of MULX, but not for the RM variant.

This patch fixes the issue by introducing a new WriteIMulHLd, which is meant to
be used only by the RM variant of MULX.

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

2 years ago[CodeExtractor] Preserve topological order for the return blocks.
Vyacheslav Zakharin [Tue, 24 Aug 2021 23:19:49 +0000 (16:19 -0700)]
[CodeExtractor] Preserve topological order for the return blocks.

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

2 years ago[openmp] Delete unused grid value field, missed from D108380
Jon Chesterfield [Wed, 25 Aug 2021 14:53:47 +0000 (15:53 +0100)]
[openmp] Delete unused grid value field, missed from D108380

2 years ago[ARC] Add ADC (addition with carry) and SBC (subtraction with carry) instructions
Thomas Johnson [Tue, 24 Aug 2021 18:40:04 +0000 (14:40 -0400)]
[ARC] Add ADC (addition with carry) and SBC (subtraction with carry) instructions

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

2 years agoRevert "[analyzer] Ignore IncompleteArrayTypes in getStaticSize() for FAMs"
Balazs Benics [Wed, 25 Aug 2021 14:43:25 +0000 (16:43 +0200)]
Revert "[analyzer] Ignore IncompleteArrayTypes in getStaticSize() for FAMs"

This reverts commit 360ced3b8fd2cfb9f2a26deb739e6c381e98b9a5.

2 years ago[AArch64] Generate SMOV in place of sext(fmov(...))
Nicholas Guy [Mon, 16 Aug 2021 13:10:21 +0000 (14:10 +0100)]
[AArch64] Generate SMOV in place of sext(fmov(...))

A single smov instruction is capable of moving from a vector register while performing
the sign-extend during said move, rather than each step being performed by separate instructions.

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

2 years ago[analyzer] Ignore IncompleteArrayTypes in getStaticSize() for FAMs
Balazs Benics [Wed, 25 Aug 2021 14:12:17 +0000 (16:12 +0200)]
[analyzer] Ignore IncompleteArrayTypes in getStaticSize() for FAMs

Currently only `ConstantArrayType` is considered for flexible array
members (FAMs) in `getStaticSize()`.
However, `IncompleteArrayType` also shows up in practice as FAMs.

This patch will ignore the `IncompleteArrayType` and return Unknown
for that case as well. This way it will be at least consistent with
the current behavior until we start modeling them accurately.

I'm expecting that this will resolve a bunch of false-positives
internally, caused by the `ArrayBoundV2`.

Reviewed By: ASDenysPetrov

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

2 years ago[libomptarget][amdgpu][nfc] Make grid value access match devicertl
Jon Chesterfield [Wed, 25 Aug 2021 14:09:46 +0000 (15:09 +0100)]
[libomptarget][amdgpu][nfc] Make grid value access match devicertl

2 years ago[DebugInfo][InstrRef] Don't use instr-ref for unoptimised functions
Jeremy Morse [Wed, 25 Aug 2021 13:56:05 +0000 (14:56 +0100)]
[DebugInfo][InstrRef] Don't use instr-ref for unoptimised functions

InstrRefBasedLDV is marginally slower than VarlocBasedLDV when analysing
optimised code -- however, it's much slower when analysing code compiled
-O0.

To avoid this: don't use instruction referencing for -O0 functions. In the
"pure" case of unoptimised code, this won't really harm the debugging
experience because most variables won't have been promoted off the stack,
so can't go missing. It becomes more complicated when optimised code is
inlined into functions marked optnone; however these are rare, and as -O0
doesn't run many optimisations there should be little damage to the debug
experience as a result.

I've taken the opportunity to refactor testing for instruction-referencing
into a MachineFunction method, which seems the most appropriate place to
put it.

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

2 years ago[libomptarget][amdgpu] Refactor debug printing
Jon Chesterfield [Wed, 25 Aug 2021 13:57:50 +0000 (14:57 +0100)]
[libomptarget][amdgpu] Refactor debug printing

Move most debug printing in rtl.cpp behind DP() macro
Adjust the print output for gpu arch mismatch when the architectures match
Convert an assert into graceful failure

Reviewed By: jdoerfert

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

2 years ago[AMDGPU] Support global_atomic_fmin/max on gfx10
Joe Nash [Tue, 24 Aug 2021 18:40:04 +0000 (14:40 -0400)]
[AMDGPU] Support global_atomic_fmin/max on gfx10

Makes patterns added for gfx90a usable with the gfx10 versions of the
insts.

Reviewed By: rampitec

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

Change-Id: I86167bf6b4823f975f74ccb619bd6190331ba16b

2 years ago[X86][NFC] Pre-commit llvm-mca tests for PR51495.
Andrea Di Biagio [Wed, 25 Aug 2021 13:15:17 +0000 (14:15 +0100)]
[X86][NFC] Pre-commit llvm-mca tests for PR51495.

WriteIMulH reports an incorrect latency for RM variants of MULX.

2 years ago[libc++] Assume that compilers support extended constexpr in C++14 mode
Louis Dionne [Tue, 24 Aug 2021 15:58:36 +0000 (11:58 -0400)]
[libc++] Assume that compilers support extended constexpr in C++14 mode

We don't support any compiler that doesn't support C++14 constexpr when
compiling in C++14 mode anymore, so we can just assume that we have C++14
extended constexpr when compiling in C++14 mode. This allows us to remove
some workarounds for older compilers.

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

2 years ago[LoopPeel] Allow peeling with multiple unreachable-terminated exit blocks.
Florian Hahn [Wed, 25 Aug 2021 10:58:49 +0000 (11:58 +0100)]
[LoopPeel] Allow peeling with multiple unreachable-terminated exit blocks.

Support for peeling with multiple exit blocks was added in D63921/77bb3a486fa6.

So far it has only been enabled for loops where all non-latch exits are
'de-optimizing' exits (D63923). But peeling of multi-exit loops can be
highly beneficial in other cases too, like if all non-latch exiting
blocks are unreachable.

The motivating case are loops with runtime checks, like the C++ example
below. The main issue preventing vectorization is that the invariant
accesses to load the bounds of B is conditionally executed in the loop
and cannot be hoisted out. If we peel off the first iteration, they
become dereferenceable in the loop, because they must execute before the
loop is executed, as all non-latch exits are terminated with
unreachable. This subsequently allows hoisting the loads and runtime
checks out of the loop, allowing vectorization of the loop.

     int sum(std::vector<int> *A, std::vector<int> *B, int N) {
       int cost = 0;
       for (int i = 0; i < N; ++i)
         cost += A->at(i) + B->at(i);
       return cost;
     }

This gives a ~20-30% increase of score for Geekbench5/HDR on AArch64.

Note that this requires a follow-up improvement to the peeling cost
model to actually peel iterations off loops as above. I will share that
shortly.

Also, peeling of multi-exits might be beneficial for exit blocks with
other terminators, but I would like to keep the scope limited to known
high-reward cases for now.

I removed the option to disable peeling for multi-deopt exits because
the code is more general now. Alternatively, the option could also be
generalized, but I am not sure if there's much value in the option?

Reviewed By: reames

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

2 years ago[LoopIdiom] Don't transform loop into memmove when load from body has more than one use
Dawid Jurczak [Wed, 25 Aug 2021 11:13:18 +0000 (13:13 +0200)]
[LoopIdiom] Don't transform loop into memmove when load from body has more than one use

This change fixes issue found by Markus: https://reviews.llvm.org/rG11338e998df1
Before this patch following code was transformed to memmove:

for (int i = 15; i >= 1; i--) {
  p[i] = p[i-1];
  sum += p[i-1];
}

However load from p[i-1] is used not only by store to p[i] but also by sum computation.
Therefore we cannot emit memmove in loop header.

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

2 years ago[clang-format] Support TypeScript override keyword
Jan Kuehle [Wed, 25 Aug 2021 12:11:43 +0000 (14:11 +0200)]
[clang-format] Support TypeScript override keyword

TypeScript 4.3 added a new "override" keyword for class members. This
lets clang-format know about it, so it can format code using it
properly.

Reviewed By: krasimir

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

2 years ago[DAGCombine] Check the legality of the index of EXTRACT_SUBVECTOR
Peilin Guo [Wed, 25 Aug 2021 11:31:00 +0000 (19:31 +0800)]
[DAGCombine] Check the legality of the index of EXTRACT_SUBVECTOR

For ISD::EXTRACT_SUBVECTOR, its second operand must be a constant
multiple of the known-minimum vector length of the result type.

Reviewed By: dmgreen

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

2 years ago[DebugInfo][InstrRef] Avoid stack-slot-coloring changing codegen due to DI
Jeremy Morse [Wed, 25 Aug 2021 11:04:59 +0000 (12:04 +0100)]
[DebugInfo][InstrRef] Avoid stack-slot-coloring changing codegen due to DI

Stack slot colouring adds "weight" to slots if a non-dbg-value instruction
refers to it. This, unfortunately, means that DBG_PHI instructions can have
an effect on codegen. The fix is very simple, replace isDebugValue with
isDebugInstr.

The regression test contains a scenario that reproduces this problem; I've
represented both normal-debug mode and instr-ref debug mode instructions
in comment lines prefixed with AAAAAA and BBBBBB, and un-comment them with
sed to test that the two different modes produce the same behaviour.

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

2 years ago[mlir][AttrTypeGen] Add support for specifying a "accessor" type of a parameter
River Riddle [Wed, 25 Aug 2021 09:26:56 +0000 (09:26 +0000)]
[mlir][AttrTypeGen] Add support for specifying a "accessor" type of a parameter

This allows for using a different type when accessing a parameter than the
one used for storage. This allows for returning parameters by reference,
enables using more optimized/convient reference results, and more.

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

2 years ago[mlir] Update DialectAsmParser::parseString to use std::string instead of StringRef
River Riddle [Wed, 25 Aug 2021 09:26:39 +0000 (09:26 +0000)]
[mlir] Update DialectAsmParser::parseString to use std::string instead of StringRef

This allows for parsing strings that have escape sequences, which require constructing
a string (as they can't be represented by looking at the Token contents directly).

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

2 years ago[mlir] Move the Operation use iteration utilities to ResultRange
River Riddle [Wed, 25 Aug 2021 09:26:23 +0000 (09:26 +0000)]
[mlir] Move the Operation use iteration utilities to ResultRange

This allows for iterating and interacting with the uses of a specific subset of
results as opposed to just the full range.

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

2 years ago[flang] Implement Posix version of DATE_AND_TIME runtime
Jean Perier [Wed, 25 Aug 2021 09:15:22 +0000 (11:15 +0200)]
[flang] Implement Posix version of DATE_AND_TIME runtime

Use gettimeofday and localtime_r to implement DATE_AND_TIME intrinsic.
The Windows version fallbacks to the "no date and time information
available" defined by the standard (strings set to blanks and values to
-HUGE).

The implementation uses an ifdef between windows and the rest because
from my tests, the SFINAE approach leads to undeclared name bogus errors
with clang 8 that seems to ignore failure to instantiate is not an error
for the function names (i.e., it understands it should not instantiate
the version using gettimeofday if it is not there, but still yields an
error that it is not declared on the spot where it is called in the
uninstantiated version).

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

2 years ago[clang][deps] Ensure deterministic order of TU '-fmodule-file=' arguments
Jan Svoboda [Wed, 25 Aug 2021 08:56:15 +0000 (10:56 +0200)]
[clang][deps] Ensure deterministic order of TU '-fmodule-file=' arguments

Translation units with multiple direct modular dependencies trigger a non-deterministic ordering in `clang-scan-deps`. This boils down to usage of `std::unordered_map`, which gets replaced by `std::map` in this patch.

Depends on D103526.

Reviewed By: dexonsmith

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

2 years ago[LoopFlatten] Add statistic for number of loops flattened. NFC
Rosie Sumpter [Tue, 24 Aug 2021 16:04:35 +0000 (17:04 +0100)]
[LoopFlatten] Add statistic for number of loops flattened. NFC

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

2 years ago[mlir] Add assertion in NamedAttrList to prevent adding null attributes
Tres Popp [Mon, 23 Aug 2021 17:24:12 +0000 (19:24 +0200)]
[mlir] Add assertion in NamedAttrList to prevent adding null attributes

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

2 years ago[gn build] Port 48958d02d294
LLVM GN Syncbot [Wed, 25 Aug 2021 09:02:08 +0000 (09:02 +0000)]
[gn build] Port 48958d02d294

2 years ago[NFC][AMDGPU] Reduce includes dependencies.
Daniil Fukalov [Mon, 23 Aug 2021 20:50:19 +0000 (23:50 +0300)]
[NFC][AMDGPU] Reduce includes dependencies.

1. Splitted out some parts of R600 target to separate modules/headers.
2. Reduced some include lists in headers.
3. Found and fixed issue with override `GCNTargetMachine::getSubtargetImpl()`
   and `R600TargetMachine::getSubtargetImpl()` had different return value type
   than base class.
4. Minor forward declarations cleanup.

Reviewed By: foad

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

2 years ago[clang][deps] Use top-level modules as precompiled dependencies
Jan Svoboda [Wed, 25 Aug 2021 08:36:03 +0000 (10:36 +0200)]
[clang][deps] Use top-level modules as precompiled dependencies

The `ASTReader` populates `Module::PresumedModuleMapFile` only for top-level modules, not submodules. To avoid generating empty `-fmodule-map-file=` arguments, make discovered modules depend on top-level precompiled modules. The granularity of submodules is not important here.

The documentation of `Module::PresumedModuleMapFile` says this field is non-empty only when building from preprocessed source. This means there can still be cases where the dependency scanner generates empty `-fmodule-map-file=` arguments. That's being addressed in separate patch: D108544.

Reviewed By: dexonsmith

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

2 years agoHave lit preserve SOURCE_DATE_EPOCH
serge-sans-paille [Wed, 18 Aug 2021 21:48:14 +0000 (23:48 +0200)]
Have lit preserve SOURCE_DATE_EPOCH

This environment variable has been standardized for reproducible builds. Setting
it can help to have reproducible tests too, so keep it as part of the testing
env when set.

See https://reproducible-builds.org/docs/source-date-epoch/

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

2 years ago[clang][deps] Collect precompiled deps from submodules too
Jan Svoboda [Wed, 25 Aug 2021 08:14:15 +0000 (10:14 +0200)]
[clang][deps] Collect precompiled deps from submodules too

In this patch, the dependency scanner starts collecting precompiled dependencies from all encountered submodules, not only from top-level modules.

Reviewed By: dexonsmith

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

2 years ago[hwasan] do not check if freed pointer belonged to allocator.
Florian Mayer [Mon, 23 Aug 2021 13:03:16 +0000 (14:03 +0100)]
[hwasan] do not check if freed pointer belonged to allocator.

In that case it is very likely that there will be a tag mismatch anyway.

We handle the case that the pointer belongs to neither of the allocators
by getting a nullptr from allocator.GetBlockBegin.

Reviewed By: hctim, eugenis

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

2 years ago[GlobalISel] Do not generate illegal G_SEXTLOADs after legalization
Konstantin Schwarz [Tue, 24 Aug 2021 13:13:39 +0000 (15:13 +0200)]
[GlobalISel] Do not generate illegal G_SEXTLOADs after legalization

The sext_inreg_of_load combine did not have the isLegalOrBeforeLegalizer check,
leading to the generation of potentially illegal G_SEXTLOADs when run after legalization.

Reviewed By: foad

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

2 years ago[CUDA] Fix static device variables with -fgpu-rdc
Jonas Hahnfeld [Fri, 20 Aug 2021 11:28:37 +0000 (13:28 +0200)]
[CUDA] Fix static device variables with -fgpu-rdc

NVPTX does not allow dots in the identifier, so ptxas errors out with
   fatal   : Parsing error near '.static': syntax error
because it parses .static as a directive. Avoid this problem by using
two underscores, similar to what OpenMP does for outlined functions.

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

2 years ago[clang] Don't generate warn-stack-size when the warning is ignored
Yi Kong [Tue, 24 Aug 2021 09:06:08 +0000 (17:06 +0800)]
[clang] Don't generate warn-stack-size when the warning is ignored

8ace12130526 introduced a regression for code that explicitly ignores the
-Wframe-larger-than= warning. Make sure we don't generate the
warn-stack-size attribute for that case.

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

2 years agoAdd "REQUIRES: arm-registered-target" line to test added in D108603.
Douglas Yung [Wed, 25 Aug 2021 05:22:16 +0000 (22:22 -0700)]
Add "REQUIRES: arm-registered-target" line to test added in D108603.

This should fix the test failure on the PS4 build bot.

2 years ago[MachineCopyPropagation] Check CrossCopyRegClass for cross-class copys
Vang Thao [Fri, 13 Aug 2021 04:39:32 +0000 (21:39 -0700)]
[MachineCopyPropagation] Check CrossCopyRegClass for cross-class copys

On some AMDGPU subtargets, copying to and from AGPR registers using another
AGPR register is not possible. A intermediate VGPR register is needed for AGPR
to AGPR copy. This is an issue when machine copy propagation forwards a
COPY $agpr, replacing a COPY $vgpr which results in $agpr = COPY $agpr. It is
removing a cross class copy that may have been optimized by previous passes and
potentially creating an unoptimized cross class copy later on.

To avoid this issue, check CrossCopyRegClass if a different register class will
be needed for the copy. If so then avoid forwarding the copy when the
destination does not match the desired register class and if the original copy
already matches the desired register class.

Issue seen while attempting to optimize another AGPR to AGPR issue:

Live-ins: $agpr0
$vgpr0 = COPY $agpr0
$agpr1 = V_ACCVGPR_WRITE_B32 $vgpr0
$agpr2 = COPY $vgpr0
$agpr3 = COPY $vgpr0
$agpr4 = COPY $vgpr0

After machine-cp:

$vgpr0 = COPY $agpr0
$agpr1 = V_ACCVGPR_WRITE_B32 $vgpr0
$agpr2 = COPY $agpr0
$agpr3 = COPY $agpr0
$agpr4 = COPY $agpr0

Machine-cp propagated COPY $agpr0 to replace $vgpr0 creating 3 AGPR to AGPR
copys. Later this creates a cross-register copy from AGPR->VGPR->AGPR for each
copy when the prior VGPR->AGPR copy was already optimal.

Reviewed By: lkail, rampitec

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

2 years ago[JITLink][MachO] Add more detail to error message.
Lang Hames [Wed, 25 Aug 2021 03:31:06 +0000 (13:31 +1000)]
[JITLink][MachO] Add more detail to error message.

2 years ago[ORC] Fix typo in debugging output
Lang Hames [Wed, 25 Aug 2021 01:18:00 +0000 (11:18 +1000)]
[ORC] Fix typo in debugging output

2 years ago[DAGCombine] Pre-commit test for D108619
Carl Ritson [Wed, 25 Aug 2021 03:11:51 +0000 (12:11 +0900)]
[DAGCombine] Pre-commit test for D108619

2 years ago[InstrProfiling] Keep profd non-private for non-renamable comdat functions
Fangrui Song [Wed, 25 Aug 2021 03:14:02 +0000 (20:14 -0700)]
[InstrProfiling] Keep profd non-private for non-renamable comdat functions

The NS==0 condition used by D103717 missed a corner case: if the current copy
does not have a hash suffix (e.g. weak_odr), a copy with value profiling (with a
different CFG) may exist. This is super rare, but is possible with pre-inlining
PGO instrumentation (which can make a weak_odr function inlines its callees
differently, sometimes with value profiling while sometimes without).

If the current copy with private profd is prevailing, the non-prevailing copy
may get an undefined symbol if a caller inlining the non-prevailing function
references its profd. If the other copy with non-private profd is prevailing,
the current copy may cause a "relocation to discarded section" linker error.

The fix is straightforward: just keep non-private profd in such a `DataReferencedByCode` case.

With this change, a stage 2 (`-DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_BUILD_INSTRUMENTED=IR`)
clang is 0.08% larger (172431496/172286720-1).
`stat -c %s **/*.o | awk '{s+=$1}END{print s}' is 0.026% larger.
The majority of D103717's benefits remains.

Reviewed By: xur

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

2 years agoPR48030: Fix COMDAT-related linking problem with C++ thread_local static data members.
Richard Smith [Wed, 25 Aug 2021 01:34:38 +0000 (18:34 -0700)]
PR48030: Fix COMDAT-related linking problem with C++ thread_local static data members.

Previously when emitting a C++ guarded initializer, we tried to work out what
the enclosing function would be used for and added it to the COMDAT containing
the variable if we thought that doing so would be correct. But this was done
from a context in which we didn't -- and realistically couldn't -- correctly
infer how the enclosing function would be used.

Instead, add the initialization function to a COMDAT from the code that
creates it, in the case where it makes sense to do so: when we know that
the one and only reference to the initialization function is in
@llvm.global.ctors and that reference is in the same COMDAT.

Reviewed By: rjmccall

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

2 years ago[WebAssembly] Fix some UB from ca541aa319cd
Thomas Lively [Wed, 25 Aug 2021 02:44:03 +0000 (19:44 -0700)]
[WebAssembly] Fix some UB from ca541aa319cd

2 years agoRevert D108432 "[InstrProfiling] Keep profd non-private for non-renamable comdat...
Fangrui Song [Wed, 25 Aug 2021 02:16:07 +0000 (19:16 -0700)]
Revert D108432 "[InstrProfiling] Keep profd non-private for non-renamable comdat functions"

This reverts commit f653beea88d2684cdc8117e662b321ba04666771.

It broke Windows coverage-inline.cpp because link.exe has a limitation
that external symbols in IMAGE_COMDAT_SELECT_ASSOCIATIVE don't work.

It essentially dropped the previous size optimization for coverage
because coverage doesn't rename comdat by default.
Needs more investigation what we should do.

2 years ago[mlir][tosa] Quantized tosa.avg_pool2d lowering to linalg
Rob Suderman [Wed, 25 Aug 2021 01:23:21 +0000 (18:23 -0700)]
[mlir][tosa] Quantized tosa.avg_pool2d lowering to linalg

Includes the quantized version of average pool lowering to linalg dialect.
This includes a lit test for the transform. It is not 100% correct as the
multiplier / shift should be done in i64 however this is negligable rounding
difference.

Reviewed By: NatashaKnk

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

2 years ago[mlir][tosa] Table did not apply offset before extract on i8 input
Rob Suderman [Wed, 25 Aug 2021 01:14:47 +0000 (18:14 -0700)]
[mlir][tosa] Table did not apply offset before extract on i8 input

Lowering to table was incorrect as it did not apply a 128 offset before
extracting the value from the table. Fixed and correct tensor length on input
table.

Reviewed By: NatashaKnk

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

2 years ago[mlir][SCF] Generalize AffineMinSCFCanonicalization to min/max ops
Matthias Springer [Wed, 25 Aug 2021 01:28:01 +0000 (10:28 +0900)]
[mlir][SCF] Generalize AffineMinSCFCanonicalization to min/max ops

* Add support for affine.max ops to SCF loop peeling pattern.
* Add support for affine.max ops to `AffineMinSCFCanonicalizationPattern`.
* Rename `AffineMinSCFCanonicalizationPattern` to `AffineOpSCFCanonicalizationPattern`.
* Rename `AffineMinSCFCanonicalization` pass to `SCFAffineOpCanonicalization`.

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

2 years ago[mlir][sparse] Correcting the use of emplace_back
wren romano [Wed, 25 Aug 2021 01:29:05 +0000 (18:29 -0700)]
[mlir][sparse] Correcting the use of emplace_back

The emplace commands are variadic and should take all the constructor arguments directly, since they implicitly call the constructor themselves in order to avoid the cost of constructing and then moving/copying temporaries.

Reviewed By: aartbik

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

2 years ago[WebAssembly] Use SSAUpdaterBulk in LowerEmscriptenSjLj
Heejin Ahn [Tue, 17 Aug 2021 06:30:02 +0000 (23:30 -0700)]
[WebAssembly] Use SSAUpdaterBulk in LowerEmscriptenSjLj

We update SSA in two steps in Emscripten SjLj:
1. Rewrite uses of `setjmpTable` and `setjmpTableSize` variables and
   place `phi`s where necessary, which are updated where we call
   `saveSetjmp`.
2. Do a whole function level SSA update for all variables, because we
   split BBs where `setjmp` is called and there are possibly variable
   uses that are not dominated by a def.
   (See https://github.com/llvm/llvm-project/blob/955b91c19c00ed4c917559a5d66d14c669dde2e3/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp#L1314-L1324)

We have been using `SSAUpdater` to do this, but `SSAUpdaterBulk` class
was added after this pass was first created, and for the step 2 it looks
like a better alternative with a possible performance benefit. Not sure
the author is aware of it, but `SSAUpdaterBulk` seems to have a
limitation: it cannot handle a use within the same BB as a def but
before it. For example:
```
... = %a + 1
%a = foo();
```
or
```
%a = %a + 1
```
The uses `%a` in RHS should be rewritten with another SSA variable of
`%a`, most likely one generated from a `phi`. But `SSAUpdaterBulk`
thinks all uses of `%a` are below the def of `%a` within the same BB.
(`SSAUpdater` has two different functions of rewriting because of this:
`RewriteUse` and `RewriteUseAfterInsertions`.) This doesn't affect our
usage in the step 2 because that deals with possibly non-dominated uses
by defs after block splitting. But it does in the step 1, which still
uses `SSAUpdater`.

But this CL also simplifies the step 1 by using `make_early_inc_range`,
removing the need to advance the iterator before rewriting a use.

This is NFC; the test changes are just the order of PHI nodes.

Reviewed By: dschuff

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

2 years ago[mlir][tosa] Fix conv/depthwise conv padding for quantized values
Rob Suderman [Wed, 25 Aug 2021 01:08:07 +0000 (18:08 -0700)]
[mlir][tosa] Fix conv/depthwise conv padding for quantized values

When padding quantized operations, the padding needs to equal the zero point
of the input value. Corrected the pass to change the padding value if quantized.

Reviewed By: NatashaKnk

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

2 years ago[WebAssembly] Add Wasm SjLj option support for clang
Heejin Ahn [Mon, 23 Aug 2021 10:55:55 +0000 (03:55 -0700)]
[WebAssembly] Add Wasm SjLj option support for clang

This adds support for Wasm SjLj in clang. Also this sets the new
`-mllvm -wasm-enable-eh` option for Wasm EH.

Note there is a little unfortunate inconsistency there: Wasm EH is
enabled by a clang option `-fwasm-exceptions`, which sets
`-mllvm -wasm-enable-eh` in the backend options. It also sets
`-exception-model=wasm` but this is done in the common code.

Wasm SjLj doesn't have a clang-level option like `-fwasm-exceptions`.
`-fwasm-exceptions` was added because each exception model has its
corresponding `-f***-exceptions`, but I'm not sure if adding a new
option like `-fwasm-sjlj` or something is a good idea.

So the current plan is Emscripten sets `-mllvm -wasm-enable-sjlj` if
Wasm SJLj is enabled in its settings.js, as it does for Emscripten
EH/SjLj (it sets `-mllvm -enable-emscripten-cxx-exceptions` for
Emscripten EH and `-mllvm -enable-emscripten-sjlj` for Emscripten SjLj).
And setting this enables the exception handling feature, and also sets
`-exception-model=wasm`, but this time this is not done in the common
code so we do it ourselves.

Also note that other exception models have 1-to-1 correspondance with
their `-f***-exceptions` flag and their `-exception-model=***` flag, but
because we use `-exception-model=wasm` also for Wasm SjLj while
`-fwasm-exceptions` still means Wasm EH, there is also a little
inconsistency there, but I think it is manageable.

Also this adds various error checking and tests.

Reviewed By: dschuff

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

2 years ago[clang] allow -fstack-clash-protection on FreeBSD
Ed Maste [Mon, 23 Aug 2021 16:12:43 +0000 (12:12 -0400)]
[clang] allow -fstack-clash-protection on FreeBSD

-fstack-clash-protection was added in Clang commit e67cbac81211 but was
enabled only on Linux.  Allow it on FreeBSD as well, as it works fine.

Reviewed By: serge-sans-paille

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

2 years ago[gn build] Manually port dbed061b more
Nico Weber [Wed, 25 Aug 2021 01:01:20 +0000 (21:01 -0400)]
[gn build] Manually port dbed061b more

2 years ago[WebAssembly] Tidy up EH/SjLj options
Heejin Ahn [Sat, 7 Aug 2021 02:35:18 +0000 (19:35 -0700)]
[WebAssembly] Tidy up EH/SjLj options

This CL is small, but the description can be a little long because I'm
trying to sum up the status quo for Emscripten/Wasm EH/SjLj options.

First, this CL adds an option for Wasm SjLj (`-wasm-enable-sjlj`), which
handles SjLj using Wasm EH. The implementation for this will be added as
a followup CL, but this adds the option first to do error checking.

This also adds an option for Wasm EH (`-wasm-enable-eh`), which has been
already implemented. Before we used `-exception-model=wasm` as the same
meaning as enabling Wasm EH, but after we add Wasm SjLj, it will be
possible to use Wasm EH instructions for Wasm SjLj while not enabling
EH, so going forward, to use Wasm EH, `opt` and `llc` will need this
option. This only affects `opt` and `llc` command lines and does not
affect Emscripten user interface.

Now we have two modes of EH (Emscripten/Wasm) and also two modes of SjLj
(also Emscripten/Wasm). The options corresponding to each of are:
- Emscripten EH: `-enable-emscripten-cxx-exceptions`
- Emscripten SjLj: `-enable-emscripten-sjlj`
- Wasm EH: `-wasm-enable-eh -exception-model=wasm`
           `-mattr=+exception-handling`
- Wasm SjLj: `-wasm-enable-sjlj -exception-model=wasm`
             `-mattr=+exception-handling`
The reason Wasm EH/SjLj's options are a little complicated are
`-exception-model` and `-mattr` are common LLVM options ane not under
our control. (`-mattr` can be omitted if it is embedded within the
bitcode file.)

And we have the following rules of the option composition:
- Emscripten EH and Wasm EH cannot be turned on at the same itme
- Emscripten SjLj and Wasm SjLj cannot be turned on at the same time
- Wasm SjLj should be used with Wasm EH

Which means we now allow these combinations:
- Emscripten EH + Emscripten SjLj: the current default in `emcc`
- Wasm EH + Emscripten SjLj:
  This is allowed, but only as an interim step in which we are testing
  Wasm EH but not yet have a working implementation of Wasm SjLj. This
  will error out (D107687) in compile time if `setjmp` is called in a
  function in which Wasm exception is used.
- Wasm EH + Wasm SjLj:
  This will be the default mode later when using Wasm EH. Currently Wasm
  SjLj implementation doesn't exist, so it doesn't work.
- Emscripten EH + Wasm SjLj will not work.

This CL moves these error checking routines to
`WebAssemblyPassConfig::addIRPasses`. Not sure if this is an ideal place
to do this, but I couldn't find elsewhere. Currently some checking is
done within LowerEmscriptenEHSjLj, but these checks only run if
LowerEmscriptenEHSjLj runs so it may not run when Wasm EH is used. This
moves that to `addIRPasses` and adds some more checks.

Currently LowerEmscriptenEHSjLj pass is responsible for Emscripten EH
and Emscripten SjLj. Wasm EH transformations are done in multiple
places, including WasmEHPrepare, LateEHPrepare, and CFGStackify. But in
the followup CL, LowerEmscriptenEHSjLj pass will be also responsible for
a part of Wasm SjLj transformation, because WasmSjLj will also be using
several Emscripten library functions, and we will be sharing more than
half of the transformation to do that between Emscripten SjLj and Wasm
SjLj.

Currently we have `-enable-emscripten-cxx-exceptions` and
`-enable-emscripten-sjlj` but these only work for `llc`, because for
`llc` we feed these options to the pass but when we run the pass using
`opt` the pass will be created with no options and the default options
will be used, which turns both Emscripten EH and Emscripten SjLj on.

Now we have one more SjLj option to care for, LowerEmscriptenEHSjLj pass
needs a finer way to control these options. This CL removes those
default parameters and make LowerEmscriptenEHSjLj pass read directly
from command line options specified. So if we only run
`opt -wasm-lower-em-ehsjlj`, currently both Emscripten EH and Emscripten
SjLj will run, but with this CL, none will run unless we additionally
pass `-enable-emscripten-cxx-exceptions` or `-enable-emscripten-sjlj`,
or both. This does not affect users; this only affects our `opt` tests
because `emcc` will not call either `opt` or `llc`. As a result of this,
our existing Emscripten EH/SjLj tests gained one or both of those
options in their `RUN` lines.

Reviewed By: dschuff

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

2 years ago[GlobalOpt] Fix the assert for null check of global value
Shimin Cui [Wed, 25 Aug 2021 00:47:33 +0000 (20:47 -0400)]
[GlobalOpt] Fix the assert for null check of global value

This is to fix the reported assert - https://bugs.llvm.org/show_bug.cgi?id=51608.

Reviewed By: asbirlea

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

2 years ago[mlir][docs] A friendlier improvement for the Toy tutorial chapter 4.
Chenggang Zhao [Wed, 25 Aug 2021 00:41:35 +0000 (00:41 +0000)]
[mlir][docs] A friendlier improvement for the Toy tutorial chapter 4.

Add notes for discarding private-visible functions in the Toy tutorial chapter 4.

Reviewed By: mehdi_amini

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

2 years ago[libomptarget][amdgpu] Fix debug build from D104696
Jon Chesterfield [Wed, 25 Aug 2021 00:26:45 +0000 (01:26 +0100)]
[libomptarget][amdgpu] Fix debug build from D104696

2 years ago[WebAssembly] Fix up out-of-range BUILD_VECTOR lane constants
Thomas Lively [Wed, 25 Aug 2021 00:24:03 +0000 (17:24 -0700)]
[WebAssembly] Fix up out-of-range BUILD_VECTOR lane constants

Fixes PR51605 in which a DAG combine and legalization sequence generated
out-of-range constants in BUILD_VECTOR lanes. In the v16i8 case, the constants
were 255, which would be in range if DAG ISel used unsigned constants, but it is
out of range because DAG ISel uses signed constants.

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

2 years ago[msan] Unpoison trailing nullptr in wordexp interceptor
Vitaly Buka [Tue, 24 Aug 2021 21:43:59 +0000 (14:43 -0700)]
[msan] Unpoison trailing nullptr in wordexp interceptor

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

2 years ago[msan] Don't EXPECT_POISONED beyond the we_wordv
Vitaly Buka [Wed, 25 Aug 2021 00:11:51 +0000 (17:11 -0700)]
[msan] Don't EXPECT_POISONED beyond the we_wordv

Partially reverts commit 629411d799223d7bc7aad98661b1443a4788c0c5.

EXPECT_POISONED argument is outside of the allocation so we can't
assume the state of shadow there.

2 years agoExtend diagnostic for out of date AST input file.
Richard Smith [Fri, 23 Jul 2021 00:52:16 +0000 (17:52 -0700)]
Extend diagnostic for out of date AST input file.

If the size has changed, list the old and new sizes; if the mtime has
changed, list the old and new mtimes (as raw time_t values).

2 years ago[mlir][linalg] Replace AffineMinSCFCanonicalizationPattern with SCF reimplementation
Matthias Springer [Tue, 24 Aug 2021 23:47:05 +0000 (08:47 +0900)]
[mlir][linalg] Replace AffineMinSCFCanonicalizationPattern with SCF reimplementation

Use the new canonicalization pattern in the SCF dialect.

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

2 years ago[msan] Fix wordexp after D108646
Vitaly Buka [Tue, 24 Aug 2021 23:23:50 +0000 (16:23 -0700)]
[msan] Fix wordexp after D108646

I introduced this bug reformating the patch before commit.

2 years agoRevert "[AArch64][GlobalISel] Don't contract cross-bank copies into truncating stores."
Amara Emerson [Tue, 24 Aug 2021 23:08:08 +0000 (16:08 -0700)]
Revert "[AArch64][GlobalISel] Don't contract cross-bank copies into truncating stores."

This reverts commit 67bf3ac7446bd8ba16bb5ef82fa9f28a848616da.

The reason is that this change is now superseded by 04fb9b729a53 which fixes the
underlying problem in the selector. Now it's fine to generate truncating FP stores
since the selector code will just generate subreg copies to handle them.

2 years ago[mlir][sparse] enable a few vectorized runs in integration tests
Aart Bik [Tue, 24 Aug 2021 22:18:29 +0000 (15:18 -0700)]
[mlir][sparse] enable a few vectorized runs in integration tests

Recent changes outside sparse compiler exposed the requirement of running a
new pass (lower-affine) but this only became apparent with private testing.
By adding some vectorized runs to integration test, we will detect the need
for such changes earlier and also widen codegen coverage of course.

Reviewed By: gussmith23

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

2 years ago[AArch64][GlobalISel] Fix incorrect handling of fp truncating stores.
Amara Emerson [Tue, 24 Aug 2021 20:56:01 +0000 (13:56 -0700)]
[AArch64][GlobalISel] Fix incorrect handling of fp truncating stores.

When the tablegen patterns fail to select a truncating scalar FPR store,
our manual selection code also failed to handle it silently, trying to
generate an invalid copy. Fix this by adding support in the manual code
to generate a proper subreg copy before selecting a non-truncating store.

2 years ago[InstrProfiling] Keep profd non-private for non-renamable comdat functions
Fangrui Song [Tue, 24 Aug 2021 22:59:35 +0000 (15:59 -0700)]
[InstrProfiling] Keep profd non-private for non-renamable comdat functions

The NS==0 condition used by D103717 missed a corner case: if the current copy
does not have a hash suffix (e.g. weak_odr), a copy with value profiling (with a
different CFG) may exist. This is super rare, but is possible with pre-inlining
PGO instrumentation (which can make a weak_odr function inlines its callees
differently, sometimes with value profiling while sometimes without).

If the current copy with private profd is prevailing, the non-prevailing copy
may get an undefined symbol if a caller inlining the non-prevailing function
references its profd. If the other copy with non-private profd is prevailing,
the current copy may cause a "relocation to discarded section" linker error.

The fix is straightforward: just keep non-private profd in this case.

With this change, a stage 2 (`-DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_BUILD_INSTRUMENTED=IR`)
clang is 0.08% larger (172431496/172286720-1).
`stat -c %s **/*.o | awk '{s+=$1}END{print s}' is 0.026% larger.
The majority of D103717's benefits remains.

Reviewed By: xur

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

2 years ago[mlir][scf] Add general affine.min canonicalization pattern
Matthias Springer [Tue, 24 Aug 2021 12:21:12 +0000 (21:21 +0900)]
[mlir][scf] Add general affine.min canonicalization pattern

This canonicalization simplifies affine.min operations inside "for loop"-like operations (e.g., scf.for and scf.parallel) based on two invariants:
* iv >= lb
* iv < lb + step * ((ub - lb - 1) floorDiv step) + 1

This commit adds a new pass `canonicalize-scf-affine-min` (instead of being a canonicalization pattern) to avoid dependencies between the Affine dialect and the SCF dialect.

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

2 years agoRevert "[lldb] Add support for debugging via the dynamic linker."
Rumeet Dhindsa [Tue, 24 Aug 2021 22:20:52 +0000 (15:20 -0700)]
Revert "[lldb] Add support for debugging via the dynamic linker."

This reverts commit 1cbdc07ec015d83038c08dc562d55eccfd808591.

Buildbot failure started after this patch with failure in
api/multithreaded/TestMultithreaded.py:
https://lab.llvm.org/buildbot/#/builders/68/builds/17556

2 years ago[mlir] Fix attachInterface typo
Logan Chien [Tue, 24 Aug 2021 21:39:59 +0000 (14:39 -0700)]
[mlir] Fix attachInterface typo

This commit fixes the documentation typo regarding `attachInterface`.

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

2 years ago[DFSan] Add wrapper for getentropy().
Andrew Browne [Tue, 24 Aug 2021 01:33:25 +0000 (18:33 -0700)]
[DFSan] Add wrapper for getentropy().

Reviewed By: morehouse

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

2 years ago[sanitizer coverage] add a basic default implementation of callbacks for -fsanitize...
Kostya Serebryany [Thu, 19 Aug 2021 20:45:36 +0000 (13:45 -0700)]
[sanitizer coverage] add a basic default implementation of callbacks for -fsanitize-coverage=inline-8bit-counters,pc-table

[sanitizer coverage] add a basic default implementation of callbacks for -fsanitize-coverage=inline-8bit-counters,pc-table

Reviewed By: kostik

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

2 years ago[LLDB] Remove typos from NativeRegisterContextLinux_arm*
Muhammad Omair Javaid [Tue, 24 Aug 2021 21:53:31 +0000 (02:53 +0500)]
[LLDB] Remove typos from NativeRegisterContextLinux_arm*

This patch removed some typos from NativeRegisterContextLinux_arm and
NativeRegisterContextLinux_arm64. Some of the log/error messages were
being reported as x86_64.

2 years agoRevert "[lldb] Refactor Module::LookupInfo constructor"
Alex Langford [Tue, 24 Aug 2021 21:52:17 +0000 (14:52 -0700)]
Revert "[lldb] Refactor Module::LookupInfo constructor"

This reverts commit cd2134e42aa7d1168a3ed54e41793b022f961b1f.

Seems like this broke some tests on arm and aarch64 boxes. Will
investigate before re-landing.

2 years ago[MSAN] Fix wordexp interception when WRDE_DOOFFS is used
Justin Cady [Tue, 24 Aug 2021 19:34:41 +0000 (12:34 -0700)]
[MSAN] Fix wordexp interception when WRDE_DOOFFS is used

Handle the case of wordexp being invoked with WRDE_DOOFFS and
we.we_offs set to a positive value, which will result in NULL
entries prepended to the result. With this change the entire
result, containing both NULL and actual entries, is unpoisoned.

Reviewed By: vitalybuka

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

2 years ago[tests] Add a couple tests for intersection of ec8d87e and D108651
Philip Reames [Tue, 24 Aug 2021 21:28:57 +0000 (14:28 -0700)]
[tests] Add a couple tests for intersection of ec8d87e and D108651

2 years ago[clang][codegen] Set CurLinkModule in CodeGenAction::ExecuteAction
Bob Haarman [Sat, 21 Aug 2021 00:14:32 +0000 (00:14 +0000)]
[clang][codegen] Set CurLinkModule in CodeGenAction::ExecuteAction

CodeGenAction::ExecuteAction creates a BackendConsumer for the
purpose of handling diagnostics. The BackendConsumer's
DiagnosticHandlerImpl method expects CurLinkModule to be set,
but this did not happen on the code path that goes through
ExecuteAction. This change makes it so that the BackendConsumer
constructor used by ExecuteAction requires the Module to be
specified and passes the appropriate module in ExecuteAction.

The change also adds a test that fails without this change
and passes with it. To make the test work, the FIXME in the
handling of DK_Linker diagnostics was addressed so that warnings
and notes are no longer silently discarded. Since this introduces
a new warning diagnostic, a flag to control it (-Wlinker-warnings)
has also been added.

Reviewed By: xur

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

2 years ago[SCEV] Infer nuw from nw for addrecs
Philip Reames [Tue, 24 Aug 2021 21:23:03 +0000 (14:23 -0700)]
[SCEV] Infer nuw from nw for addrecs

This was previously committed in 914836b, and reverted due to confusion on the status of the review.

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

2 years ago[orc] Fix unit tests that use ORC C API
Ben Langmuir [Tue, 24 Aug 2021 18:10:11 +0000 (11:10 -0700)]
[orc] Fix unit tests that use ORC C API

* c_api_tests was failing to build after the API change to
  __orc_rt_CWrapperFunctionResultAllocate

* wrapper_function_utils_test was causing an assertion failure, because
  it was creating a result for `void(void)` with Size = 0, but seeing an
  uninitialized pointer, which it considered to be an out-of-bound
  error.

I noticed locally that making modifications to c_api.h is not causing
these unit tests to be rebuilt, which may be how the bug slipped in in
the first place.

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

2 years ago[test] Prcommit tests for D108651
Philip Reames [Tue, 24 Aug 2021 21:18:50 +0000 (14:18 -0700)]
[test] Prcommit tests for D108651

2 years ago[hwasan] Always untag short granule in shadow.
Mitch Phillips [Tue, 24 Aug 2021 21:10:02 +0000 (14:10 -0700)]
[hwasan] Always untag short granule in shadow.

Fixes a regression when the allocator is disabled, and a dirty
allocation is re-used. This only occurs when the allocator is disabled,
so a test-only fix, but still necessary.

Reviewed By: eugenis

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

2 years ago[X86] Add explicit library dependency on LLVMInstrumentation
Min-Yih Hsu [Tue, 24 Aug 2021 21:07:21 +0000 (14:07 -0700)]
[X86] Add explicit library dependency on LLVMInstrumentation

Patch 9588b685c6b2 introduced dependency on ASAN. But it didn't
explicitly put LLVMInstrumentation as one of the library dependencies
such that the build will fail if we're building LLVM as shared libraries
(i.e. -DBUILD_SHARED_LIBS=ON).
This patch explicitly links X86CodeGen against the Instrumentation
component.

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

2 years ago[AArch64][GlobalISel] Legalize narrow scalar FP arithmetic
Jessica Paquette [Tue, 24 Aug 2021 20:21:15 +0000 (13:21 -0700)]
[AArch64][GlobalISel] Legalize narrow scalar FP arithmetic

Widen narrow fp arithmetic ops (e.g. G_FADD). When we don't have full FP16
support, widen to s32. Otherwise widen to s16.

https://godbolt.org/z/TbT9Pqa7e

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

2 years ago[lldb] Refactor Module::LookupInfo constructor
Alex Langford [Tue, 17 Aug 2021 17:55:05 +0000 (10:55 -0700)]
[lldb] Refactor Module::LookupInfo constructor

Module::LookupInfo's constructor currently goes over supported languages
trying to figure out the best way to search for a symbol name. This
seems like a great candidate for refactoring. Specifically, this is work
that can be delegated to language plugins.

Once again, the goal here is to further decouple plugins from
non-plugins. The idea is to have each language plugin take a name and
give you back some information about the name from the perspective of
the language. Specifically, each language now implements a
`GetFunctionNameInfo` method which returns an object of type
`Language::FunctionNameInfo`. Right now, it consists of a basename,
a context, and a FunctionNameType. Module::LookupInfo's constructor will
call `GetFunctionNameInfo` with the appropriate language plugin(s) and
then decide what to do with that information. I have attempted to maintain
existing behavior as best as possible.

A nice side effect of this change is that lldbCore no longer links
against the ObjC Language plugin.

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

2 years ago[libc++abi] Apply simplify scan_eh_tab to SjLj
Kazushi (Jam) Marukawa [Tue, 24 Aug 2021 20:51:21 +0000 (16:51 -0400)]
[libc++abi] Apply simplify scan_eh_tab to SjLj

Previous "simplify scan_eh_tab" patch, https://reviews.llvm.org/D93190,
saves landingpad if and only if the target is not using SjLj exceptions.
However, the landingpad is used by SjLj exception handler also.  This
patch changes to set landingpad for both exception handlers.

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

2 years ago[lldb] Add support for debugging via the dynamic linker.
Rumeet Dhindsa [Tue, 24 Aug 2021 20:38:45 +0000 (13:38 -0700)]
[lldb] Add support for debugging via the dynamic linker.

This patch adds support for shared library load when the executable is
called through ld.so.

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

2 years ago[gn build] (manually) port 87dd51983cf9
Nico Weber [Tue, 24 Aug 2021 20:40:44 +0000 (16:40 -0400)]
[gn build] (manually) port 87dd51983cf9