platform/upstream/llvm.git
15 months ago[AMDGPU] TableGen syntax cleanups
Jay Foad [Thu, 30 Mar 2023 10:24:39 +0000 (11:24 +0100)]
[AMDGPU] TableGen syntax cleanups

15 months ago[NFC] Fix potential for use-after-free in DumpModuleInfoAction
Mariya Podchishchaeva [Thu, 30 Mar 2023 10:04:28 +0000 (06:04 -0400)]
[NFC] Fix potential for use-after-free in DumpModuleInfoAction

Since each `DumpModuleInfoAction` can now contain a pointer to a
`raw_ostream`, saving there a poiter that owned by a local `unique_ptr`
may cause use-after-free. Clarify ownership and save a `shared_ptr`
inside of `DumpModuleInfoAction` instead.
Found by static analyzer.

Reviewed By: tahonermann, aaron.ballman

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

15 months agoRevert "[LSR] Preserve LCSSA when rewriting instruction with PHI user"
Nico Weber [Thu, 30 Mar 2023 10:40:16 +0000 (06:40 -0400)]
Revert "[LSR] Preserve LCSSA when rewriting instruction with PHI user"

This reverts commit 8ff4832679e1ff2d2a1cfaa45bb5cb995b0685a1.
Breaks tests, see https://reviews.llvm.org/D146811#4232839

15 months ago[mlir][transform] Fix typo in TrackingListener
Matthias Springer [Thu, 30 Mar 2023 10:08:20 +0000 (12:08 +0200)]
[mlir][transform] Fix typo in TrackingListener

This was an oversight in D147206. The function should not have been made
`const` (just like the other `notify...` functions).

15 months ago[clangd] Map references from include'd files to directives
Kadir Cetinkaya [Wed, 29 Mar 2023 11:09:39 +0000 (13:09 +0200)]
[clangd] Map references from include'd files to directives

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

15 months ago[AMDGPU] Remove two unused ComplexRendererFns
Jay Foad [Thu, 30 Mar 2023 09:43:37 +0000 (10:43 +0100)]
[AMDGPU] Remove two unused ComplexRendererFns

These were left over after https://reviews.llvm.org/D98663

15 months ago[mlir] Fix folding into tensor.pad op.
Alexander Belyaev [Thu, 30 Mar 2023 09:26:09 +0000 (11:26 +0200)]
[mlir] Fix folding into tensor.pad op.

When low/high padding is folded in padOp, there should be inserted a
tensor.cast back to the original result type. Right now, there is a no-op
tensor.cast from new type to new type...

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

15 months ago[AArch64] Extend icmp bitcast to vecreduce fold to comparison with -1
Nikita Popov [Tue, 21 Mar 2023 11:14:44 +0000 (12:14 +0100)]
[AArch64] Extend icmp bitcast to vecreduce fold to comparison with -1

D130163 added support for folding
setcc (iN (bitcast (vNi1 X))), 0, (eq|ne) to
setcc (iN (zext (i1 (vecreduce_or (vNi1 X))))), 0, (eq|ne).

There is a conjugate fold for comparison with -1 which uses
vecreduce_and and sext instead.

Proof: https://alive2.llvm.org/ce/z/Zz--xy

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

15 months ago[mlir][transform] Add optional error checking to TrackingListener
Matthias Springer [Thu, 30 Mar 2023 08:18:10 +0000 (10:18 +0200)]
[mlir][transform] Add optional error checking to TrackingListener

Derived classes can implement `notifyPayloadReplacementNotFound` for custom error checking.

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

15 months ago[mlir] Apply ClangTidy readability fix (NFC).
Adrian Kuegel [Thu, 30 Mar 2023 08:43:15 +0000 (10:43 +0200)]
[mlir] Apply ClangTidy readability fix (NFC).

15 months ago[flang][hlfir] disable region simplification in HLFIR pipeline
Jean Perier [Thu, 30 Mar 2023 07:48:45 +0000 (09:48 +0200)]
[flang][hlfir] disable region simplification in HLFIR pipeline

Block merging is disabled with FIR: some FIR value should not be promoted
to block arguments, and the region simplification block merging is
promoting all SSA value types to block argument when two blocks are
similar except for the usage these values.

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

15 months ago[LSR] Preserve LCSSA when rewriting instruction with PHI user
Dmitry Makogon [Fri, 24 Mar 2023 13:42:30 +0000 (20:42 +0700)]
[LSR] Preserve LCSSA when rewriting instruction with PHI user

Fixes https://github.com/llvm/llvm-project/issues/61182.

LoopStrengthReduce may sometimes break LCSSA form when applying a rewrite
for an instruction used in a PHI.
It happens if:
 - The PHI is in a loop exit block,
 - The edge from the corresponding exiting block to that exit is critical,
 - The PHI has at least two inputs coming from loop blocks,
 - and the rewritten instruction is inserted in the loop.

In such case we split the critical edge and then replace PHI inputs
with the rewritten instruction. However ExitBlock is no longer
a loop exit, so LCSSA form is broken.

This patch fixes it by collecting all inserted instructions for PHIs
whose parent block is not a loop exit and then forming LCSSA for them.

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

15 months ago[CodeGen] Remove redundent instructions generated by combineAddrModes.
Peter Rong [Tue, 28 Mar 2023 12:14:23 +0000 (05:14 -0700)]
[CodeGen] Remove redundent instructions generated by combineAddrModes.

CodeGenPare may optimize memory access modes.
During such optimization, it might create a new instruction representing combined value.
Later, If the optimization failed, the generated value is not removed and remains a dead instruction.

Normally this won't be a problem as dead code will be eliminated later.
However, in this case (Issue 58538), the generated instruction may trigger an infinite loop.
The infinite loop involves `sinkCmpExpression`, where it tries to optimize the placeholder generated by us.
(See the test case detailed in the issue)

To fix this, we remove the unnecessary placeholder immediately when we abort the optimization.
`AddressingModeCombiner` will keep track of the placeholder, and remove it if it is an inserted placeholder and has no uses.
This patch fixes https://github.com/llvm/llvm-project/issues/58538, a test is also included.

Reviewed By: skatkov

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

15 months ago[RISCV] isDigit instead of isdigit for consistency. NFC
Craig Topper [Thu, 30 Mar 2023 07:10:36 +0000 (00:10 -0700)]
[RISCV] isDigit instead of isdigit for consistency. NFC

