[llvm] [AArch64][SVE] Tweak how SVE CFI expressions are emitted (PR #151677)

Benjamin Maxwell via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 02:24:22 PDT 2025


================
@@ -5861,33 +5861,41 @@ void AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
   }
 }
 
-// Convenience function to create a DWARF expression for
-//   Expr + NumBytes + NumVGScaledBytes * AArch64::VG
-static void appendVGScaledOffsetExpr(SmallVectorImpl<char> &Expr, int NumBytes,
-                                     int NumVGScaledBytes, unsigned VG,
-                                     llvm::raw_string_ostream &Comment) {
-  uint8_t buffer[16];
-
-  if (NumBytes) {
+// Convenience function to create a DWARF expression for `Op` Value.
+// This helper emits compact sequences for common cases.
+static void appendConstantExpr(SmallVectorImpl<char> &Expr, int64_t Value,
+                               uint8_t Op) {
+  // + -constant (<= 31)
+  if (Op == dwarf::DW_OP_plus && Value < 0 && -Value <= 31) {
+    Expr.push_back(dwarf::DW_OP_lit0 - Value);
+    Op = dwarf::DW_OP_minus;
+  } else if (Value >= 0 && Value <= 31) {
----------------
MacDue wrote:

Using `DW_OP_lit*` does not require the operation to be a plus 

https://github.com/llvm/llvm-project/pull/151677


More information about the llvm-commits mailing list