[CodeGen] Fold load into LZCNT/TZCNT/POPCNT after compare elimination in peephole optimizer (#194662)
When a loaded value feeds both a bit-count instruction
(LZCNT/TZCNT/POPCNT) and an `icmp eq zero` / `select` sequence, ISel
emits the register form (`rr`) because the loaded value has two uses at
that point. The peephole optimizer later eliminates the redundant
compare (recognizing that LZCNT/TZCNT/POPCNT already set the necessary
EFLAGS), but failed to retry folding the load into the now single-use
bit-count instruction — because that instruction had already been
scanned.
The fix pre-saves the compared register before `optimizeCmpInstr` erases
the compare. After successful elimination, if the EFLAGS producer and
its defining load are both already-scanned and now have a single use,
fold immediately via `TII->optimizeLoadInstr`.
Before:
```
movq (%rdi), %rax
[10 lines not shown]
[DebugInfo] Enforce DISubprogram type as required in LLParser (#196299)
Add a parse-time check so that LLParser treats the `type:` field of
`DISubprogram` as required and non-null. Attempting to assemble IR with
a missing or null `type:` now produces a clear parse-time error
("missing required field 'type'" or "'type' cannot be null") rather
than relying solely on the verifier warning added in #194556.
Update existing hand-written LLVM IR tests to supply a minimal valid
`DISubroutineType` where they are not intentionally testing malformed
debug info.
**Scope.** This patch covers the LLParser path only. Two entry points
are intentionally deferred:
- *MetadataLoader*: pre-LLVM-5 bitcode legitimately stores null
`DISubprogram.type`; auto-upgrading that field requires more careful
backward-compatibility handling (see
`llvm/test/Bitcode/dityperefs-3.8.ll`).
- *BitcodeWriter*: IR written to bitcode has already passed the
verifier, which guarantees a non-null type; no additional check is
needed in the writer.
Follow-up to #194556.
[CIR] Lower materialize-global-temporaries that self-reference (#197314)
This showed up in a test suite, but cases where a materialized global
temporary references itself, we emitted an NYI. This patch implements it
by creating a 'throw-away' global op that can be referenced by name,
then erased/thrown away. Since it is referenced by name in global-view,
all of the uses I could reproduce didn't require a 'replaceAllUsesWith',
but the call is left in case some sort of initialization causes a
reference directly to the global.
Also, as a drive-by, `createGlobalOp` was a static member function that
took the CIRGenModule as an argument for some reason, so this patch just
makes it a member function.
linux/zpl_super: handle 'source' option directly
vfs_parse_fs_param_source() didn't appear until 5.14, and was not
backported to kernel.org LTS kernels. It's simple enough that it's
easier to just handle it ourselves rather than use a configure check.
Sponsored-by: TrueNAS
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18529
bootgrid: clean up converter compatibility code
Only other consumer is Nginx in plugins, but worst case scenario
these timestamps will render as... timestamps, which in that form
are sortable anyway. It's likely this was throwing an error anyway
The "sorters" weren't actually accounted for in the compat
translation, so this wasn't overridable. Fix this here.
[DirectX][ObjectYAML] Add ILDB program part support (#189685)
Add support for DXContainer ILDB parts in the ObjectYAML pipeline so
they can be represented in structured YAML and round-tripped through
yaml2obj/obj2yaml.
ILDB payloads use the same layout as DXIL, but contain debug IR. This
change treats ILDB as a DXIL-shaped program part.
FileSize and DXIL ProgramHeader Size values in DXILPart.yaml were
modified to make output binary correct/parseable by dxa utility.
[LLDB] Extract process arguments from core dump for Linux (#185338)
This PR adds the ability for lldb to print out how to reproduce the
crash by printing out the arguments used with the process on Linux.
This is implemented by extracting arguments from the field `pr_psargs`
of the struct `ELFLinuxPrPsInfo`, a note entries of an ELF coredump
file.
A limitation of this approach is that the `pr_psargs` char array is only
80 character long, so the command arguments that triggers a core dump
might not be fully captured. To alleviate this, if the arguments
extracted matches the maximal length, we emit `(command may be
truncated)` message when printing the arguments to the user.
Calling `process status -v` also prints out said arguments for users, as
suggested by #156427.
Not implemented for BSD-based OSs.
Assisted with Claude.
[lldb][Python] Include limited API library directory (#197185)
On Windows, when compiling with the limited API in non-debug mode,
Python will instruct the linker to link `python3.lib`
[here](https://github.com/python/cpython/blob/f5fb491341e566bbaf17d9bf3e4ec3af4a56bb3f/PC/pyconfig.h#L344-L345).
Currently, we don't directly specify the library in CMake. We specify
`python3xx.lib`. When the linker encounters the `python3.lib`
requirement, it errors out, because it doesn't know where that is. With
this PR, we add the directory of `python3xx.lib`. This is the same one
as `python3.lib`. So the linker can find the library.
This is more of a temporary fix. As commented in the code, we should use
`Python3_SABI_LIBRARY_DIRS` once we require CMake 3.26. Furthermore, I'm
not fully sure why we link to `python3xx.lib` when the limited API is
requested (presumably because of #167001?).
[lldb][windows] preserve PATH in lldbtest (#197232)
On Windows the shlib environment variable is `PATH`. In swiftlang, it
carries essential runtime paths (Swift runtime, etc.).
`SetEnvironmentEntries` with append=True replaces any matching key, so
simply returning "PATH=<test-build-dir>" currently wipes out the
inherited `PATH` and breaks DLL resolution.
This patch prepends the shlib directories to the inherited `PATH`
instead.
[CIR] Global-TLS Wrapper/init func lowering- (#197265)
This patch does most of the rest of the Global-TLS lowering prepare
feature. It makes sure the individual 'init' functions are generated,
and properly generates the 'wrapper' to call the 'init'.
It is missing(to come in the followup patch):
1- Generation of the actual 'call all inits' function. 2- Emitting the
'guard' functionality in unordered inits.
---------
Co-authored-by: Andy Kaylor <akaylor at nvidia.com>
[lldb][windows] add sibling-import fallback to LoadImage helper (#197218)
`PlatformWindows::DoLoadImage` injects `__lldb_LoadLibraryHelper` which
registers each caller-supplied search path via `AddDllDirectory()` and
calls `LoadLibraryExW(name, nullptr, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS)`.
In practice however, this flow fails for a common layout where a DLL
lives next to its sibling imports. LoadLibraryExW returns
ERROR_CANT_RESOLVE_FILENAME and the load is reported as unrecoverable,
even though every required DLL is present in one of the search paths.
This patch adds a fallback after the first `LoadLibraryExW(name,
nullptr, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS)` call: if it fails, iterate
the caller-provided search paths and try `LoadLibraryExW(path, nullptr,
LOAD_WITH_ALTERED_SEARCH_PATH)`. `LOAD_WITH_ALTERED_SEARCH_PATH`
instructs the Windows loader to add the DLL's own directory to the
dependency search.
See
https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryexa.
[3 lines not shown]