There are several other calls to isDigit in RISCVISAInfo.cpp

15 months ago[symbolizer] Additional tests for invalid address handling
Serge Pavlov [Thu, 30 Mar 2023 06:29:48 +0000 (13:29 +0700)]
[symbolizer] Additional tests for invalid address handling

These tests check GNU-compatible output if llvm-symbolizer is called with
the option --output-style=GNU and LLVM-style output if llvm-addr2line is
called with --output-style=LLVM.

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

15 months agoUse Dense{Map,Set}::contains (NFC)
Kazu Hirata [Thu, 30 Mar 2023 06:01:11 +0000 (23:01 -0700)]
Use Dense{Map,Set}::contains (NFC)

15 months ago[RISCV] Replace std::string with StringRef in RISCVISAInfo. NFC
Craig Topper [Thu, 30 Mar 2023 05:22:57 +0000 (22:22 -0700)]
[RISCV] Replace std::string with StringRef in RISCVISAInfo. NFC

We're just slicing off part of an existing StringRef. No need to
allocate any new storage.

15 months ago[WASM] Precommit WebAssemblyISelLowering.cpp format changes for D147198
Peter Rong [Thu, 30 Mar 2023 05:17:59 +0000 (22:17 -0700)]
[WASM] Precommit WebAssemblyISelLowering.cpp format changes for D147198

Signed-off-by: Peter Rong <PeterRong96@gmail.com>
15 months ago[compiler-rt] Fix cross-compiling detection
Hau Hsu [Thu, 30 Mar 2023 04:47:33 +0000 (12:47 +0800)]
[compiler-rt] Fix cross-compiling detection

Previously the detection compares "CMAKE_SYSTEM_NAME" and
"CMAKE_TARGET_SYSTEM_NAME", which only contains OS names like "Linux".
This is not sufficient when cross-compiling for different target CPUs.

This patch uses CMAKE_CROSSCOMPILING, which sets automatically by CMake
when cross compiling.

Reviewed By: smeenai, phosek

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

15 months ago[DWARFLinker] Honor verbose flag for input verification
Jonas Devlieghere [Thu, 30 Mar 2023 04:51:45 +0000 (21:51 -0700)]
[DWARFLinker] Honor verbose flag for input verification

Fix an inconsistency between input and output verification in dsymutil.
Previously, output verification would be controlled by the verbose flag,
while input verification would unconditionally dump to stdout. Make
input and output verification behave the same by printing verification
error to stderr in verbose mode only.

15 months ago[RISCV] Use StringRef(&C, 1) instead of std::string(1, C).
Craig Topper [Thu, 30 Mar 2023 04:37:26 +0000 (21:37 -0700)]
[RISCV] Use StringRef(&C, 1) instead of std::string(1, C).

We're calling functions that take a StringRef. We can create one
from a single character variable without using std::string.

15 months ago[ARM] Use isNullConstant and isOneConstant (NFC)
Kazu Hirata [Thu, 30 Mar 2023 04:50:34 +0000 (21:50 -0700)]
[ARM] Use isNullConstant and isOneConstant (NFC)

15 months ago[GuardWidening] Freeze the introduced use. Re-land.
Serguei Katkov [Thu, 30 Mar 2023 03:21:31 +0000 (10:21 +0700)]
[GuardWidening] Freeze the introduced use. Re-land.

Non-determenism is fixed.

Guard widening optimization is able to move the condition from one
guard to the previous one. As a result if the condition is poison
and orginal second guard is never executed but the first one does,
we introduce undefined behavior which was not observed in original
program.

To resolve the issue we must freeze the condition we are moving.
However optimization itself does not know how to work with freeze.
Additionally optimization is written in incremental way.
For example we have three guards
G1(base + 8 < L)
G2(base + 16 < L)
G3(base + 24 < L)

On the first step GW will combine G1 and G2 as
G1(base + 8 < L && freeze(base + 16 < L))
G2(true)
G3(base + 24 < L)

while combining G1 and G3 base appears to be different.

To keep optimization enabled after freezing the moving condition, the
freeze instruction is pushed as much as possible and later all uses
of freezed values are replaced with frozen version.

This is similar what instruction combining does but more aggressevely.

15 months ago[lld][ELF][NFC] Simplify method "Thunk *elf::addThunk()"
Ben Shi [Thu, 30 Mar 2023 03:34:19 +0000 (11:34 +0800)]
[lld][ELF][NFC] Simplify method "Thunk *elf::addThunk()"

Reviewed By: MaskRay

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

15 months ago[MCP] Do not try forward non-existent sub-register of a copy
Sergei Barannikov [Sun, 26 Mar 2023 23:22:46 +0000 (02:22 +0300)]
[MCP] Do not try forward non-existent sub-register of a copy

In this example:
```
$d14 = COPY killed $d18
$s0 = MI $s28
```

$s28 is a sub-register of $d14. However, $d18 does not have
sub-registers and thus cannot be forwarded. Previously, this resulted
in $noreg being substituted in place of the use of $s28, which later
led to an assertion failure.

Fixes https://github.com/llvm/llvm-project/issues/60908, a regression
that was introduced in D141747.

Reviewed By: arsenm

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

15 months ago[MachineScheduler] Rename postprocessDAG to postProcessDAG. NFC
jacquesguan [Fri, 24 Mar 2023 10:18:25 +0000 (18:18 +0800)]
[MachineScheduler] Rename postprocessDAG to postProcessDAG. NFC

Rename postprocessDAG to camel case.

Reviewed By: foad

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

15 months agoHandle the unexpected inputs for pass HardwareLoops
Wang, Xin10 [Thu, 30 Mar 2023 02:33:57 +0000 (10:33 +0800)]
Handle the unexpected inputs for pass HardwareLoops

For a function TryConvertLoop in pass HardwareLoops, wrong input arguments will
lead to crash. There will be 3 cases.
In line 342, compiler want to get something from
HWLoopInfo.CountType, which depends on if argument Bitwidth is given, if not,
will crash.
In Function isHardwareLoopCandidate, it dereference CountType too.
In Function InsertLoopDec, it dereference LoopDecrement.
They all could lead to crash. This patch add condition to this pass, when we meet unexpected inputs then skip
the pass.

Reviewed By: samparker, fhahn

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

