platform/upstream/llvm.git
2 years ago[AArch64] Select to CCMN when the CCMP's second operator is negative constant
chenglin.bi [Fri, 14 Oct 2022 13:40:55 +0000 (21:40 +0800)]
[AArch64] Select to CCMN when the CCMP's second operator is negative constant

CCMP/CCMN's second operator support const from 0 to 31. When the CCMP's second operator is in the range [-31, -1] we can replace it with CCMN to avoid extra mov.

Fix: #57034

Reviewed By: efriedma

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

2 years agoRevert "[libc] New version of the mem* framework"
Guillaume Chatelet [Fri, 14 Oct 2022 13:21:52 +0000 (13:21 +0000)]
Revert "[libc] New version of the mem* framework"

This reverts commit 9721687835a7df5da0c9482cf684c11b8ba97f75.

2 years agoRevert "[libc] Fix embedded version of bcmp / memcmp"
Guillaume Chatelet [Fri, 14 Oct 2022 13:21:19 +0000 (13:21 +0000)]
Revert "[libc] Fix embedded version of bcmp / memcmp"

This reverts commit 7c9b8fa6d2d921569a1ebeb4816edb7b05a37cdd.

2 years ago[libc] Fix embedded version of bcmp / memcmp
Guillaume Chatelet [Fri, 14 Oct 2022 13:09:28 +0000 (13:09 +0000)]
[libc] Fix embedded version of bcmp / memcmp

2 years ago[lld/ELF] Convert undef-spell-corrector.s test to split-file
Nico Weber [Thu, 13 Oct 2022 14:55:24 +0000 (10:55 -0400)]
[lld/ELF] Convert undef-spell-corrector.s test to split-file

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

2 years agoFix the ExtractAPI tests
Aaron Ballman [Fri, 14 Oct 2022 12:57:01 +0000 (08:57 -0400)]
Fix the ExtractAPI tests

This should address the issues found by:
https://lab.llvm.org/buildbot/#/builders/139/builds/29568
https://lab.llvm.org/buildbot/#/builders/109/builds/48658

2 years agoAdd f16 type support in math.erf op.
Prashant Kumar [Wed, 12 Oct 2022 12:41:16 +0000 (12:41 +0000)]
Add f16 type support in math.erf op.

f16 type support was missing in the math.erf op.

Reviewed By: ezhulenev

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

2 years ago[libc] New version of the mem* framework
Guillaume Chatelet [Fri, 14 Oct 2022 12:42:34 +0000 (12:42 +0000)]
[libc] New version of the mem* framework

This version is more composable and also simpler at the expense of being more explicit and more verbose. It also provides minimal implementations for ARM platforms.

Codegen can be checked here https://godbolt.org/z/x19zvE59v

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

2 years ago[clang][Interp] Implement while and do-while loops
Timm Bäder [Fri, 7 Oct 2022 09:37:12 +0000 (11:37 +0200)]
[clang][Interp] Implement while and do-while loops

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

2 years ago[clang][Interp][NFC] Remove unused parameter from emitConst()
Timm Bäder [Fri, 7 Oct 2022 06:12:05 +0000 (08:12 +0200)]
[clang][Interp][NFC] Remove unused parameter from emitConst()

2 years ago[clang][Interp][NFC] Add some tests for invalid array access
Timm Bäder [Mon, 10 Oct 2022 10:58:47 +0000 (12:58 +0200)]
[clang][Interp][NFC] Add some tests for invalid array access

2 years agoSpeculatively fix the lldb test bots
Aaron Ballman [Fri, 14 Oct 2022 12:36:04 +0000 (08:36 -0400)]
Speculatively fix the lldb test bots

This should fix the issue found by:
https://lab.llvm.org/buildbot/#/builders/68/builds/41100

2 years agoRevert "[libc] New version of the mem* framework"
Guillaume Chatelet [Fri, 14 Oct 2022 12:26:38 +0000 (12:26 +0000)]
Revert "[libc] New version of the mem* framework"

This reverts commit 98bf836f3127a346a81da5ae3e27246935298de4.

2 years ago[mlir][llvm] Use tablegen to import atomic ops from LLVM IR.
Tobias Gysi [Fri, 14 Oct 2022 12:00:44 +0000 (15:00 +0300)]
[mlir][llvm] Use tablegen to import atomic ops from LLVM IR.

The revision imports the atomic operations using
tablegen generated builders. Additionally, it moves their tests to
the instructions.ll test file.

Depends on D135880

Reviewed By: ftynse

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

2 years ago[libc] New version of the mem* framework
Guillaume Chatelet [Thu, 13 Oct 2022 14:59:41 +0000 (14:59 +0000)]
[libc] New version of the mem* framework

This version is more composable and also simpler at the expense of being more explicit and more verbose. It also provides minimal implementations for ARM platforms.

Codegen can be checked here https://godbolt.org/z/x19zvE59v

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

2 years agoProperly print unnamed TagDecl objects in diagnostics
Aaron Ballman [Fri, 14 Oct 2022 12:17:16 +0000 (08:17 -0400)]
Properly print unnamed TagDecl objects in diagnostics

