[AArch64][GlobalISel] Select i16/f16 cross-bank bitcasts (#220612)
Test bitcast_to_half in
llvm/test/CodeGen/AArch64/GlobalISel/arm64-atomic.ll crashes with
H0 = COPY W8
unimplemented reg-to-reg copy
UNREACHABLE executed at
/home/culrho01/llvm-project/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp:6363!
when type-based RegBankSelect (#199040) is enabled. Normal RBS keeps
both operands on GPR and moves to FPR afterward. This extends
instruction select to support bitcasts where src/dst reg bank doens't
match.
Assisted-by: codex
[libc] Enable code coverage using continuous instrumentation profiling (#213271)
This patch adds coverage to LLVM-libc using Clang continuous
instrumentation.
The `LIBC_ENABLE_COVERAGE` CMake option enables
`-fprofile-instr-generate=libc_cov_%c%p.profraw`, `-fcoverage-mapping`,
and `-fprofile-continuous` for Clang overlay builds, and is limited to
overlay build.
Developer documentation and usage instructions are added in
`libc/docs/dev/code_coverage.md` and indexed in
`libc/docs/dev/index.md`.
Assisted-by: Automated tooling, human reviewed.
[CIR] Derive lowering attr names from cppClassName, not the def name
CIRLoweringEmitter built its CXX_ABI_ALWAYS_LEGAL_ATTRS entries with
GetOpCppClassName, which splits the TableGen def name at the first
underscore. That works only while every def is named CIR_<CppClassName>Attr.
When one is not, the emitter writes an `isa<>` for a class that does not
exist, and the failure lands as a compile error in generated code.
Attributes carry the authoritative name in cppClassName, which
GenerateAttrToValueVisitor was already reading. Factor that out as
GetAttrCppClassRef and use it for both attribute paths. GetOpCppClassName
stays for operations.
NFC, and checkable. No CIR attribute overrides cppClassName, so the generated
CIRLowering.inc is byte-identical.
[CIR] Move the CIR enums off the legacy EnumAttrInfo hierarchy
MLIR has two enum hierarchies. `EnumAttrInfo` doubles as an `IntegerAttr`
constraint, so every CIR enum had to clear `genSpecializedAttr` to say it did
not want one. `EnumInfo` describes a C++ enum and nothing more.
Derive the CIR bases from `I32Enum`, `I64Enum` and `I32BitEnum`, and widen
`CIR_EnumAttr` to the `EnumInfo` that upstream `EnumAttr` already takes. The
flag no longer exists to clear. `FPClassTestEnum` gets unquoted printing from
`BitEnumBase` rather than overriding `printBitEnumQuoted`, and
`CIR_KnownFuncKind` drops a `parameterPrinter` the generated `operator<<`
now covers, still spelling `#cir.func_identity<"std::find">`.
AMDGPU wraps an `I32Enum` in an `EnumAttr` with this same bracketed format.
Parsing moves to the generated `FieldParser`, whose diagnostic names the
accepted spellings, so two `expected-error` lines change. Generated attribute
code drops 16 KB as 28 inlined parsers collapse into it.
[CIR] Drop dead ceremony around the CIR enum attributes
Five things that no longer earn their place in the CIR enum attribute
machinery.
CIR_CleanupKindAttr carried three. Its cppClassName restated the default
AttrDef already derives. Its skipDefaultBuilders plus hand-written
AttrBuilder existed only to default $value to CleanupKind::All, which no
caller relies on, so the generated builders stayed suppressed for nothing.
And its summary and description restated the name, overriding the enum's own
"cleanup kind" that EnumAttr would otherwise inherit. The isNormal, isEH and
isNormalAndEH helpers stay.
CIR_TLSModelAttr's summary restated its name the same way, so only that goes.
CIR_DefaultValuedEnumParameter has never had a user.
NFC.
[CIR] Migrate the FPClassTest bit enum and unquote its flags
cir.is_fp_class printed its flags inconsistently. Single-bit values came out
bare, as in `fcSNan`, while group values and combinations came out quoted, as
in `"fcInf"` and `"fcSNan|fcNegInf"`. That comes from I32BitEnumAttr setting
printBitEnumQuoted, which EnumAttr.td keeps only for backwards compatibility.
Clearing the bit and using the `enum` directive selects the separator-aware
parser and printer, so every value now spells unquoted:
cir.is_fp_class %x, fcSNan|fcNegInf : (!cir.float) -> !cir.bool
The enum also drops its specialized IntegerAttr for a CIR_EnumAttr wrapper,
giving it the standalone spelling `#cir.fp_class<fcSNan|fcNegInf>`. This
changes operation syntax, so it updates 37 CHECK lines.
[llvm][llvm-readobj] Print COFF RawDataSize as hex (#221224)
To match VirtualSize, and Microsoft's dumpbin which prints both as hex:
SECTION HEADER #1
.text name
440B4 virtual size
1000 virtual address (0000000140001000 to 00000001400450B3)
44200 size of raw data
llvm-readobj before this change:
VirtualSize: 0x3478
VirtualAddress: 0x74000
RawDataSize: 3584
And after:
VirtualSize: 0x3478
VirtualAddress: 0x74000
RawDataSize: 0xe00
[2 lines not shown]
[Flang][NFCI] Use abstraction for binary scalar data (#212956)
There is currently the assumption that the binary representation of the
scalar data classes (Integer, Real, Complex, Logical) is identical to
the binary representation of native types. For instance `Integer<64>`
can be reinterpret-casted to a `int64_t` or serialized using `memcpy`.
This will not be the case anymore with #206907. This first PR introduces
`LoadRawBytes` and `StoreRawBytes` abstractions that can be adapted when
the binary data layout of the scalar data classes change. No functional
change intended.
The binary representation is assumed for these uses:
1. Data serialization in initial-image.h/.cpp
2. Calling native math functions to constant-fold functions such as
`sin` in intrinsics-library.cpp. An abstraction layer has been created
in host.h/host.cpp to convert between host-native types and the scalar
data classes.
[28 lines not shown]
[clang-tidy][docs] Rename readability check docs to Markdown [1/5] (#221446)
Tracking issue: #201242
See the [migration guide] for more information.
[migration guide]:
https://llvm.org/docs/SphinxQuickstartTemplate.html#markdown-migration-guidelines
This is the first part of the mechanical rename of the check
documentations in readability module.
The rewrite is provided by the next PR in this stack.
[llvm][llvm-readobj][NFC] clang-format COFFDumper.cpp (#221688)
Prior to changes to it in #221224.
This formats the whole file, and when it's landed I'll add the commit
hash to .git-blame-ignore-revs.
[Inliner] Use distinct DILocations and cache inlineDebugLoc by OrigDL (#204817)
Found while profiling clang compiling `SLPVectorizer.cpp`.
The call chain `DILocation::get` -> `DILocation::getImpl` ->
`llvm::getUniqued` caused lots of expensive `DenseSet` `find_as` and
`grow` operations due to the cache being really inefficient. Switch to
`DILocation::getDistinct` and cache `inlineDebugLoc` by `OrigDL` for a
more efficient cache.
[X86] Don't fold loads from non-fixed stack objects into tail calls (#221243)
Fixes #216504
The callee of a tail call can be folded into the jump as a memory
operand (`TCRETURNmi64`). That jump runs after the epilogue, so the
operand is resolved relative to the incoming stack pointer, which only
works for fixed objects such as incoming arguments. Here the callee was
a `volatile` local, so the load stayed on the stack and got folded,
while a variable-index extract from a 256-bit vector went through a
32-byte stack temporary and forced dynamic realignment. Once the stack
is realigned a local has no static offset from the incoming stack
pointer, and PEI tripped the assertion. The sibcall eligibility check
does look at realignment, but it runs before legalization, so it never
saw the temporary. Spill slots created during register allocation can
cause the same thing, so no check at that point can be complete.
The fold is now refused whenever the load's address may use a non-fixed
frame index, in `checkTCRetEnoughRegs`, which gates both the
[5 lines not shown]
[CIR] Derive lowering attr names from cppClassName, not the def name
CIRLoweringEmitter built its CXX_ABI_ALWAYS_LEGAL_ATTRS entries with
GetOpCppClassName, which splits the TableGen def name at the first
underscore. That works only while every def is named CIR_<CppClassName>Attr.
When one is not, the emitter writes an `isa<>` for a class that does not
exist, and the failure lands as a compile error in generated code.
Attributes carry the authoritative name in cppClassName, which
GenerateAttrToValueVisitor was already reading. Factor that out as
GetAttrCppClassRef and use it for both attribute paths. GetOpCppClassName
stays for operations.
NFC, and checkable. No CIR attribute overrides cppClassName, so the generated
CIRLowering.inc is byte-identical.
[CIR] Migrate the FPClassTest bit enum and unquote its flags
cir.is_fp_class printed its flags inconsistently. Single-bit values came out
bare, as in `fcSNan`, while group values and combinations came out quoted, as
in `"fcInf"` and `"fcSNan|fcNegInf"`. That comes from I32BitEnumAttr setting
printBitEnumQuoted, which EnumAttr.td keeps only for backwards compatibility.
Clearing the bit and using the `enum` directive selects the separator-aware
parser and printer, so every value now spells unquoted:
cir.is_fp_class %x, fcSNan|fcNegInf : (!cir.float) -> !cir.bool
The enum also drops its specialized IntegerAttr for a CIR_EnumAttr wrapper,
giving it the standalone spelling `#cir.fp_class<fcSNan|fcNegInf>`. This
changes operation syntax, so it updates 37 CHECK lines.
[CIR] Drop dead ceremony around the CIR enum attributes
Five things that no longer earn their place in the CIR enum attribute
machinery.
CIR_CleanupKindAttr carried three. Its cppClassName restated the default
AttrDef already derives. Its skipDefaultBuilders plus hand-written
AttrBuilder existed only to default $value to CleanupKind::All, which no
caller relies on, so the generated builders stayed suppressed for nothing.
And its summary and description restated the name, overriding the enum's own
"cleanup kind" that EnumAttr would otherwise inherit. The isNormal, isEH and
isNormalAndEH helpers stay.
CIR_TLSModelAttr's summary restated its name the same way, so only that goes.
CIR_DefaultValuedEnumParameter has never had a user.
NFC.
[CIR] Move the CIR enums off the legacy EnumAttrInfo hierarchy
MLIR has two enum hierarchies. `EnumAttrInfo` doubles as an `IntegerAttr`
constraint, so every CIR enum had to clear `genSpecializedAttr` to say it did
not want one. `EnumInfo` describes a C++ enum and nothing more.
Derive the CIR bases from `I32Enum`, `I64Enum` and `I32BitEnum`, and widen
`CIR_EnumAttr` to the `EnumInfo` that upstream `EnumAttr` already takes. The
flag no longer exists to clear. `FPClassTestEnum` gets unquoted printing from
`BitEnumBase` rather than overriding `printBitEnumQuoted`, and
`CIR_KnownFuncKind` drops a `parameterPrinter` the generated `operator<<`
now covers, still spelling `#cir.func_identity<"std::find">`.
AMDGPU wraps an `I32Enum` in an `EnumAttr` with this same bracketed format.
Parsing moves to the generated `FieldParser`, whose diagnostic names the
accepted spellings, so two `expected-error` lines change. Generated attribute
code drops 16 KB as 28 inlined parsers collapse into it.
[CIR] Move the CIR enums off the legacy EnumAttrInfo hierarchy (#220889)
MLIR has two enum hierarchies. `EnumAttrInfo` doubles as an
`IntegerAttr`
constraint, so every CIR enum had to clear `genSpecializedAttr` to say
it did
not want one. `EnumInfo` describes a C++ enum and nothing more.
Derive the CIR bases from `I32Enum`, `I64Enum` and `I32BitEnum`, and
widen
`CIR_EnumAttr` to the `EnumInfo` that upstream `EnumAttr` already takes.
The
flag no longer exists to clear. `FPClassTestEnum` gets unquoted printing
from
`BitEnumBase` rather than overriding `printBitEnumQuoted`, and
`CIR_KnownFuncKind` drops a `parameterPrinter` the generated
`operator<<`
now covers, still spelling `#cir.func_identity<"std::find">`.
[Support][Caching] Don't use `mmap` in `localCache`, on NFS
When the cache directory is on an NFS, we may hit a SIGBUS signal
when there is contention on the cache.
This happens typically with MPI jobs running on an NFS mounted $HOME
directory.
If we execute through the regular `read()` path, we also fail with a
`Stale file descriptor` error. But at least this path is properly handled
and we can continue without using the cache.
To achieve this, we pass `OnNFS` to `IsVolatile` and `RequiresNullTerminator`,
which makes `shouldUseMmap` return `false`.
[LoopSafetyInfo] Store Loop and automatically compute (NFC) (#221238)
This makes two changes:
* LoopSafetyInfo is bound to a single loop. Store the Loop in the ctor,
so it does not need to be passed to individual queries.
* Automatically compute LoopSafetyInfo on construction, instead of in a
separate call. This is mostly to clarify that (contrary to the doc
comment) nobody is actually trying to invalidate LoopSafetyInfo by
rerunning computeLoopSafetyInfo().
This makes it easier to change implementation details, like computing
information lazily.
[lldb][test] Rewrite Watchpoint/SetErrorCases as API test (#221563)
This test is randomly failing on macOS bots with this error:
```
error: Command requires a process which is currently stopped.
```
There is no test logic in shell tests that can diagnose what is going on
with the process, so this patch rewrites this test as an API test where
we have better error handling.
Reapply [Clang][CodeGen] Use ptrtoaddr for pointer diff (#210729) (#221675)
Reapply https://github.com/llvm/llvm-project/pull/210729 without change
after https://github.com/llvm/llvm-project/pull/221188, which should fix
the miscompiles this change exposed.
-----
We don't have to expose the provenance of pointers for pointer
subtraction, so use ptrtoaddr instead of ptrtoint if -fwrapv-pointer is
not set.
Co-authored-by: Alexis Engelke <engelke at in.tum.de>