15 months agoRevert "Reland "[hwasan] Provide aliases for c allocation functions for Fuchsia"
Leonard Chan [Thu, 30 Mar 2023 01:38:05 +0000 (01:38 +0000)]
Revert "Reland "[hwasan] Provide aliases for c allocation functions for Fuchsia"

This reverts commit 5bb826d569ccd80e28aedd682db39b8cddd44e53.

We suspect this is leading to the segfaults for tests run on
aarch64+android+hwasan:
https://lab.llvm.org/buildbot/#/builders/77/builds/26025/steps/21/logs/stdio

15 months ago[mlir][sparse] avoid creating temporary unordered COO buffer when reshape sparse...
Peiming Liu [Thu, 30 Mar 2023 01:01:13 +0000 (01:01 +0000)]
[mlir][sparse] avoid creating temporary unordered COO buffer when reshape sparse tensor.

Reviewed By: aartbik, wrengr

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

15 months ago[SYCL] Always set NoUnwind attribute for SYCL.
Harald van Dijk [Thu, 30 Mar 2023 01:18:52 +0000 (02:18 +0100)]
[SYCL] Always set NoUnwind attribute for SYCL.

Like CUDA and OpenCL, the SYCL specification says that throwing and
catching exceptions in device functions is not supported, so this change
extends the logic for adding the NoUnwind attribute to SYCL.

The existing convergent.cpp test, which tests that the convergent
attribute is added to functions by default, is renamed and reused to
test that the nounwind attribute is added by default. This test now has
-fexceptions added to it, which the driver adds by default as well.

The obvious question here is why not simply change the driver to remove
-fexceptions. This change follows the direction given by the TODO
comment because removing -fexceptions would also disable the
__EXCEPTIONS macro, which should reflect whether exceptions are enabled
on the host, rather than on the device, to avoid conflicts in types
shared between host and device.

Reviewed By: bader

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

15 months ago[mlir][sparse] Preliminary code changes for ExprId, LatPointId, LatSetId newtypes
wren romano [Fri, 24 Mar 2023 23:03:56 +0000 (16:03 -0700)]
[mlir][sparse] Preliminary code changes for ExprId, LatPointId, LatSetId newtypes

This commit contains several code changes which are ultimately required for converting the varions `Merger` identifiers from typedefs to newtypes.  The actual implementation of the newtypes themselves has been split off into separate commits, in hopes of simplifying the review process.

Depends On D146561

Reviewed By: aartbik

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

15 months ago[mlir][arith] Add expansion pattern for ext/trunc of bf16
Robert Suderman [Thu, 30 Mar 2023 00:49:01 +0000 (00:49 +0000)]
[mlir][arith] Add expansion pattern for ext/trunc of bf16

bf16 has a trivial truncation/extension behavior with F32 that
can be described in elementary arith operations. Include some
expansions to efficiently convert.

Reviewed By: jpienaar

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

15 months ago[DAG][RISCV] Allow scalable vector ISD::STRICT_FP_ROUND and support vector ISD::STRIC...
Yeting Kuo [Wed, 29 Mar 2023 05:22:54 +0000 (13:22 +0800)]
[DAG][RISCV] Allow scalable vector ISD::STRICT_FP_ROUND and support vector ISD::STRICT_FP_ROUND for RISC-V.

The patch customized lower vector type ISD::STRICT_FP_ROUND to RISCVISD::STRICT_FP_ROUND.

Reviewed By: craig.topper

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

15 months agoRevert "[libc++] Add minor test for polymorphic_allocator.construct with mixed argume...
Haowei Wu [Thu, 30 Mar 2023 00:07:31 +0000 (17:07 -0700)]
Revert "[libc++] Add minor test for polymorphic_allocator.construct with mixed argument pair"

This reverts commit b66a6e4b104b245ed448e3dea944fa7e842a96b2 which
breaks runtime tests.

15 months ago[gn build] Port 167e8f8b6b11
LLVM GN Syncbot [Wed, 29 Mar 2023 23:24:32 +0000 (23:24 +0000)]
[gn build] Port 167e8f8b6b11

15 months ago[InstrProf] Minimal Block Coverage
Ellis Hoag [Wed, 29 Mar 2023 19:58:42 +0000 (12:58 -0700)]
[InstrProf] Minimal Block Coverage

This diff implements minimal block coverage instrumentation. When the `-pgo-block-coverage` option is used, basic blocks will be instrumented for block coverage using single byte booleans. The coverage of some basic blocks can be inferred from others, so not every basic block is instrumented. In fact, we found that only ~60% of basic blocks need to be instrumented. These differences lead to less size overhead when compared to instrumenting block counts. For example, block coverage on the clang binary has an overhead of 20 Mi (17%) compared to 56 Mi (47%) with block counts.

Even though block coverage profiles have less precision than block count profiles, they can still be used to guide optimizations. In `PGOUseFunc` we use block coverage to populate edge weights such that BFI gives nonzero counts to only covered blocks. We do this by 1) setting the entry count of covered functions to a large value, i.e., 10000 and 2) populating edge weights using block coverage. In the next diff https://reviews.llvm.org/D125743 we use BFI to guide the machine outliner to avoid outlining covered blocks. This `-pgo-block-coverage` option provides a trade off of generating less precise profiles for faster and smaller instrumented binaries.

The `BlockCoverageInference` class defines the algorithm to find the minimal set of basic blocks that need to be instrumented for coverage. This is different from the Kirchhoff circuit law optimization that is used for edge **counts** because that does not work for block **coverage**. The reason for this is that edge counts can be added together to find a missing count while block coverage cannot since they store boolean values. So we need a new algorithm to find which blocks must be instrumented.

The details on this algorithm can be found in this paper titled "Minimum Coverage Instrumentation": https://arxiv.org/abs/2208.13907

Special thanks to Julian Mestre for creating this block coverage inference algorithm.

Binary size of `clang` using `-O2`:

* Base
  * `.text`: 65.8 Mi
  * Total: 119 Mi
* IRPGO (`-fprofile-generate -mllvm -disable-vp -mllvm -debug-info-correlate`)
  * `.text`: 93.0 Mi
  * `__llvm_prf_cnts`: 14.5 Mi
  * Total: 175 Mi
* Minimal Block Coverage (`-fprofile-generate -mllvm -disable-vp -mllvm -debug-info-correlate -mllvm -pgo-block-coverage`)
  * `.text`: 82.1 Mi
  * `__llvm_prf_cnts`: 1.38 Mi
  * Total: 139 Mi