The diagnostics engine is very smart about being passed a NamedDecl to
print as part of a diagnostic; it gets the "right" form of the name,
quotes it properly, etc. However, the result of using an unnamed tag
declaration was to print '' instead of anything useful.

This patch causes us to print the same information we'd have gotten if
we had printed the type of the declaration rather than the name of it,
as that's the most relevant information we can display.

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

2 years ago[clang][Interp] Implement bitwise Or operations
Timm Bäder [Thu, 6 Oct 2022 13:13:11 +0000 (15:13 +0200)]
[clang][Interp] Implement bitwise Or operations

Analogous to the bitAnd implementation, do the same for bitwise or.

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

2 years ago[clang][Interp] Implement bitwise and operations
Timm Bäder [Fri, 30 Sep 2022 14:59:50 +0000 (16:59 +0200)]
[clang][Interp] Implement bitwise and operations

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

2 years ago[mlir][llvm] Use tablegen to import shufflevector from LLVM IR.
Tobias Gysi [Fri, 14 Oct 2022 11:45:32 +0000 (14:45 +0300)]
[mlir][llvm] Use tablegen to import shufflevector from LLVM IR.

The revision imports the shuffle vector operation using
tablegen generated builders. Additionally, it moves its test to
the instructions.ll test file.

Depends on D135874

Reviewed By: ftynse

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

2 years ago[clang][Interp][NFC] Remove an unnecessary local variable
Timm Bäder [Wed, 5 Oct 2022 04:17:40 +0000 (06:17 +0200)]
[clang][Interp][NFC] Remove an unnecessary local variable

2 years ago[clang][Interp][NFC] Zero-initialize Function::FrameSize
Timm Bäder [Wed, 5 Oct 2022 04:11:57 +0000 (06:11 +0200)]
[clang][Interp][NFC] Zero-initialize Function::FrameSize

It's never going to be used since it's only uninitialized if the
function is invalid, but let's zero it for readbility of
Function::dump().

2 years ago[clang][Interp][NFC] Rename a parameter to be more descriptive
Timm Bäder [Tue, 4 Oct 2022 16:26:25 +0000 (18:26 +0200)]
[clang][Interp][NFC] Rename a parameter to be more descriptive

2 years ago[clang][Interp][NFC] Remove unused function
Timm Bäder [Tue, 4 Oct 2022 15:24:55 +0000 (17:24 +0200)]
[clang][Interp][NFC] Remove unused function

2 years ago[clang][Interp][NFC] Add a failing test case
Timm Bäder [Fri, 30 Sep 2022 10:04:28 +0000 (12:04 +0200)]
[clang][Interp][NFC] Add a failing test case

2 years ago[clang][Interp] Implement ConditionalOperators
Timm Bäder [Wed, 28 Sep 2022 04:51:17 +0000 (06:51 +0200)]
[clang][Interp] Implement ConditionalOperators

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

2 years ago[clang][Interp] Implement div opcode
Timm Bäder [Tue, 27 Sep 2022 16:17:52 +0000 (18:17 +0200)]
[clang][Interp] Implement div opcode

Implement an opcode for division of two integrals.

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

2 years ago[clang][Interp] Implement rem opcode
Timm Bäder [Tue, 27 Sep 2022 15:40:55 +0000 (17:40 +0200)]
[clang][Interp] Implement rem opcode

Implement an opcode to get the remainder of the divison between LHS and
RHS.

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

2 years ago[clang][Interp] Implement bitwise not operations
Timm Bäder [Wed, 28 Sep 2022 12:30:44 +0000 (14:30 +0200)]
[clang][Interp] Implement bitwise not operations

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

2 years ago[mlir][Linalg] Support multi-output fusion in FuseIntoContainingOp
Nicolas Vasilache [Fri, 30 Sep 2022 11:09:37 +0000 (04:09 -0700)]
[mlir][Linalg] Support multi-output fusion in FuseIntoContainingOp

This revision adds the ability to fuse tileable ops with multiple results to
the transform.fuse_into_containing_op.

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

2 years ago[clang][Interp][NFC] Simplify Integral using constexpr if
Timm Bäder [Tue, 27 Sep 2022 15:10:20 +0000 (17:10 +0200)]
[clang][Interp][NFC] Simplify Integral using constexpr if

Just keep one version of the function and differentiate between
std::is_signed() and unsigned using a constexpr if, instead of having
two different versions for the signed and unsigned cases.

2 years ago[clang][Interp][NFC] Use a SourceRange for errors
Timm Bäder [Tue, 27 Sep 2022 10:40:12 +0000 (12:40 +0200)]
[clang][Interp][NFC] Use a SourceRange for errors

This makes the error message generated by bail() a bit more pleasant to
read.

2 years ago[mlir][spirv] GPUToSPIRVPass: support case when `TargetEnv` attribute attached to...
Ivan Butygin [Thu, 13 Oct 2022 19:16:26 +0000 (21:16 +0200)]
[mlir][spirv] GPUToSPIRVPass: support case when `TargetEnv` attribute attached to the `gpu.module`

Previously, only case when `TargetEnv` was attached to the top level `ModuleOp` was supported.

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

