Skip to content

Conversation

@4vtomat
Copy link
Member

@4vtomat 4vtomat commented Sep 15, 2025

This commit implements a complete load/store optimization pass for the
RISC-V Zilsd extension, which combines pairs of 32-bit load/store
instructions into single 64-bit LD/SD instructions when possible.
Default alignment is 8, it also provide zilsd-4byte-align feature for
looser condition.

Related work: https://reviews.llvm.org/D144002

This commit implements a complete load/store optimization pass for the
RISC-V Zilsd extension, which combines pairs of 32-bit load/store
instructions into single 64-bit LD/SD instructions when possible.
Default alignment is 8, it also provide zilsd-4byte-align feature for
looser condition.
@llvmbot
Copy link
Member

llvmbot commented Sep 15, 2025

@llvm/pr-subscribers-backend-risc-v

Author: Brandon Wu (4vtomat)

Changes

This commit implements a complete load/store optimization pass for the
RISC-V Zilsd extension, which combines pairs of 32-bit load/store
instructions into single 64-bit LD/SD instructions when possible.
Default alignment is 8, it also provide zilsd-4byte-align feature for
looser condition.


Patch is 53.61 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/158640.diff

12 Files Affected:

  • (modified) llvm/lib/Target/RISCV/CMakeLists.txt (+1)
  • (modified) llvm/lib/Target/RISCV/RISCV.h (+6)
  • (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+5)
  • (modified) llvm/lib/Target/RISCV/RISCVInstrInfoZilsd.td (+15)
  • (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp (+68)
  • (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.h (+10)
  • (modified) llvm/lib/Target/RISCV/RISCVTargetMachine.cpp (+8)
  • (added) llvm/lib/Target/RISCV/RISCVZilsdOptimizer.cpp (+765)
  • (modified) llvm/test/CodeGen/RISCV/O3-pipeline.ll (+2)
  • (added) llvm/test/CodeGen/RISCV/zilsd-ldst-opt-postra.mir (+137)
  • (added) llvm/test/CodeGen/RISCV/zilsd-ldst-opt-prera.mir (+1065)
  • (added) llvm/test/CodeGen/RISCV/zilsd-regalloc-hints.mir (+83)
<!DOCTYPE html>
<!--

Hello future GitHubber! I bet you're here to remove those nasty inline styles,
DRY up these templates and make 'em nice and re-usable, right?

Please, don't. https://github.com/styleguide/templates/2.0

-->
<html>
  <head>
    <title>Unicorn! &middot; GitHub</title>
    <style type="text/css" media="screen">
      body {
        background-color: #f1f1f1;
        margin: 0;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
      }

      .container { margin: 50px auto 40px auto; width: 600px; text-align: center; }

      a { color: #4183c4; text-decoration: none; }
      a:hover { text-decoration: underline; }

      h1 { letter-spacing: -1px; line-height: 60px; font-size: 60px; font-weight: 100; margin: 0px; text-shadow: 0 1px 0 #fff; }
      p { color: rgba(0, 0, 0, 0.5); margin: 10px 0 10px; font-size: 18px; font-weight: 200; line-height: 1.6em;}

      ul { list-style: none; margin: 25px 0; padding: 0; }
      li { display: table-cell; font-weight: bold; width: 1%; }

      .logo { display: inline-block; margin-top: 35px; }
      .logo-img-2x { display: none; }
      @media
      only screen and (-webkit-min-device-pixel-ratio: 2),
      only screen and (   min--moz-device-pixel-ratio: 2),
      only screen and (     -o-min-device-pixel-ratio: 2/1),
      only screen and (        min-device-pixel-ratio: 2),
      only screen and (                min-resolution: 192dpi),
      only screen and (                min-resolution: 2dppx) {
        .logo-img-1x { display: none; }
        .logo-img-2x { display: inline-block; }
      }

      #suggestions {
        margin-top: 35px;
        color: #ccc;
      }
      #suggestions a {
        color: #666666;
        font-weight: 200;
        font-size: 14px;
        margin: 0 10px;
      }

    </style>
  </head>
  <body>

    <div class="container">
      <p>
        <img width="200" src="data:image/png;base64,
iVBORw0KGgoAAAANSUhEUgAAAZAAAAGZCAMAAACQbpc2AAADAFBMVEWEBz6FAD6FAD6GAD+MAEGOAEOKAEGOAEOGAD+IAECOAEOOAUOOAEOOAEOOAEOOAEOOAEOOAEOCACyOAEQAAACKAEJpoJ2KADqu0eSKAD2BAD+KAD6AxCNqwoX1Ziawo9LYnGuwhL7aiwaIyYudst6DlrnhcWvCcVvlbE9PvsL2u3uYmdCZum9Rns7clUYsreOYp2nuj37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UhJBJTUUIx5mwUr7YbDAQ7MNew5yHthcCZnmTN5aRaZOn/+LfHJCWCwNiCCChIROLHyoe3bIvzIexVAPxqNft1jv2x6EIkgMIVxJyFqhzHv7I1YWpuGStREgYakiU5JPnE5f0Nn7V05EMEmpKgKG/o143Niq6wdJvjOoOfOX169/+aU5xLxsR+DmlQPZiOFI7I8Qm2BfmFMZkIfzQJCQWDEeuuVDHvsKHoX5e6tOngQOjgQW61sAUT0AoguzVn/4w//9X+wCsBPgsUYSZ6kiC7goTeye8MlRtZqICGFIlvb1gk1pf/8uslqcx8n+ww0yD3ffeJNfh7ox8YiryEqB0BpFrS4pdsxAPAkAWYAERCKKWMXxL5xH7smqk/39QLH3pGaxKA3hMbOQP0JIQZgDWVPhroTXRr+ckKWE86sfdSRGLktTAY/Sv/xlVz89jKV7hYLMrdMvEKWYFwdKVgyEr8wQp0z5ThNeOQEOINGoPERCovAzJODxG26vcm/0nwSO/v6dO8lw7b8KDUGiTuX320kCxQl6jSsbsu/d4Up0s+Wy+EJ+ciT0ErLYq6RgAntV07z117uo/dO/a5euIOz4NGDwgSDsB331EW02XikQVNrZ1huUN0WlF0Csx6AhDxkR/nrfpnrYiQUwebBFYem5zuP/0FfUsSCUh2Dvxu4kIFAQj5NnIGuMJOzu0wrBnwX9PsXZ+xdGIyUWPf5ajCWnqqt/16+3nrzRfOPG1q03ILnFpCCLLtwkJBvpIt0VAYGBWkdBLjrzr9L6NN6b4hryu4caCV1HkJB42IkFJCDMYO2BvSLZ+yumIOUIk6EiCLNClFYmK4hUTyXFNRcEXLBb3Gxd6Z7oDEbnkJFoPJa0X4LIj4d2VbVW5RyC2cLzuPW/6aHcUygbNmHzSdA3Vgxk4zsAokRVz/QLo...
[truncated]

@github-actions
Copy link

github-actions bot commented Sep 15, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@lenary
Copy link
Member

lenary commented Sep 15, 2025

Great to see someone is contributing this work, as we have looked forward to having it too.

I have a few high-level comments, which I don't think are covered by Craig's review, and might supersede his comments:

Is this based on the NXP Patches against LLVM 18? If so, this will need appropriate Co-authored-by. Even if it isn't, I will add @anmolparalkar-nxp as a reviewer as he is familiar with that work.

We already have one pass that does this optimisation: RISCVLoadStoreOptimizer (in PreSched2). Your "PostAlloc" pass should be merged into this pass, as they are doing the same thing, at the same point in the pass pipeline (I will also add @djtodoro as a reviewer as he worked on that pass). The Pre Allocation pass can be left separate.

I am glad to see the new zilsd-4byte-align feature, as it is also something that we want, and would use in other places (e.g. #153595). I agree that this isn't a "tune" feature. To me it feels more similar to an intermediate scalar alignment mode, somewhere between "everything has to be naturally aligned" (the default) and FeatureUnalignedScalarMem (everything can be 1-byte aligned) - maybe it should be modelled that way? I guess we'd end up needing changes to clang flags to enable this, which can come as a follow-up.

@topperc
Copy link
Collaborator

topperc commented Sep 15, 2025

We already have one pass that does this optimisation: RISCVLoadStoreOptimizer (in PreSched2). Your "PostAlloc" pass should be merged into this pass, as they are doing the same thing, at the same point in the pass pipeline (I will also add @djtodoro as a reviewer as he worked on that pass). The Pre Allocation pass can be left separate.

They aren't really doing the same thing are they? This pass uncombines the pseudo instructions that didn't register allocate correctly. The existing pass combines small loads into wider loads.

@topperc
Copy link
Collaborator

topperc commented Sep 15, 2025

To me it feels more similar to an intermediate scalar alignment mode, somewhere between "everything has to be naturally aligned" (the default) and FeatureUnalignedScalarMem (everything can be 1-byte aligned) - maybe it should be modelled that way?

Wouldn't modeling it that way imply that FLD and FSD would support 4 byte alignment when Zilsd supports 4 byte alignment?

@lenary
Copy link
Member

lenary commented Sep 15, 2025

To me it feels more similar to an intermediate scalar alignment mode, somewhere between "everything has to be naturally aligned" (the default) and FeatureUnalignedScalarMem (everything can be 1-byte aligned) - maybe it should be modelled that way?

Wouldn't modeling it that way imply that FLD and FSD would support 4 byte alignment when Zilsd supports 4 byte alignment?

Fair question, but my feeling (no hard data to back this up) is that cores with the 4-byte Zilsd support would likely do the same kind of thing for D accesses. I would especially expect this for Zdinx cores.

If we do make it an unaligned scalar mode, I would probably rename it XLenAlignedScalarMem.

Maybe this is too much and a zilsd-only option is good enough for the moment.

@lenary
Copy link
Member

lenary commented Sep 15, 2025

We already have one pass that does this optimisation: RISCVLoadStoreOptimizer (in PreSched2). Your "PostAlloc" pass should be merged into this pass, as they are doing the same thing, at the same point in the pass pipeline (I will also add @djtodoro as a reviewer as he worked on that pass). The Pre Allocation pass can be left separate.

They aren't really doing the same thing are they? This pass uncombines the pseudo instructions that didn't register allocate correctly. The existing pass combines small loads into wider loads.

They aren't, but I think it would be good to have only one early pairing-related pass and one late pairing-related pass, especially if we're going to run the late passes at such a similar time. I realise this PR isn't the one that's going to make the existing late pairing pass support Zilsd.

@djtodoro
Copy link
Collaborator

We already have one pass that does this optimisation: RISCVLoadStoreOptimizer (in PreSched2). Your "PostAlloc" pass should be merged into this pass, as they are doing the same thing, at the same point in the pass pipeline (I will also add @djtodoro as a reviewer as he worked on that pass). The Pre Allocation pass can be left separate.

They aren't really doing the same thing are they? This pass uncombines the pseudo instructions that didn't register allocate correctly. The existing pass combines small loads into wider loads.

They aren't, but I think it would be good to have only one early pairing-related pass and one late pairing-related pass, especially if we're going to run the late passes at such a similar time. I realise this PR isn't the one that's going to make the existing late pairing pass support Zilsd.

I agree with this.

@djtodoro
Copy link
Collaborator

We already have one pass that does this optimisation: RISCVLoadStoreOptimizer (in PreSched2). Your "PostAlloc" pass should be merged into this pass, as they are doing the same thing, at the same point in the pass pipeline (I will also add @djtodoro as a reviewer as he worked on that pass). The Pre Allocation pass can be left separate.

They aren't really doing the same thing are they? This pass uncombines the pseudo instructions that didn't register allocate correctly. The existing pass combines small loads into wider loads.

They aren't, but I think it would be good to have only one early pairing-related pass and one late pairing-related pass, especially if we're going to run the late passes at such a similar time. I realise this PR isn't the one that's going to make the existing late pairing pass support Zilsd.

I agree with this.

Furthermore, if it cannot be embedded into RISCVLoadStoreOptimizer.cpp, I would expect RISCVLoadStoreOptimizer being mentioned in the top level comment in RISCVZilsdOptimizer.cpp file, by explaining how it differs from the existing Pass.

@4vtomat
Copy link
Member Author

4vtomat commented Sep 24, 2025

Great to see someone is contributing this work, as we have looked forward to having it too.

I have a few high-level comments, which I don't think are covered by Craig's review, and might supersede his comments:

Is this based on the NXP Patches against LLVM 18? If so, this will need appropriate Co-authored-by. Even if it isn't, I will add @anmolparalkar-nxp as a reviewer as he is familiar with that work.

No I started this from scratch, I didn't even notice there's existing one lol

@djtodoro
Copy link
Collaborator

Great to see someone is contributing this work, as we have looked forward to having it too.
I have a few high-level comments, which I don't think are covered by Craig's review, and might supersede his comments:
Is this based on the NXP Patches against LLVM 18? If so, this will need appropriate Co-authored-by. Even if it isn't, I will add @anmolparalkar-nxp as a reviewer as he is familiar with that work.

No I started this from scratch, I didn't even notice there's existing one lol

I feel like mentioning https://reviews.llvm.org/D144002 (XTheadMemPair) as related work as well.

@4vtomat
Copy link
Member Author

4vtomat commented Sep 25, 2025

Fixed all comments including moving post-ra fixup pass to RISCVLoadStoreOptimizer

Copy link
Member

@lenary lenary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments about edge cases.

// register This prevents register reuse issues where the first load
// overwrites the base
if (Opcode == RISCV::LW) {
if (FirstReg == BaseReg || SecondReg == BaseReg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't believe that the Zilsd specification, as ratified, includes this restriction. The 20250508 version of the unprivileged spec does not mention it. I think this did once exist in an unratified Zilsd spec, but was removed.

@4vtomat
Copy link
Member Author

4vtomat commented Nov 14, 2025

@lenary @topperc My apologize, I usually use 2 laptop to work so there's some part of fix that didn't be pushed and I thought I did..
I try to combine them with new fixes, this round of updates includes:

  1. pre-ra part alignment issue fix and simplifying the code.
  2. post-ra part valid register pair detection fix, external symbol removement and simplifying the code.
  3. make first reg of PseudoLD_RV32_OPT so that it won't be overlapped with base reg which corrects decomposition(if any).
    For 3. I'm not sure if this solution is too aggressive, or maybe we can use something like register scavenger?

@lenary
Copy link
Member

lenary commented Nov 18, 2025

@lenary @topperc My apologize, I usually use 2 laptop to work so there's some part of fix that didn't be pushed and I thought I did.. I try to combine them with new fixes ...

Thanks for explaining, this makes sense for what happened - I'm glad we found out what happened, as you are normally very good with review comments.

Copy link
Member

@lenary lenary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just did a close reading, and I think I'm happy enough? The below are broadly just nits. I don't think any of them are required to land this.


// When no memory operands are present, conservatively assume unaligned,
// volatile, unfoldable.
if (!MI.hasOneMemOperand())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can happen if we merge two separate instructions with different memoperands. I think this case is rare so this is ok.

Comment on lines 207 to 209
unsigned Alignment = MMO->getBaseAlign().value() + Offset0;
if (Alignment < RequiredAlign.value() ||
(Alignment % RequiredAlign.value()) != 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we know MI0 is the instruction with the lower offset (you sorted them by offset, so I believe this to be true), then we can use MachineMemOp::getAlign() on the op from the lower instruction, and compare the two Aligns directly, because the lower of the two offsets needs to be the correctly aligned one

Suggested change
unsigned Alignment = MMO->getBaseAlign().value() + Offset0;
if (Alignment < RequiredAlign.value() ||
(Alignment % RequiredAlign.value()) != 0)
if (MMO->getAlign() < RequiredAlign)

S

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not ok to add getBaseAlign from MMO and the Offset from the instruction. BaseAlign is the alignment of the MMO without the including the offset that is also stored in the MMO. If the offset in the MMO is 0, which is possible even if the instruction has a non-zero immediate, the code will calculate too large of an alignment.

It would not be correct with the offset from the MMO either. Alignment isn't additive like this. To calculate alignment you need to take the common alignment from the base and the offset.

Sam's suggestion is correct and should block this patch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my bad, you're right the alignment cant be added directly it should be lowest common multiple

// Special case: First register can not be zero
// zeros
if (First == RISCV::X0)
return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code here isn't great, but this does now do the correct thing.

  if (First == X0)
    return (Second == x0);

Would be equivalent to these two initial ifs and simpler.

Comment on lines 207 to 209
unsigned Alignment = MMO->getBaseAlign().value() + Offset0;
if (Alignment < RequiredAlign.value() ||
(Alignment % RequiredAlign.value()) != 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not ok to add getBaseAlign from MMO and the Offset from the instruction. BaseAlign is the alignment of the MMO without the including the offset that is also stored in the MMO. If the offset in the MMO is 0, which is possible even if the instruction has a non-zero immediate, the code will calculate too large of an alignment.

It would not be correct with the offset from the MMO either. Alignment isn't additive like this. To calculate alignment you need to take the common alignment from the base and the offset.

Sam's suggestion is correct and should block this patch.

@github-actions
Copy link

github-actions bot commented Nov 20, 2025

🐧 Linux x64 Test Results

  • 186417 tests passed
  • 4867 tests skipped

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a complete load/store optimization pass for the RISC-V Zilsd extension, which combines pairs of 32-bit load/store instructions (LW/SW) into single 64-bit LD/SD instructions on RV32 systems. The optimization operates in two phases: a pre-allocation phase that reschedules and pairs instructions while providing register allocation hints, and a post-allocation phase that validates or decomposes the paired instructions based on actual register assignments.

Key changes:

  • New pre-allocation optimization pass that identifies and combines consecutive memory operations
  • Post-allocation validation and decomposition logic integrated into existing RISCVLoadStoreOptimizer
  • Register allocation hint mechanism for encouraging consecutive even/odd register pairs
  • Support for both 8-byte (default) and 4-byte alignment via feature flag

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
llvm/lib/Target/RISCV/RISCVZilsdOptimizer.cpp New pre-allocation pass implementing instruction rescheduling, pairing logic, and safety checks
llvm/lib/Target/RISCV/RISCVLoadStoreOptimizer.cpp Extended with post-allocation logic to validate/decompose pseudo-instructions
llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp/h Added register allocation hint handling for consecutive register pairs
llvm/lib/Target/RISCV/RISCVInstrInfoZilsd.td Defined new pseudo-instructions for optimization phase
llvm/lib/Target/RISCV/RISCVFeatures.td Added zilsd-4byte-align feature flag
llvm/lib/Target/RISCV/RISCVTargetMachine.cpp Integrated new pass into compilation pipeline
llvm/test/CodeGen/RISCV/*.mir Comprehensive test suite covering various optimization scenarios
llvm/lib/Target/RISCV/RISCV.h Pass declaration
llvm/lib/Target/RISCV/CMakeLists.txt Build system integration
llvm/test/CodeGen/RISCV/O3-pipeline.ll Pipeline test update
llvm/test/CodeGen/RISCV/features-info.ll Feature info test update

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

4vtomat and others added 2 commits November 20, 2025 17:47
bool IsOdd = (RegNum % 2 != 0);

// Verify the pair register exists and is in the same register class
if ((WantOdd && IsOdd) || (!WantOdd && !IsOdd))
Copy link
Collaborator

@topperc topperc Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check reserved registers here like ARM so we don't hint X5 which can never pair with the reserved X4 register. We don't want to hint S1(X9) when S0(X8) is reserved for the frame pointer. And we don't want to hint X1, since X0 and X1 isn't a valid pair.

Users can also reserved registers from the command line.

We can fix this in a follow up.

Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@4vtomat 4vtomat enabled auto-merge (squash) November 21, 2025 04:32
@4vtomat 4vtomat merged commit 645e0dc into llvm:main Nov 21, 2025
7 of 9 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 21, 2025

LLVM Buildbot has detected a new failure on builder clang-m68k-linux-cross running on suse-gary-m68k-cross while building llvm at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/19244

Here is the relevant piece of the build log for the reference
Step 5 (ninja check 1) failure: stage 1 checked (failure)
...
[186/1214] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/tweaks/TweakTests.cpp.o
[187/1214] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/CodeCompleteTests.cpp.o
[188/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/ArenaTest.cpp.o
[189/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Driver/ToolChainTest.cpp.o
[190/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/FormulaTest.cpp.o
[191/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp.o
[192/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/CloneDetectionTest.cpp.o
[193/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/MacroExpansionContextTest.cpp.o
[194/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/ValueTest.cpp.o
[195/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp.o
FAILED: tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp.o 
/usr/bin/c++ -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/unittests -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests/Tooling -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/third-party/unittest/googletest/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/third-party/unittest/googlemock/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-dangling-reference -Wno-redundant-move -Wno-pessimizing-move -Wno-array-bounds -Wno-stringop-overread -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -O3 -DNDEBUG -std=c++17  -Wno-variadic-macros -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp.o -MF tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp.o.d -o tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp.o -c /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
[196/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/StaticAnalyzer/AnalyzerOptionsTest.cpp.o
[197/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/CFGTest.cpp.o
[198/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/CachedConstAccessorsLatticeTest.cpp.o
[199/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/RecordOpsTest.cpp.o
[200/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/StaticAnalyzer/APSIntTypeTest.cpp.o
[201/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/ASTOpsTest.cpp.o
[202/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/SmartPointerAccessorCachingTest.cpp.o
[203/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/DeterminismTest.cpp.o
[204/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/TransferBranchTest.cpp.o
[205/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/SimplifyConstraintsTest.cpp.o
[206/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp.o
[207/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/CFGDominatorTree.cpp.o
[208/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp.o
[209/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/TestingSupport.cpp.o
[210/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/MapLatticeTest.cpp.o
[211/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/CFGMatchSwitchTest.cpp.o
[212/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/StaticAnalyzer/BlockEntranceCallbackTest.cpp.o
[213/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/MatchSwitchTest.cpp.o
[214/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp.o
[215/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTest.cpp.o
[216/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/LoggerTest.cpp.o
[217/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp.o
[218/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/DebugSupportTest.cpp.o
[219/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/SignAnalysisTest.cpp.o
[220/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/WatchedLiteralsSolverTest.cpp.o
[221/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp.o
[222/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/StaticAnalyzer/BugReportInterestingnessTest.cpp.o
[223/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/IntervalPartitionTest.cpp.o
[224/1214] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/LifetimeSafetyTest.cpp.o
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests/Analysis/LifetimeSafetyTest.cpp: In instantiation of ‘bool clang::lifetimes::internal::{anonymous}::AreLiveAtImplMatcherP2<Annotation_type, ConfFilter_type>::gmock_Impl<arg_type>::MatchAndExplain(const arg_type&, testing::MatchResultListener*) const [with arg_type = const clang::lifetimes::internal::{anonymous}::OriginsInfo&; Annotation_type = const char*; ConfFilter_type = clang::lifetimes::internal::{anonymous}::LivenessKindFilter]’:
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests/Analysis/LifetimeSafetyTest.cpp:302:1:   required from here
  302 | MATCHER_P2(AreLiveAtImpl, Annotation, ConfFilter, "") {
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests/Analysis/LifetimeSafetyTest.cpp:312:19: warning: loop variable ‘<structured bindings>’ creates a copy from type ‘const std::pair<clang::lifetimes::internal::utils::ID<clang::lifetimes::internal::OriginTag>, clang::lifetimes::internal::LivenessKind>’ [-Wrange-loop-construct]
  312 |   for (const auto [OID, ActualConfidence] : ActualLiveSetOpt.value()) {
      |                   ^~~~~~~~~~~~~~~~~~~~~~~

@lenary
Copy link
Member

lenary commented Nov 21, 2025

@4vtomat thanks for having the patience to work through all our comments, I do appreciate that this wasn't as quick/easy as one might have hoped. I'm glad with where we got to though, it's good!

@4vtomat
Copy link
Member Author

4vtomat commented Nov 21, 2025

@4vtomat thanks for having the patience to work through all our comments, I do appreciate that this wasn't as quick/easy as one might have hoped. I'm glad with where we got to though, it's good!

@lenary thanks for your patience to review such a big PR, your comments are really helpful and make me learn a lot, I really appreciate that!

aadeshps-mcw pushed a commit to aadeshps-mcw/llvm-project that referenced this pull request Nov 26, 2025
This commit implements a complete load/store optimization pass for the
RISC-V Zilsd extension, which combines pairs of 32-bit load/store
instructions into single 64-bit LD/SD instructions when possible.
Default alignment is 8, it also provide zilsd-4byte-align feature for
looser condition.

Related work: https://reviews.llvm.org/D144002

---------

Co-authored-by: Copilot <[email protected]>
Priyanshu3820 pushed a commit to Priyanshu3820/llvm-project that referenced this pull request Nov 26, 2025
This commit implements a complete load/store optimization pass for the
RISC-V Zilsd extension, which combines pairs of 32-bit load/store
instructions into single 64-bit LD/SD instructions when possible.
Default alignment is 8, it also provide zilsd-4byte-align feature for
looser condition.

Related work: https://reviews.llvm.org/D144002

---------

Co-authored-by: Copilot <[email protected]>
augusto2112 pushed a commit to augusto2112/llvm-project that referenced this pull request Dec 3, 2025
This commit implements a complete load/store optimization pass for the
RISC-V Zilsd extension, which combines pairs of 32-bit load/store
instructions into single 64-bit LD/SD instructions when possible.
Default alignment is 8, it also provide zilsd-4byte-align feature for
looser condition.

Related work: https://reviews.llvm.org/D144002

---------

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants