[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:26:02 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) {
+ // `Op` literal value 0 to 31
+ Expr.push_back(dwarf::DW_OP_lit0 + Value);
+ } else {
+ // `Op` constant
Expr.push_back(dwarf::DW_OP_consts);
- Expr.append(buffer, buffer + encodeSLEB128(NumBytes, buffer));
- Expr.push_back((uint8_t)dwarf::DW_OP_plus);
- Comment << (NumBytes < 0 ? " - " : " + ") << std::abs(NumBytes);
+ appendLEB128<LEB128Sign::Signed>(Expr, Value);
}
+ return Expr.push_back(Op);
+}
- if (NumVGScaledBytes) {
- Expr.push_back((uint8_t)dwarf::DW_OP_consts);
- Expr.append(buffer, buffer + encodeSLEB128(NumVGScaledBytes, buffer));
-
- Expr.push_back((uint8_t)dwarf::DW_OP_bregx);
- Expr.append(buffer, buffer + encodeULEB128(VG, buffer));
- Expr.push_back(0);
-
- Expr.push_back((uint8_t)dwarf::DW_OP_mul);
- Expr.push_back((uint8_t)dwarf::DW_OP_plus);
+// Convenience function to create a DWARF expression for VG
+static void appendReadVGRegExpr(SmallVectorImpl<char> &Expr,
+ unsigned VGRegNum) {
----------------
MacDue wrote:
In my next patch, I will add `appendLoadIncomingVGExpr`. I think the more explicit name here makes the distinction more apparent.
https://github.com/llvm/llvm-project/pull/151677
More information about the llvm-commits
mailing list