2 years ago[clang][Interp] Fix Pointer::toAPValue() LValuePath order
Timm Bäder [Mon, 26 Sep 2022 06:44:09 +0000 (08:44 +0200)]
[clang][Interp] Fix Pointer::toAPValue() LValuePath order

2 years ago[clang][Interp][NFC] Pass Function* pointers around as const
Timm Bäder [Fri, 23 Sep 2022 13:15:09 +0000 (15:15 +0200)]
[clang][Interp][NFC] Pass Function* pointers around as const

2 years ago[ConstraintElim] Add debug message when decomposition fails.
Florian Hahn [Fri, 14 Oct 2022 10:01:53 +0000 (11:01 +0100)]
[ConstraintElim] Add debug message when decomposition fails.

2 years ago[clang][Interp] Fix copy constructors with record array members
Timm Bäder [Fri, 23 Sep 2022 09:29:33 +0000 (11:29 +0200)]
[clang][Interp] Fix copy constructors with record array members

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

2 years ago[clang][Interp][NFC] Explain why tests are disabled
Timm Bäder [Fri, 14 Oct 2022 09:44:23 +0000 (11:44 +0200)]
[clang][Interp][NFC] Explain why tests are disabled

Disabled to make the buildbots happy in
c004d7534dcefcfebc3e07a7fa12f5492be80279. In C++14, the functions here
use a MaterializeTemporaryExpr, which the new constant interpreter
doesn't support yet. Add comments for this and two new RUN lines.

2 years ago[clang][Interp][NFC] Run record tests on i686 as well
Timm Bäder [Fri, 14 Oct 2022 09:19:24 +0000 (11:19 +0200)]
[clang][Interp][NFC] Run record tests on i686 as well

So we have some test coverage on a 32bit arch.

2 years ago[clang][Interp] Classify ArrayInitIndexExpr type
Timm Bäder [Fri, 14 Oct 2022 09:08:57 +0000 (11:08 +0200)]
[clang][Interp] Classify ArrayInitIndexExpr type

We can't just push a uint64 unconditionally here, since on 32bit arches
we later expect a different type, e.g. uint32.

This broke e.g. these builders:
https://lab.llvm.org/buildbot#builders/171/builds/21514
https://lab.llvm.org/buildbot#builders/38/builds/6643

2 years ago[MemorySSA] Add test for select with cross-iteration dependency (NFC)
Nikita Popov [Fri, 14 Oct 2022 09:02:23 +0000 (11:02 +0200)]
[MemorySSA] Add test for select with cross-iteration dependency (NFC)

This is currently miscompiled.

2 years agoRevert "[AArch64] Fix aligning the stack after calling __chkstk"
Martin Storsjö [Fri, 14 Oct 2022 08:27:39 +0000 (11:27 +0300)]
Revert "[AArch64] Fix aligning the stack after calling __chkstk"

This reverts commit 50e0aced4521260af842dba73f1d8c50d36314ea.

This could accidentally start producing invalid code in some
cases (in particular, if compiling with -mstack-alignment=16, which
one could expect to be a no-op for a target where the stack always
is aligned to 16 bytes anyway).

2 years ago[clang][Interp] Disable some RVO tests
Timm Bäder [Fri, 14 Oct 2022 08:44:39 +0000 (10:44 +0200)]
[clang][Interp] Disable some RVO tests

Apparently this breaks a couple of builders:
https://lab.llvm.org/buildbot/#/builders/139/builds/29552
https://lab.llvm.org/buildbot/#/builders/216/builds/11240

2 years ago[Interp] Silence warning in release builds. NFC.
Benjamin Kramer [Fri, 14 Oct 2022 08:35:48 +0000 (10:35 +0200)]
[Interp] Silence warning in release builds. NFC.

2 years agoAdd missing `override`s after aad013de41c0
Benjamin Kramer [Fri, 14 Oct 2022 08:34:17 +0000 (10:34 +0200)]
Add missing `override`s after aad013de41c0

2 years ago[BasicAA] Account for cycles when checking for same select condition
Nikita Popov [Fri, 14 Oct 2022 08:35:36 +0000 (10:35 +0200)]
[BasicAA] Account for cycles when checking for same select condition

If we have translated across a cycle backedge, the same SSA value
for the condition might be referring to two different loop iterations.
Use the isValueEqualInPotentialCycles() helper to avoid assuming
equality in that case.

2 years ago[BasicAA] Add test for select with loop carried dependency (NFC)
Nikita Popov [Fri, 14 Oct 2022 08:31:44 +0000 (10:31 +0200)]
[BasicAA] Add test for select with loop carried dependency (NFC)

2 years ago[mlir] add missing markdown delimiters in SCFOps.td
Oleksandr "Alex" Zinenko [Fri, 14 Oct 2022 08:30:34 +0000 (10:30 +0200)]
[mlir] add missing markdown delimiters in SCFOps.td

2 years ago[clang][Interp] Fix using default copy constructors
Timm Bäder [Wed, 21 Sep 2022 14:05:30 +0000 (16:05 +0200)]
[clang][Interp] Fix using default copy constructors

Implement ArrayInitLoopExprs, which are used in copy constructors to
copy arrays. Also fix problems encountered while doing that.

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

