[clang] [llvm] [Clang] Add `__builtin_stack_address` (PR #148281)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 2 00:47:49 PDT 2025


================
@@ -2720,6 +2721,30 @@ static SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) {
       Align(std::min(PtrVT.getFixedSizeInBits(), VT.getFixedSizeInBits()) / 8));
 }
 
+static SDValue LowerSTACKADDRESS(SDValue Op, SelectionDAG &DAG,
+                                 const SparcSubtarget *Subtarget) {
+  SDValue Chain = Op.getOperand(0);
+  EVT VT = Op->getValueType(0);
+  SDLoc DL(Op);
+  unsigned OffsetToStackStart = 0;
+
+  unsigned SPReg = SP::O6;
+  SDValue SP = DAG.getCopyFromReg(Chain, DL, SPReg, VT);
+
+  // Unbias the stack pointer register.
+  OffsetToStackStart += Subtarget->getStackPointerBias();
----------------
nikic wrote:

```suggestion
  unsigned OffsetToStackStart = Subtarget->getStackPointerBias();
```
No need to initialize to 0 and then use += here...

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


More information about the llvm-commits mailing list