Apply LLVM patches for deterministic operand order and correct peephole optimization for minsize (#500)

## Description

Applies LLVM patches that have not been backported to the major version
used in our submodule:

* [LLVM PR #163679](https://github.com/llvm/llvm-project/pull/163679)
  * *"[RISCV] Allow large div peephole optimization for minsize"*
* Fixes peephole optimization of large integers when `minsize` function
attribute is set.
* (Our revive codebase used a workaround that can be removed once this
500 PR is merged and we publish a new LLVM release.)
* [LLVM PR #190219](https://github.com/llvm/llvm-project/pull/190219)
* *"[TargetLowering] Speculative fix for a non-determinism issue between
different compilers"*
* Operand ordering of `mul i256` were different depending on the target
ABI when building LLVM, producing different RISC-V and PVM bytecode for
our Windows vs macOS/linux builds.
* The bytecode divergence (yet functionally equivalent) affected
Solidity contracts containing a value [multiplied by
itself](https://github.com/llvm/llvm-project/issues/190148) (e.g. via
explicit squaring or exponentiation), manifesting primarily when using
optimization level `-O0`.
This commit is contained in:
LJ authored and GitHub committed 2026-04-09 17:33:09 +02:00
1 parent 8c41f93ace
commit 3dc84349d9
9 files changed
+99 -11

No files matched your search

+3
View File
@@ -20,6 +20,9 @@ impl LLVMPath {
/// The Emscripten SDK source directory.
pub const DIRECTORY_EMSDK_SOURCE: &'static str = "./emsdk/";
/// The directory containing patches to apply to the LLVM source.
pub const DIRECTORY_PATCHES: &'static str = "./patches/llvm/";
/// Returns the path to the `llvm` stage 1 host LLVM source module directory.
pub fn llvm_host_module_llvm() -> anyhow::Result<PathBuf> {
let mut path = PathBuf::from(Self::DIRECTORY_LLVM_HOST_SOURCE);