2 years ago[clang][Interp] Implement nested struct initialization
Timm Bäder [Mon, 19 Sep 2022 11:16:47 +0000 (13:16 +0200)]
[clang][Interp] Implement nested struct initialization

Recurse into visitInitializer() if necessary.

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

2 years ago[clang][Interp] Implement This pointer passing to methods
Timm Bäder [Sun, 18 Sep 2022 18:40:27 +0000 (20:40 +0200)]
[clang][Interp] Implement This pointer passing to methods

Implement passing the this pointer to member functions and constructors.
The this pointer is passed via the stack. This changes the functions to
explicitly track whether they have a RVO pointer and a this pointer.

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

2 years ago[clang][Interp] Start implementing record types
Timm Bäder [Fri, 16 Sep 2022 17:11:58 +0000 (19:11 +0200)]
[clang][Interp] Start implementing record types

Implement simple constructors as well as member access expressions.

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

2 years ago[clang][Interp] Don't run functions immediately after compiling them
Timm Bäder [Mon, 10 Oct 2022 11:02:15 +0000 (13:02 +0200)]
[clang][Interp] Don't run functions immediately after compiling them

This doesn't make much sense with functions that expect valid parameters
and/or a certain call stack on the caller side like This/RVO pointers.

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

2 years ago[clang][Interp][NFC] Add more tests for if expressions
Timm Bäder [Fri, 7 Oct 2022 09:54:04 +0000 (11:54 +0200)]
[clang][Interp][NFC] Add more tests for if expressions

Rename the old if_consteval.cpp to just if.cpp and add tests for the
if declaration.

2 years ago[clang][Interp][NFC] Add a TODO comment
Timm Bäder [Fri, 7 Oct 2022 05:49:57 +0000 (07:49 +0200)]
[clang][Interp][NFC] Add a TODO comment

We can ignore casts where FromT and ToT are the same type. But that's a
performance optimization that I'd like to do later. For now, this code
is doing the right thing.

2 years ago[TBAA] Model call accessing immutable type as readnone
Nikita Popov [Thu, 13 Oct 2022 10:31:23 +0000 (12:31 +0200)]
[TBAA] Model call accessing immutable type as readnone

Accesses to constant memory are not observable and should be
reported as readnone, not readonly. This is consistent with what
we do for normal (non-call) instructions: For those, the TBAA
metadata will result in pointsToConstantMemory() returning true,
which will then result in a NoModRef result, not a Ref result.

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

2 years ago[LoongArch] Add codegen support for atomicrmw umin/umax operation on LA64
gonglingqin [Fri, 14 Oct 2022 07:23:51 +0000 (15:23 +0800)]
[LoongArch] Add codegen support for atomicrmw umin/umax operation on LA64

Furthermore, use `beqz $rd, .BB` instead of `beq $rd, $zero, .BB`.

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

2 years ago[mlir][llvm] Use tablegen to import extract/insert ops from LLVM IR.
Tobias Gysi [Fri, 14 Oct 2022 06:32:30 +0000 (09:32 +0300)]
[mlir][llvm] Use tablegen to import extract/insert ops from LLVM IR.

The revision imports the extract and insert value operations using
tablegen generated builders. Additionally, it moves the tests to
the instructions.ll test file.

Reviewed By: ftynse, dcaballe

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

2 years agoAdd f16 nearbyint support.
Leon Clark [Fri, 14 Oct 2022 07:05:10 +0000 (08:05 +0100)]
Add f16 nearbyint support.

Enable lowering of FNEARBYINT for f16 and extend existing tests.

Reviewed By: arsenm

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

2 years agoAMDGPU: Fix failing test with expensive checks
Matt Arsenault [Fri, 14 Oct 2022 06:34:20 +0000 (23:34 -0700)]
AMDGPU: Fix failing test with expensive checks

Fixes failure after d383adec4d3914492e67267462e6f00fdd4934af

2 years agoAtomicExpand: Avoid some operations if the atomic is overaligned
Matt Arsenault [Tue, 20 Sep 2022 21:51:42 +0000 (17:51 -0400)]
AtomicExpand: Avoid some operations if the atomic is overaligned

Let some of the pointer bithacking fold away if we know the LSB are 0.

2 years ago[llvm-profgen] Fix inconsistent loading address issues
wlei [Fri, 14 Oct 2022 03:42:51 +0000 (20:42 -0700)]
[llvm-profgen] Fix inconsistent loading address issues

This is to fix two issues related with loading address:

1) When multiple MMAPs occur and their loading address are different, before it only used the first MMap as base address, all perf address after it used the wrong base address.

2) For pseudo probe profile, the address is always based on preferred loading address. If the base address is not equal to the preferred loading address, the pseudo probe address query will be wrong.

Solution: Instead of converting the address to offset lazily, right now all the address after parsing are converted on the fly based on preferred loading address in the parsing time. There is no "offset" used in profile generator any more.

Reviewed By: hoy, wenlei

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

2 years ago[BOLT] Section-handling refactoring/overhaul
Maksim Panchenko [Thu, 22 Sep 2022 19:05:12 +0000 (12:05 -0700)]
[BOLT] Section-handling refactoring/overhaul