Reviewed By: spupyrev, kyulee

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

15 months ago[Debuginfod][CMake] Don't build a defunct llvm-debuginfod
Daniel Thornburgh [Wed, 29 Mar 2023 21:08:37 +0000 (14:08 -0700)]
[Debuginfod][CMake] Don't build a defunct llvm-debuginfod

llvm-debuginfod intrinsically requires cpp-httplib to operate, so
exclude the target if it's unavailable. Right now the tool walks off an
llvm_unreachable.

Reviewed By: phosek

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

15 months ago[libc] Add LIBC_INLINE macro to RPC implementation
Joseph Huber [Wed, 29 Mar 2023 20:24:58 +0000 (15:24 -0500)]
[libc] Add LIBC_INLINE macro to RPC implementation

These were required by the llvmlibc linter.

Reviewed By: sivachandra

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

15 months ago[RISCV] Add helper function for RVV intrinsics in getTgtMemIntrinsic. NFC
Craig Topper [Wed, 29 Mar 2023 22:34:25 +0000 (15:34 -0700)]
[RISCV] Add helper function for RVV intrinsics in getTgtMemIntrinsic. NFC

Preparation for adding the other RVV load/store intrinsics we use
for the C API.

Reviewed By: asb, kito-cheng

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

15 months agoFix https://lab.llvm.org/buildbot/#/builders/77/builds/26020. D147092
Leonard Chan [Wed, 29 Mar 2023 22:28:44 +0000 (22:28 +0000)]
Fix https://lab.llvm.org/buildbot/#/builders/77/builds/26020. D147092
broke this build since I forgot to wrap the moved struct in the
`__sanitizer` namespace so uptr wasn't refering to __sanitizer::uptr.

15 months ago[gn build] Port 4c10a6122edf
LLVM GN Syncbot [Wed, 29 Mar 2023 22:16:57 +0000 (22:16 +0000)]
[gn build] Port 4c10a6122edf

15 months ago[RISCV] Move allWUsers from RISCVInstrInfo to RISCVOptWInstrs.
Craig Topper [Wed, 29 Mar 2023 22:09:51 +0000 (15:09 -0700)]
[RISCV] Move allWUsers from RISCVInstrInfo to RISCVOptWInstrs.

It was only in RISCVInstrInfo because it was used by 2 passes, but those
passes have been merged in D147173.

Reviewed By: asb

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

15 months ago[RISCV] Merge SExtWRemoval and StripWSuffix into a single pass.
Craig Topper [Wed, 29 Mar 2023 21:59:20 +0000 (14:59 -0700)]
[RISCV] Merge SExtWRemoval and StripWSuffix into a single pass.

These run together in the pipeline and are the only users of
TII.hasAllWUsers. Merging them will allow us to move hasAllWUsers
back from TII.

Reviewed By: asb

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

15 months ago[lldb] Unify target triples across compiler and linker invocations
Jonas Devlieghere [Wed, 29 Mar 2023 21:53:58 +0000 (14:53 -0700)]
[lldb] Unify target triples across compiler and linker invocations

rdar://107364766

15 months ago[libc++] Add minor test for polymorphic_allocator.construct with mixed argument pair
Louis Dionne [Wed, 29 Mar 2023 21:01:18 +0000 (17:01 -0400)]
[libc++] Add minor test for polymorphic_allocator.construct with mixed argument pair

15 months agoDWARF: Enable "ranges always" under Split DWARF by default
David Blaikie [Wed, 29 Mar 2023 19:57:09 +0000 (19:57 +0000)]
DWARF: Enable "ranges always" under Split DWARF by default

Given the intent of Split DWARF is to minimize .o file size it seems
like adequate signal that it's worth a minor tradeoff in .dwo size to
significantly reduce .o size (though it doesn't reduce linked executable
size - the cost is mostly in the static relocations resolved by the
linker).

15 months agoDwarfDebug: Minor condition cleanups
David Blaikie [Wed, 29 Mar 2023 19:55:45 +0000 (19:55 +0000)]
DwarfDebug: Minor condition cleanups

Sink/share a few common conditions.

15 months ago[WebAssembly] Fix SmallVector warning
Heejin Ahn [Wed, 29 Mar 2023 20:33:36 +0000 (13:33 -0700)]
[WebAssembly] Fix SmallVector warning

Fixes a build warning caused by D146744.

15 months ago[clang-format] JSON Add ability to add a space before the colon
mydeveloperday [Wed, 29 Mar 2023 20:28:40 +0000 (21:28 +0100)]
[clang-format] JSON Add ability to add a space before the colon

I've seen a couple of request for extra Json formatting to match prettier capability.

Reviewed By: owenpan

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

15 months ago[clang-format] NFC ensure Style operator== remains sorted for ease of editing
mydeveloperday [Wed, 29 Mar 2023 20:24:37 +0000 (21:24 +0100)]
[clang-format] NFC ensure Style operator== remains sorted for ease of editing

{D144170} didn't go via the normal clang-format reviewers and we'd have pointed out that this list of options remains sorted.

Reviewed By: owenpan

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

15 months ago[include-cleaner] Visit the VarDecl in ASTWalker.
Haojian Wu [Wed, 29 Mar 2023 10:46:14 +0000 (12:46 +0200)]
[include-cleaner] Visit the VarDecl in ASTWalker.

Fixes https://github.com/clangd/clangd/issues/1554

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

15 months ago[Sema] Stop stripping CV quals from *this captures in lambdas
Roy Jacobson [Tue, 14 Mar 2023 19:25:54 +0000 (21:25 +0200)]
[Sema] Stop stripping CV quals from *this captures in lambdas

It appears we've been incorrectly stripping CV qualifiers when capturing `this` by value inside lambdas.
This patch simply removes the CV stripping code as discussed.

Closes https://github.com/llvm/llvm-project/issues/50866

Reviewed By: #clang-language-wg, cor3ntin, aaron.ballman

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

15 months ago[libc] fix strtointeger behavior on max values
Michael Jones [Wed, 29 Mar 2023 17:42:23 +0000 (10:42 -0700)]
[libc] fix strtointeger behavior on max values

Previously the check to just return MAX or MIN used the caclulated
number being the maximum absolute value. This was right in every case
except for an unsigned conversion being passed its maximum value with a
negative sign on the front. This should return -MAX, but was returning
just MAX.

