[llvm] [NFC] Reuse DwarfExpression fragment (PR #210181)

Eric Christopher via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 16 14:59:00 PDT 2026


https://github.com/echristo updated https://github.com/llvm/llvm-project/pull/210181

>From 062513ef6ebd77fd5d12fdeee639f61ce1f339b5 Mon Sep 17 00:00:00 2001
From: Eric Christopher <echristopher at nvidia.com>
Date: Thu, 16 Jul 2026 09:22:33 -0700
Subject: [PATCH] Reuse DwarfExpression fragment information since nothing
 changes it between the outside of the loop and the inside of the loop.

Tested via make check.

Assisted by AI.
---
 llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
index ef83a877ad37c..d23ab837afb6a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
@@ -325,17 +325,15 @@ bool DwarfExpression::addMachineRegExpression(const TargetRegisterInfo &TRI,
   // expression representing a value, rather than a location.
   if ((!isParameterValue() && !isMemoryLocation() && !HasComplexExpression) ||
       isEntryValue()) {
-    auto FragmentInfo = ExprCursor.getFragmentInfo();
     unsigned RegSize = 0;
     for (auto &Reg : DwarfRegs) {
       RegSize += Reg.SubRegSize;
       if (Reg.DwarfRegNo >= 0)
         addReg(Reg.DwarfRegNo, Reg.Comment);
-      if (FragmentInfo)
-        if (RegSize > FragmentInfo->SizeInBits)
-          // If the register is larger than the current fragment stop
-          // once the fragment is covered.
-          break;
+      if (Fragment && RegSize > Fragment->SizeInBits)
+        // If the register is larger than the current fragment stop
+        // once the fragment is covered.
+        break;
       addOpPiece(Reg.SubRegSize);
     }
 



More information about the llvm-commits mailing list