Simplify the logic of handling sections in BOLT. This change brings more
direct and predictable mapping of BinarySection instances to sections in
the input and output files.

* Only sections from the input binary will have a non-null SectionRef.
  When a new section is created as a copy of the input section,
  its SectionRef is reset to null.

* RewriteInstance::getOutputSectionName() is removed as the section name
  in the output file is now defined by BinarySection::getOutputName().

* Querying BinaryContext for sections by name uses their original name.
  E.g., getUniqueSectionByName(".rodata") will return the original
  section even if the new .rodata section was created.

* Input file sections (with relocations applied) are emitted via MC with
  ".bolt.org" prefix. However, their name in the output binary is
  unchanged unless a new section with the same name is created.

* New sections are emitted internally with ".bolt.new" prefix if there's
  a name conflict with an input file section. Their original name is
  preserved in the output file.

* Section header string table is properly populated with section names
  that are actually used. Previously we used to include discarded
  section names as well.

* Fix the problem when dynamic relocations were propagated to a new
  section with a name that matched a section in the input binary.
  E.g., the new .rodata with jump tables had dynamic relocations from
  the original .rodata.

Reviewed By: rafauler

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

2 years ago[BranchRelaxation] Fall through only if block has no unconditional branches
Anshil Gandhi [Fri, 14 Oct 2022 04:47:28 +0000 (22:47 -0600)]
[BranchRelaxation] Fall through only if block has no unconditional branches

Prior to inserting an unconditional branch from X to its
fall through basic block, check if X has any terminators to
avoid inserting additional branches.

Reviewed By: arsenm

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

2 years agoAMDGPU: Add __builtin_amdgcn_permlane64
Matt Arsenault [Wed, 28 Sep 2022 21:55:30 +0000 (17:55 -0400)]
AMDGPU: Add __builtin_amdgcn_permlane64

2 years agoAsmPrinter: Remove pointless code in inline asm emission
Matt Arsenault [Thu, 13 Oct 2022 17:02:34 +0000 (10:02 -0700)]
AsmPrinter: Remove pointless code in inline asm emission

This was scanning through def operands looking for the
symbol operand. This is pointless because the symbol is always
the first operand as enforced by the verifier, and all operands
are implicit.

2 years ago[AArch64][BuildErrorFix] Add compatible classifyGlobalFunctionReference
Xiang1 Zhang [Fri, 14 Oct 2022 03:23:20 +0000 (11:23 +0800)]
[AArch64][BuildErrorFix] Add compatible classifyGlobalFunctionReference

2 years ago[AArch64] add tests for ccmp with negative constant op1; NFC
chenglin.bi [Fri, 14 Oct 2022 04:07:43 +0000 (12:07 +0800)]
[AArch64] add tests for ccmp with negative constant op1; NFC

2 years ago[flang] Add a semantics test for atomic_ref
Katherine Rasmussen [Thu, 13 Oct 2022 01:10:53 +0000 (18:10 -0700)]
[flang] Add a semantics test for atomic_ref

Reviewed By: rouson

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

2 years ago[clang][PowerPC][NFC] Add base test case for PPC64 VAArg aggregate smaller than a...
Ting Wang [Fri, 14 Oct 2022 02:57:40 +0000 (22:57 -0400)]
[clang][PowerPC][NFC] Add base test case for PPC64 VAArg aggregate smaller than a slot

Reviewed By: shchenz

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

2 years ago[InlineAsm][bugfix] Correct function addressing in inline asm
Xiang1 Zhang [Tue, 13 Sep 2022 06:48:12 +0000 (14:48 +0800)]
[InlineAsm][bugfix] Correct function addressing in inline asm
In Linux PIC model, there are 4 cases about value/label addressing:
Case 1: Function call or Label jmp inside the module.
Case 2: Data access (such as global variable, static variable) inside the module.
Case 3: Function call or Label jmp outside the module.
Case 4: Data access (such as global variable) outside the module.

Due to current llvm inline asm architecture designed to not "recognize" the asm
code, there are quite troubles for us to treat mem addressing differently for
same value/adress used in different instuctions.
For example, in pic model, call a func may in plt way or direclty pc-related,
but lea/mov a function adress may use got.

This patch fix/refine the case 1 and case 2 in inline asm.
Due to currently inline asm didn't support jmp the outsider lable, this patch
mainly focus on fix the function call addressing bugs in inline asm.

Reviewed By: Pengfei, RKSimon

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

2 years ago[mlir][bufferize] Treat certain aliasing-only uses like memory reads
Matthias Springer [Fri, 14 Oct 2022 01:39:50 +0000 (10:39 +0900)]
[mlir][bufferize] Treat certain aliasing-only uses like memory reads

This fixes an issue in One-Shot Bufferize that could lead to missing buffer copies in the future. This bug can currently not be triggered because of the order in which ops are analyzed (always bottom-to-top). However, if we consider different traversal orders for the analysis in the future, this bug can cause subtle issues that are difficult to debug.

Example:
```
%0 = ...
%1 = tensor.insert ... into %0
%2 = tensor.extract_slice %0
tensor.extract %2[...]
```