Reviewed By: lntue

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

15 months ago[RISCV] Support emulated TLS
Vitaly Cheptsov [Wed, 29 Mar 2023 19:55:51 +0000 (20:55 +0100)]
[RISCV] Support emulated TLS

As discussed earlier in the [GitHub
issue](https://github.com/llvm/llvm-project/issues/59500), currently
LLVM generates invalid code when emulated TLS is used. There were
attempts to resolve this previously (D102527), but they were not merged
because the component owners raised concerns about emulated TLS
efficiency.

The current state of the art is that:

- OpenBSD team, which raised the initial issue, simply has [patches
  downstream](https://github.com/openbsd/src/blob/a0747c9/gnu/llvm/llvm/lib/Target/RISCV/RISCVISelLowering.cpp#L2850-L2852).
- Our team, which raised the GH issue, has patches downstream as well.
  We also do not use `malloc` or any [dynamic
allocations](https://github.com/llvm/llvm-project/issues/59500#issuecomment-1349046835)
with emulated TLS, so the concerns raised in the original issue does not
apply to us.
- GCC compatibility is broken, because GCC supports emulated TLS.
- RISC-V is the only architecture in LLVM that does not support emulated
  TLS, and work is being done to at least warn the users about it
(D143619).

With all these in mind I believe it is important to address the
consumers' needs especially given that there is little to no maintenance
downsides.

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

15 months ago[mlir][Vector] Add canonicalization pattern for vector.transpose(vector.constant_mask)
Diego Caballero [Wed, 29 Mar 2023 19:20:22 +0000 (19:20 +0000)]
[mlir][Vector] Add canonicalization pattern for vector.transpose(vector.constant_mask)

We already had vector.transpose(vector.create_mask) ->
vector.create_mask. This patch adds the constant mask version of it.

Reviewed By: nicolasvasilache

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

15 months ago[mlir][Vector] Add mapIterationSpaceDimToAllOperandDims to Linalg interface
Diego Caballero [Wed, 29 Mar 2023 19:09:41 +0000 (19:09 +0000)]
[mlir][Vector] Add mapIterationSpaceDimToAllOperandDims to Linalg interface

This is a variant of the existing `mapIterationSpaceDimToOperandDim`.
We have a local use downstream.

Reviewed By: nicolasvasilache

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

15 months ago[mlir][Vector] Enable masked vectorization of linalg.fill
Diego Caballero [Wed, 29 Mar 2023 19:19:24 +0000 (19:19 +0000)]
[mlir][Vector] Enable masked vectorization of linalg.fill

linalg.fill was already vectorizable with masks but not supported in the
dynamic pre-checks.

Reviewed By: nicolasvasilache

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

15 months ago[mlir][Vector] Remove lhs and rhs masks from vector.contract
Diego Caballero [Wed, 29 Mar 2023 19:16:12 +0000 (19:16 +0000)]
[mlir][Vector] Remove lhs and rhs masks from vector.contract

This patch removes the historical lhs and rhs masks in vector.contract,
now that vector.mask supports vector.contract and the lhs and rhs masks
are barely supported by all the vector.contract lowerings and
transformations.

Reviewed By: nicolasvasilache

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

15 months ago[WebAssembly] Do nothing when sinking to same place
Heejin Ahn [Fri, 24 Mar 2023 18:49:08 +0000 (11:49 -0700)]
[WebAssembly] Do nothing when sinking to same place

In `DebugValueManager`, if a `Def` is requested to be sunk to the same
place (i.e., `Insert` is right after `Def`, not counting `DBG_VALUE`s)
currently we still do the sink. This can result in unnecessary creation
of `DBG_VALUE $noreg`. See comments for details. This CL detects this
case and do nothing and return, so we don't end up creating unnecessary
undef `DBG_VALUE`s.

Reviewed By: dschuff

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

15 months ago[WebAssembly] Redesign DebugValueManager
Heejin Ahn [Wed, 30 Nov 2022 23:37:08 +0000 (15:37 -0800)]
[WebAssembly] Redesign DebugValueManager

The current `DebugValueManager`, which is mostly used in `RegStackify`,
simply sinks `DBG_VALUE`s along when a def instruction sinks.
(`RegStackify` only does sinks; it doesn't do hoists.)

But this simple strategy can result in incorrect combinations of
variables' values which would have not been possible in the original
program. In this case, LLVM's policy is to make the value unavailable,
so they will be shown as 'optimized out', rather than showing inaccurate
debug info. Especially, when an instruction sinks, its original
`DBG_VALUE` should be set to undef. This is well illustrated in the
third example in
https://llvm.org/docs/SourceLevelDebugging.html#instruction-scheduling.

This CL rewrites `DebugValueManager` with this principle in mind. When
sinking an instruction, it sinks its eligible `DBG_VALUE`s with it, but
also leaves undef `DBG_VALUE`s in the original place to make those
variables' values undefined.

Also, unlike the current version, we sink only an eligible subset of
`DBG_VALUE`s with a def instruction. See comments in the code for
details.

In case of cloning, because the original def is still there, we don't
set its `DBG_VALUE`s to undef. But we clone only an eligible subset of
`DBG_VALUE`s here as well.

One consequence of this change is that now we do sinking and cloning of
the def instruction itself within the `DebugValueManager`'s `sink` and
`clone` methods. This is necessary because the `DebugValueManager` needs
to know the original def's location before sinking and cloning in order
to scan other interfering `DBG_VALUE`s between the original def and the
insertion point. If we want to separate these two, we need to call
`DebugValueManager`'s `sink` and `clone` methods //before//
sinking/cloning the def instruction, which I don't think is a good
design alternative either, because the user of this class needs to pay
extra attention when using it.

Because this change is fixing the existing inaccuracy of the current
debug info, this reduces the variable info coverage in debug info, but
not by a large margin. In Emscripten core benchmarks compiled with
`-O1`, the coverage goes from 56.6% down to 55.2%, which I doubt will be
a noticeable drop. The compilation time doesn't have any meaningful
difference either with this change.

Reviewed By: dschuff

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

15 months ago[libc] Re-enable wctob with fixes
Michael Jones [Tue, 21 Mar 2023 18:12:05 +0000 (11:12 -0700)]
[libc] Re-enable wctob with fixes

The stdio test failures were due to headers potentially not being built
in the correct order. This should set up the dependencies correctly.

Reviewed By: sivachandra

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

15 months ago[WebAssembly] Use ArrayRef/SmallVectorImpl in parameters (NFC)
Heejin Ahn [Fri, 24 Mar 2023 19:09:22 +0000 (12:09 -0700)]
[WebAssembly] Use ArrayRef/SmallVectorImpl in parameters (NFC)

It is recommended to use `SmallVectorImpl`/`ArrayRef` over
`SmallVector<TypeName, N>` for function parameters:
https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h

Reviewed By: dschuff

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

15 months ago[WebAssembly] Select call_indirect for alloca calls
Heejin Ahn [Tue, 28 Mar 2023 08:01:21 +0000 (01:01 -0700)]
[WebAssembly] Select call_indirect for alloca calls

Currently calling stack locations is selected using `CALL` in ISel,
resulting in an invalid code and crashing in AsmPrinter. FastISel
correctly selects it will `CALL_INDIRECT`.

Fixes the problem reported in D146781.

Reviewed By: tlively, HerrCai0907

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

15 months ago[AMDGPU] Do not fix implicit vcc operand on INLINEASM
Jay Foad [Wed, 29 Mar 2023 14:06:53 +0000 (15:06 +0100)]
[AMDGPU] Do not fix implicit vcc operand on INLINEASM

An INLINEASM can have an implicit def of vcc. It is not appropriate for
fixImplicitOperands to change this to vcc_lo on wave32.

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

15 months ago[AMDGPU] Consistently use v2i16 for packed bf16 inputs. NFC.
Jay Foad [Wed, 29 Mar 2023 12:10:19 +0000 (13:10 +0100)]
[AMDGPU] Consistently use v2i16 for packed bf16 inputs. NFC.

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

15 months ago[libc] Use LTO for AMDGPU compilation and linking
Joseph Huber [Wed, 29 Mar 2023 19:19:08 +0000 (14:19 -0500)]
[libc] Use LTO for AMDGPU compilation and linking

Summary:
The AMDGPU ABI isn't stable or well defined. For that reson we prefer to
rely on LTO to ensure that multiple files get linked correctly.
Currently the internal targets used for testing mix LLVM-IR and
assembly. We should be consistent here.

15 months agoMark test added in D141824 as unsupported for PS4/PS5 as those platforms require...
Douglas Yung [Wed, 29 Mar 2023 19:09:28 +0000 (12:09 -0700)]
Mark test added in D141824 as unsupported for PS4/PS5 as those platforms require an external linker that is not present.

15 months ago[clang-format] NFC ensure clang-format is itself clang-formatted
mydeveloperday [Wed, 29 Mar 2023 19:01:03 +0000 (20:01 +0100)]
[clang-format] NFC ensure clang-format is itself clang-formatted

Some patch in the past introduce this non clang-formatted change

15 months ago[gn build] Port 3be6c4d413f6
LLVM GN Syncbot [Wed, 29 Mar 2023 18:50:19 +0000 (18:50 +0000)]
[gn build] Port 3be6c4d413f6

15 months ago[Flang][OpenMP] Update test case to track an issue
Kavitha Natarajan [Wed, 29 Mar 2023 18:40:16 +0000 (00:10 +0530)]
[Flang][OpenMP] Update test case to track an issue

Adding CHECK-NOT for the MAX intrinsic implementation for which
reduction operation is not generated. Issue #61808 created to
track the same.

15 months ago[MLIR] NFC. Expose/move MDG out of Affine fusion into Affine Analysis
Uday Bondhugula [Wed, 29 Mar 2023 18:27:13 +0000 (23:57 +0530)]
[MLIR] NFC. Expose/move MDG out of Affine fusion into Affine Analysis

Move out MemRefDependenceGraph analysis structure out of LoopFusion into
the Affine Analysis library. This had been a long pending TODO. Moving
MDG out allows its use in other affine passes as well as allows building
custom affine fusion passes downstream while reusing upstream fusion
utilties. The file LoopFusion.cpp had also become lengthy and this
change makes things more modular. This change is a pure NFC and is a
code movement.

NFC.

Reviewed By: springerm

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

15 months agoMake all additions matter in private mapping test.
Doru Bercea [Wed, 29 Mar 2023 16:34:03 +0000 (12:34 -0400)]
Make all additions matter in private mapping test.

15 months agoRevert "Revert "Revert ExtractAPI from https://reviews.llvm.org/D146656""
Mitch Phillips [Wed, 29 Mar 2023 18:36:44 +0000 (11:36 -0700)]
Revert "Revert "Revert ExtractAPI from https://reviews.llvm.org/D146656""

This reverts commit 79116475124112051625b1a0665e35c861bb13fd.

Broke the ASan bots. See more information in
https://reviews.llvm.org/rG79116475124112051625b1a0665e35c861bb13fd

15 months agoRevert "[clang][ExtractAPI] Add queried symbol to parent contexts in libclang"
Mitch Phillips [Wed, 29 Mar 2023 18:35:59 +0000 (11:35 -0700)]
Revert "[clang][ExtractAPI] Add queried symbol to parent contexts in libclang"

This reverts commit 1cfe1e732ad8e8148f6fa8fc0f0c86f4b965d567.

Depends on reverted commit 158a431227a876306fe5838936413dd51588d0c6. See
https://reviews.llvm.org/rG79116475124112051625b1a0665e35c861bb13fd for
more information, this broke the ASan bots.

15 months ago[MSCV][dllexport/dllimport][PS] Allow UniqueExternal linkage classes with dllexport...
Wolfgang Pieb [Mon, 13 Mar 2023 17:45:20 +0000 (17:45 +0000)]
[MSCV][dllexport/dllimport][PS] Allow UniqueExternal linkage classes with dllexport/dllimport

MSVC allows instantiations of exported or imported template classes with template
parameters that have internal linkage. Clang now allows it in Microsoft mode and for
the Playstation platform. This partially addresses issue 56068.

Note that MSVC also allows explicit dllexport/dllimport attributes on classes
with internal linkage (e.g. local classes or classes declared in anonymous name spaces).
Clang continues to reject such declarations.

Reviewed By: hans

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

15 months ago[Flang][OpenMP] Fix crash in MAX intrinsic reduction
Kavitha Natarajan [Wed, 29 Mar 2023 15:35:42 +0000 (21:05 +0530)]
[Flang][OpenMP] Fix crash in MAX intrinsic reduction

This patch fixes a crash that appear in an OpenMP MAX intrinsic
reduction when the reduction is not expressed using MAX intrinsic
function. Updated flang/test/Lower/OpenMP/wsloop-reduction-max.f90
test case with additional way of expressing MAX reduction.

Reviewed By: kiranchandramohan

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

15 months ago[OpenMP][MLIR] Add Flags attribute to OMP OffloadModuleInterface
Andrew Gozillon [Wed, 29 Mar 2023 15:45:59 +0000 (10:45 -0500)]
[OpenMP][MLIR] Add Flags attribute to OMP OffloadModuleInterface

The intent of this attribute is for it to be applied to a module and
then hold information on runtime library (RTL) flags given to
Flang (or other OpenMP frontend) that should be lowered down to
LLVM-IR for devices as LLVM globals. The following related
flags are:

-fopenmp-target-debug
-fopenmp-assume-threads-oversubscription
-fopenmp-assume-teams-oversubscription
-fopenmp-assume-no-nested-parallelism
-fopenmp-assume-no-thread-state

These exist within Clang and are lowered into the IR when
offloading for device. This attribute allows this infromation
to be carried down from the Flang frontend to the
LLVM/OpenMP Dialect to LLVM-IR translation phase
and then be lowered to LLVM-IR.

Reviewers: kiranchandramohan

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

15 months ago[Flang][Driver][OpenMP] Fix omp-frontend-forwarding.f90 failure on windows
Andrew Gozillon [Wed, 29 Mar 2023 15:37:18 +0000 (10:37 -0500)]
[Flang][Driver][OpenMP] Fix omp-frontend-forwarding.f90 failure on windows

Failing due to forgetting the .exe suffix the clang-offload-packager
receives on windows.

15 months ago[RISCV] Made v(f)(w)red* pseudoinstructions SEW-aware
Nitin John Raj [Wed, 29 Mar 2023 00:46:16 +0000 (17:46 -0700)]
[RISCV] Made v(f)(w)red* pseudoinstructions SEW-aware

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

15 months agoReland "[hwasan] Provide aliases for c allocation functions for Fuchsia
Leonard Chan [Wed, 29 Mar 2023 17:34:16 +0000 (17:34 +0000)]
Reland "[hwasan] Provide aliases for c allocation functions for Fuchsia

This reverts commit 3b4cb1e96c645bb833fe710856479c31383859bb.

Reland D145718 but unconditionally define __sanitizer_mallinfo which is
exposed as part of the hwasan interface.

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

15 months ago[compiler-rt] Move __sanitizer_mallinfo to separate header
Leonard Chan [Wed, 29 Mar 2023 17:08:22 +0000 (17:08 +0000)]
[compiler-rt] Move __sanitizer_mallinfo to separate header

mallinfo is platform-specific and not specified by either posix or the C
standard, but the hwasan interface unconditionally exposes
__sanitizer_mallinfo which returns a struct __sanitizer_struct_mallinfo
which is defined in sanitizer_platform_limits_posix.h, so this should
also be available for fuchsia to provide __sanitizer_mallinfo. Fuchsia
doesn't need the rest of what's in sanitizer_platform_limits_posix.h so
we can just move it to its own header.

Exposing this and not forcing it to hide behind
SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO fixes the test failures found
after landing D145718.

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

15 months ago[mlir][arith] Fold `index_cast[ui]` of vectors
Jakub Kuderski [Wed, 29 Mar 2023 16:49:32 +0000 (12:49 -0400)]
[mlir][arith] Fold `index_cast[ui]` of vectors

Handle the splat and dense case.

I saw this pattern show up in a couple recent SPIR-V-specific bug
report.

Reviewed By: antiagainst

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

15 months ago[docs] Fix a typo (malicously-crafter)
Benjamin Kramer [Wed, 29 Mar 2023 16:49:04 +0000 (18:49 +0200)]
[docs] Fix a typo (malicously-crafter)

15 months ago[LV] Add test cases for global struct dereferencability.
Florian Hahn [Wed, 29 Mar 2023 16:47:41 +0000 (17:47 +0100)]
[LV] Add test cases for global struct dereferencability.

Currently LLVM fails to determine that conditional loads in
@accesses_to_struct_dereferenceable are dereferenceable unconditionally.

15 months agoFix ArgsAsWritten being null for ConceptSpecializationExpr in certain
Walter Gray [Wed, 29 Mar 2023 16:27:07 +0000 (09:27 -0700)]
Fix ArgsAsWritten being null for ConceptSpecializationExpr in certain
circumstances when parsing ASTs

Fix ArgsAsWritten being null for ConceptSpecializationExpr in certain
circumstances when parsing ASTs

ASTStmtWriter::VisitConceptSpecializationExpr specifically expects
getTemplateArgsAsWritten() to return true, which it wasn't when parsed
by ASTContext.cpp in certain edge cases.

Fixes: #61486

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

15 months ago[PS4][clang] Limit ThinLTO parallelism when requested
Matthew Voss [Wed, 29 Mar 2023 16:36:46 +0000 (09:36 -0700)]
[PS4][clang] Limit ThinLTO parallelism when requested

Pass the correct option to the linker when "-flto-jobs=" is passed to
the driver.

15 months ago[NFC] Fix uninitalized member variable use in ASTReader::ParseTargetOptions()
Sindhu Chittireddy [Wed, 22 Mar 2023 03:38:45 +0000 (20:38 -0700)]
[NFC] Fix uninitalized member variable use in ASTReader::ParseTargetOptions()

15 months ago[Flang][OpenMP] Issue error for assumed-size array in Map clause
Kiran Chandramohan [Wed, 29 Mar 2023 16:07:23 +0000 (16:07 +0000)]
[Flang][OpenMP] Issue error for assumed-size array in Map clause

Error only applies if it is a whole array. Page 157 in OpenMP 5.2
standard.

Reviewed By: TIFitis

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

15 months ago[mlir][spirv] Fix null pointer dereference in `--test-spirv-target-env`
Jakub Kuderski [Wed, 29 Mar 2023 16:08:21 +0000 (12:08 -0400)]
[mlir][spirv] Fix null pointer dereference in `--test-spirv-target-env`

Fixes: https://github.com/llvm/llvm-project/issues/61710

Reviewed By: antiagainst

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

15 months ago[clang-tidy] Fix if-constexpr false-positive in readability-misleading-indentation
Piotr Zegar [Wed, 29 Mar 2023 15:24:54 +0000 (15:24 +0000)]
[clang-tidy] Fix if-constexpr false-positive in readability-misleading-indentation

When  depend on template parameter,
compiler can use NullStmt instead of CompoundStmt.
This causes issues as we losing information about
end location of that Stmt. To avoid this issue
check now ignores ifStmt with NullStmt on true-branch.

Fixes: https://github.com/llvm/llvm-project/issues/61435

Reviewed By: carlosgalvezp

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

15 months agoRevert "[compiler-rt] Quote multiple warning flags in check_cxx_compiler_flag invocation"
Mitch Phillips [Wed, 29 Mar 2023 16:06:17 +0000 (09:06 -0700)]
Revert "[compiler-rt] Quote multiple warning flags in check_cxx_compiler_flag invocation"

This reverts commit e4918d43763e8bdcdf9ad27f4eb536bf9aa4e3cf.

Reason: Broke the sanitizer bots. More information in
https://reviews.llvm.org/D146920 and should be re-landed with
https://reviews.llvm.org/D147164 (or similar)

15 months ago[MLIR][OpenMP] Change map_operands type to OpenMP_PointerLikeType for Target Data
Akash Banerjee [Tue, 28 Mar 2023 13:54:18 +0000 (14:54 +0100)]
[MLIR][OpenMP] Change map_operands type to OpenMP_PointerLikeType for Target Data

This patches chagnes the type of map_operands to OpenMP_PointerLikeType for OMP Target Data directives.

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

15 months agoProperly Propagate RecoveryExpr through RequiresExpr
Erich Keane [Wed, 29 Mar 2023 15:54:40 +0000 (08:54 -0700)]
Properly Propagate RecoveryExpr through RequiresExpr

Commit 3d7946c58 implemented a DR that allowed us to error in a case
where an ill-formedness in a RequiresExpr is diagnosed as a satisfaction
failure.  However, it failed to cover cases where the RequiresExpr had
Requirements that failed for similar reasons.

This patch propagates the RecoveryExpr "containsErrors" correctly
through RequiresExpr.

Fixes: #61776

15 months agoRevert "[mlir-cpu-runner] Add export_executable_symbols in CMake."
Mitch Phillips [Wed, 29 Mar 2023 15:49:04 +0000 (08:49 -0700)]
Revert "[mlir-cpu-runner] Add export_executable_symbols in CMake."

This reverts commit ccdcfad0815296d8952438632d9abe6bc0a5258a.

Reason: Introduced an ODR that broke the ASan bots. See more information
in Phabricator: https://reviews.llvm.org/D146935

15 months ago[IPO] Add documentation for new function argument
Shoaib Meenai [Wed, 29 Mar 2023 10:26:47 +0000 (03:26 -0700)]
[IPO] Add documentation for new function argument

As pointed out by @fhahn in https://reviews.llvm.org/D146876.

Reviewed By: tejohnson

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

15 months ago[clang][ExtractAPI] Add queried symbol to parent contexts in libclang
Daniel Grumberg [Wed, 29 Mar 2023 11:04:30 +0000 (12:04 +0100)]
[clang][ExtractAPI] Add queried symbol to parent contexts in libclang

Ensure that the current symbol is added to the parent contexts in the
output of libclang function for generating symbol graphs for single symbols.

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

15 months ago[symbolizer] Factor out conversion DILineInfo->JSON. NFC
Serge Pavlov [Wed, 29 Mar 2023 05:11:12 +0000 (12:11 +0700)]
[symbolizer] Factor out conversion DILineInfo->JSON. NFC

Move the conversion of DILineInfo to JSON into a separate function, so
it can be used in other places too.

This is a prerequisite patch for implementation of symbol+offset lookup.

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

15 months ago[symbolizer] Treat invalid address as addr2line does
Serge Pavlov [Tue, 28 Mar 2023 17:44:55 +0000 (00:44 +0700)]
[symbolizer] Treat invalid address as addr2line does

llvm-symbolizer echoed input if it was not recognized as a valid address.
This behavior was extended to llvm-addr2line as well. GNU addr2line in
this case optputs "??:0". This difference prevents implementation of
symbol+offset lookup available in the recent versions of GNU binutils.
In that case a string that is not an address may be a symbol.

This change make reaction of llvm-addr2line on unrecognized input closer
to GNU addr2line.

15 months ago[AIX][PGO] Teach profile runtime to read build-id
Wael Yehia [Mon, 20 Mar 2023 19:51:17 +0000 (15:51 -0400)]
[AIX][PGO] Teach profile runtime to read build-id

On AIX, the build-id can be embedded in a binary using the -mxcoff-build-id
compiler option. When present, the build id is stored as an ascii string at the
beginning of the string table in the loader section of the XCOFF file.

Reviewed By: stephenpeckham, daltenty

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

15 months ago[Assignment Tracking] Coalesce dbg loc definitions with contiguous fragments
OCHyams [Wed, 29 Mar 2023 14:27:29 +0000 (15:27 +0100)]
[Assignment Tracking] Coalesce dbg loc definitions with contiguous fragments

MemLocFragmentFill uses an IntervalMap to track which bits of each variable are
stack-homed. Intervals with the same value (same stack location base address)
are automatically coalesced by the map. This patch changes the analysis to take
advantage of that and insert a new dbg loc after each def if any coalescing
took place. This results in some additional redundant defs (we insert a def,
then another that by definition shadows the previous one if any coalescing took
place) but they're all cleaned up thanks to the previous patch in this stack.

This reduces the total number of fragments created by
AssignmentTrackingAnalysis which reduces compile time because LiveDebugValues
computes SSA for every fragment it encounters. There's a geomean reduction in
instructions retired in a CTMark LTO-O3-g build of 0.3% with these two patches.

One small caveat is that this technique can produce partially overlapping
fragments (e.g. slice [0, 32) and slice [16, 64)), which we know
LiveDebugVariables doesn't really handle correctly. Used in combination with
instruction-referencing this isn't a problem, since LiveDebugVariables is
effectively side-stepped in instruction-referencing mode. Given this, the
coalescing is only enabled when instruction-referencing is enabled (but the
behaviour can be overriden using -debug-ata-coalesce-frags=<bool>).

Reviewed By: jmorse

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