In case of a top-to-bottom analysis of the above IR, the `tensor.insert` is analyzed before the `tensor.extract_slice`. In that case, the `tensor.insert` will bufferize in-place because %2 is not yet known to become an alias of %0 (and therefore causing a conflict).

With this change, the `tensor.insert` will bufferize out-of-place, regardless of the traversal order.

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

2 years ago[mlir] Update CallInterfaceCallable to use the new casting infra.
Nick Kreeger [Fri, 14 Oct 2022 01:33:24 +0000 (20:33 -0500)]
[mlir] Update CallInterfaceCallable to use the new casting infra.

This enables casting LLVM style for mlir::CallInterfaceCallable usage.

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

2 years ago[PowerPC] Change CRNOT to a code gen single operand instruction
Nemanja Ivanovic [Fri, 14 Oct 2022 01:09:23 +0000 (20:09 -0500)]
[PowerPC] Change CRNOT to a code gen single operand instruction

Inputs to crnor can come from operands with chains so
if it is being used simply to negate such an operand,
the repeated input cannot be CSE'd. This patch just
adds a code-gen only instruction for this that takes
a single input and duplicates it in the encoding of
the underlying crnor.

Differential revision: https://reviews.llvm.org/D133577

2 years agoImprove dynamic loader support in DynamicLoaderPOSIXDYLD when using core files.
Greg Clayton [Wed, 28 Sep 2022 23:50:38 +0000 (16:50 -0700)]
Improve dynamic loader support in DynamicLoaderPOSIXDYLD when using core files.

Prior to this fix, no shared libraries would be loaded for a core file, even if they exist on the current machine. The issue was the DYLDRendezvous would read a DYLDRendezvous::Rendezvous from memory of the process in DYLDRendezvous::Resolve() which would read some ld.so structures as they existed in the middle of a process' lifetime. In core files we see, the DYLDRendezvous::Rendezvous::state would be set to eAdd for running processes. When ProcessELFCore.cpp would load the core file, it would call DynamicLoaderPOSIXDYLD::DidAttach(), which would call the above Rendezvous functions. The issue came when during the DidAttach function it call DYLDRendezvous::GetAction() which would return eNoAction if the DYLDRendezvous::m_current.state was read from memory as eAdd. This caused no shared libraries to be loaded for any ELF core files. We now detect if we have a core file and after reading the DYLDRendezvous::m_current.state from memory we set it to eConsistent, which causes DYLDRendezvous::GetAction() to return the correct action of eTakeSnapshot and shared libraries get loaded.

We also improve the DynamicLoaderPOSIXDYLD class to not try and set any breakpoints to catch shared library loads/unloads when we have a core file, which saves a bit of time.

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

2 years ago[gn build] port 1fda6f6859aa (lld driver_executable)
Nico Weber [Thu, 13 Oct 2022 23:56:37 +0000 (19:56 -0400)]
[gn build] port 1fda6f6859aa (lld driver_executable)

2 years ago[SPIRV] Fix formatting of function tests
Michal Paszkowski [Mon, 10 Oct 2022 22:17:11 +0000 (00:17 +0200)]
[SPIRV] Fix formatting of function tests

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

2 years ago[scudo] Support partial page releasing
Chia-hung Duan [Thu, 13 Oct 2022 22:52:04 +0000 (22:52 +0000)]
[scudo] Support partial page releasing

Block grouping enables us doing partial page releasing so that we can
release the pages in a finer granularity. Which means we don't need to
visit all blocks to determine which pages are unused. Besides, this
means we can do incremental page releasing depends on the number fo free
blocks.

Reviewed By: cryptoad, cferris

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

2 years ago[scudo] Manage free blocks in BatchGroup.
Chia-hung Duan [Thu, 13 Oct 2022 22:51:17 +0000 (22:51 +0000)]
[scudo] Manage free blocks in BatchGroup.

Scudo is supposed to allocate any blocks across the entired mapped
pages and each page is equally likely to be selected. Which means Scudo
is leaning to touch as many pages as possible. This brings better
security but it also sacrifices the chance of releasing dirty pages.

To alleviate the unmanagable footprint growing, this CL introduces the
BatchGroup concept. Each blocks will be classified into a BatchGroup
according to its address. While allocation, we are leaning to allocate
blocks in the same group first. Note that the blocks selected from a
group is still random over several pages. At the same time, we have
better prediction of dirty page growing speed. Besides, we are able to
do partial page releasing by examing part of BatchGroups.

Reviewed By: cryptoad, cferris

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

2 years ago[scudo] Add PageReleaseContext to convey page usage status.
Chia-hung Duan [Thu, 13 Oct 2022 22:33:35 +0000 (22:33 +0000)]
[scudo] Add PageReleaseContext to convey page usage status.

PageReleaseContext contains all the information needed for determing if
a page can be released. Splitting out the context increases the flexibility
of heterogenous free lists in the future. Also rename PackedCounterArray to
PageMap.

Reviewed By: cryptoad, cferris

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

2 years agoUse u16 to store Count/MaxCount
Chia-hung Duan [Thu, 13 Oct 2022 22:03:06 +0000 (22:03 +0000)]
Use u16 to store Count/MaxCount

The Count/MaxCount used in TransferBatch and PerClass can be fit in u16 in
current configurations and it's also reasonable to have a u16 limit. The
spare 16 bits will be used for additional status like pages mapping
status in a TransferBatch.

Reviewed By: cryptoad, cferris, vitalybuka

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

2 years agoPlatformDarwinKernel calls the ctor directly, not setting no-jit
Jason Molenda [Thu, 13 Oct 2022 23:28:18 +0000 (16:28 -0700)]
PlatformDarwinKernel calls the ctor directly, not setting no-jit

Fix a small thinko in https://reviews.llvm.org/D133534 .  Normally
DynamicLoaderDarwinKernels are created via the CreateInstance plugin
method, and that plugin method sets the Process CanJIT to false.
In the above patch, I added a new code path that can call the
DynamicLoaderDarwinKernel ctor directly, without going through
CreateInstance, and CanJIT was not being correctly set for the
process.

rdar://101148552

2 years agoDriver: Change default Android linker to lld.
Peter Collingbourne [Fri, 7 Oct 2022 04:13:05 +0000 (21:13 -0700)]
Driver: Change default Android linker to lld.

The clang distributed with the Android NDK has defaulted to lld since r22,
so let's update the driver to match.

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

2 years ago[NFC][FuncSpec] Add a test to show redundant function cloning.
Alexandros Lamprineas [Fri, 7 Oct 2022 16:40:41 +0000 (17:40 +0100)]
[NFC][FuncSpec] Add a test to show redundant function cloning.

Happens when we find identical specializations.

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

2 years ago[PGO] Do not create block count annotations when all weights are 0,
Wolfgang Pieb [Fri, 16 Sep 2022 16:40:14 +0000 (09:40 -0700)]
[PGO] Do not create block count annotations when all weights are 0,
avoiding an assertion.

A BB with a nonzero count, whose successor blocks all have 0 counts, could
cause an assertion. Don't create any branch weights in this case.

Reviewed By: xur

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

2 years ago[lld][WebAssembly] Add symbols marking start/end of stack region
Sam Clegg [Thu, 13 Oct 2022 16:53:12 +0000 (09:53 -0700)]
[lld][WebAssembly] Add symbols marking start/end of stack region

Currently emscripten is make assumptions about that memory layout,
assuming the stack is between `__data_end` and `__heap_base`:

https://github.com/emscripten-core/emscripten/blob/af961ad5c4c278ec510f0b7f7d522a95ee5a90f8/system/lib/compiler-rt/stack_limits.S#L42-L61

With this change we can be more precise:

https://github.com/emscripten-core/emscripten/pull/18057

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

2 years agoApply clang-tidy fixes for performance-for-range-copy in VectorOps.cpp (NFC)
Mehdi Amini [Thu, 6 Oct 2022 19:36:31 +0000 (19:36 +0000)]
Apply clang-tidy fixes for performance-for-range-copy in VectorOps.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-identifier-naming in TosaCanonicalizations...
Mehdi Amini [Thu, 6 Oct 2022 19:32:24 +0000 (19:32 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in TosaCanonicalizations.cpp (NFC)

2 years agoMove GCC-compatible pod-packing change to v16/old behavior available at v15 and below
David Blaikie [Thu, 13 Oct 2022 21:11:41 +0000 (21:11 +0000)]
Move GCC-compatible pod-packing change to v16/old behavior available at v15 and below

Change matches D126334/e59f648d698e since this change got punted from
v15 too.

2 years agoRevert "[Libomp] Do not error on undefined version script symbols"
Slava Zakharin [Thu, 13 Oct 2022 20:43:41 +0000 (13:43 -0700)]
Revert "[Libomp] Do not error on undefined version script symbols"

This reverts commit 096f93e73dc3f88636cdcb57515e3732385b452d.

Revert "[Libomptarget] Make the plugins ingore undefined exported symbols"

This reverts commit 3f62314c235bd2475c8e2b5b874b2932a444e823.

Revert "[LLD] Enable --no-undefined-version by default."

This reverts commit 7ec8b0d162e354c703f5390784287054601f9c69.

Three commits are reverted because of the current omp build fail
with GNU ld. See discussion here: https://reviews.llvm.org/rG096f93e73dc3

2 years ago[lld-macho] Preserve the size of common symbols
Jez Ng [Thu, 13 Oct 2022 20:44:33 +0000 (16:44 -0400)]
[lld-macho] Preserve the size of common symbols

We never noticed this before because the only time the size gets emitted is via
the linker map...

Reviewed By: #lld-macho, thakis

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

2 years ago[lld-macho] Include symbol sizes in mapfile
Jez Ng [Thu, 13 Oct 2022 20:44:29 +0000 (16:44 -0400)]
[lld-macho] Include symbol sizes in mapfile

This matches ld64's behavior.

Additionally, I edited the "Dead Stripped Symbols" header to omit "Address" --
this also matches ld64.

Reviewed By: #lld-macho, oontvoo

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

2 years ago[test] Reset timer flag after test is done
Arthur Eubanks [Thu, 13 Oct 2022 20:31:22 +0000 (13:31 -0700)]
[test] Reset timer flag after test is done

Fixes some test failures after D135219 on internal bots.

2 years ago[InstCombine] fold logical and/or to xor
Sanjay Patel [Thu, 13 Oct 2022 19:37:28 +0000 (15:37 -0400)]
[InstCombine] fold logical and/or to xor

(A | B) & ~(A & B) --> A ^ B

https://alive2.llvm.org/ce/z/qpFMns

We already have the equivalent fold for real
logic instructions, but this pattern may occur
with selects too.

This is part of solving issue #58313.

2 years ago[InstCombine] add tests for logical select xor folds; NFC
Sanjay Patel [Thu, 13 Oct 2022 18:32:33 +0000 (14:32 -0400)]
[InstCombine] add tests for logical select xor folds; NFC

issue #58313

2 years ago[ConstraintElim] Add support for GEPs with multiple indices.
Florian Hahn [Thu, 13 Oct 2022 20:08:33 +0000 (21:08 +0100)]
[ConstraintElim] Add support for GEPs with multiple indices.

Lift restriction on GEPs with a single index by iterating over all
indices and joining the {Coefficient, Variable} entries for all indices
together.

2 years agoFix the clang Sphinx build
Aaron Ballman [Thu, 13 Oct 2022 20:04:25 +0000 (16:04 -0400)]
Fix the clang Sphinx build

This should address the issue found in:
https://lab.llvm.org/buildbot/#/builders/92/builds/34157

2 years ago[ConstraintElim] Add nested GEP test with scalable vectors.
Florian Hahn [Thu, 13 Oct 2022 19:58:10 +0000 (20:58 +0100)]
[ConstraintElim] Add nested GEP test with scalable vectors.

2 years ago[llvm-objdump] Add HelpText for --no-addresses after D135040
Fangrui Song [Thu, 13 Oct 2022 19:50:15 +0000 (12:50 -0700)]
[llvm-objdump] Add HelpText for --no-addresses after D135040

2 years ago[PGO] Make emitted symbols hidden
Alex Brachet [Thu, 13 Oct 2022 19:47:15 +0000 (19:47 +0000)]
[PGO] Make emitted symbols hidden

This was reverted because it was breaking when targeting Darwin which
tried to export these symbols which are now hidden. It should be safe
to just stop attempting to export these symbols in the clang driver,
though Apple folks will need to change their TAPI allow list described
in the commit where these symbols were originally exported
https://github.com/llvm/llvm-project/commit/f5380185623be243ba0f1b18d4bd594ac5cc7163

Bug: https://github.com/llvm/llvm-project/issues/58265

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

2 years ago[LLDB][NativePDB] Fix struct layout when it has anonymous unions.
Zequan Wu [Thu, 29 Sep 2022 02:40:35 +0000 (19:40 -0700)]
[LLDB][NativePDB] Fix struct layout when it has anonymous unions.

Previously, lldb mistook fields in anonymous union in a struct as the direct
field of the struct, which causes lldb crashes due to multiple fields sharing
the same offset in a struct. This patch fixes it.

MSVC generated pdb doesn't have the debug info entity representing a anonymous
union in a struct. It looks like the following:
```
struct S {
union {
  char c;
  int i;
};
};

0x1004 | LF_FIELDLIST [size = 40]
         - LF_MEMBER [name = `c`, Type = 0x0070 (char), offset = 0, attrs = public]
         - LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public]
0x1005 | LF_STRUCTURE [size = 32] `S`
         unique name: `.?AUS@@`
         vtable: <no type>, base list: <no type>, field list: 0x1004
```
Clang generated pdb is similar, though due to the [[ https://github.com/llvm/llvm-project/issues/57999 | bug ]],
it's not more useful than the debug info above. But that's not very relavent,
lldb should still be able to understand MSVC geneerated pdb.
```
0x1003 | LF_UNION [size = 60] `S::<unnamed-tag>`
         unique name: `.?AT<unnamed-type-$S1>@S@@`
         field list: <no type>
         options: forward ref (= 0x1003) | has unique name | is nested, sizeof 0
0x1004 | LF_FIELDLIST [size = 40]
         - LF_MEMBER [name = `c`, Type = 0x0070 (char), offset = 0, attrs = public]
         - LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public]
         - LF_NESTTYPE [name = ``, parent = 0x1003]
0x1005 | LF_STRUCTURE [size = 32] `S`
         unique name: `.?AUS@@`
         vtable: <no type>, base list: <no type>, field list: 0x1004
         options: contains nested class | has unique name, sizeof 4
0x1006 | LF_FIELDLIST [size = 28]
         - LF_MEMBER [name = `c`, Type = 0x0070 (char), offset = 0, attrs = public]
         - LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public]
0x1007 | LF_UNION [size = 60] `S::<unnamed-tag>`
         unique name: `.?AT<unnamed-type-$S1>@S@@`
         field list: 0x1006
         options: has unique name | is nested | sealed, sizeof
```
This patch delays the FieldDecl creation when travesing LF_FIELDLIST so we know
if there are multiple fields are in the same offsets and are able to group them
into different anonymous unions based on offsets. Nested anonymous union will
be flatten into one anonymous union, because we simply don't have that info, but
they are equivalent in terms of union layout.

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