[llvm] Fix stack layout for frames larger than 2gb (PR #84114)

Wesley Wiser via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 27 07:29:59 PDT 2024


================
@@ -538,30 +538,30 @@ class MCCFIInstruction {
 public:
   /// .cfi_def_cfa defines a rule for computing CFA as: take address from
   /// Register and add Offset to it.
-  static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int Offset,
-                                    SMLoc Loc = {}) {
+  static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register,
+                                    int64_t Offset, SMLoc Loc = {}) {
     return MCCFIInstruction(OpDefCfa, L, Register, Offset, Loc);
   }
 
   /// .cfi_def_cfa_register modifies a rule for computing CFA. From now
   /// on Register will be used instead of the old one. Offset remains the same.
   static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register,
                                                SMLoc Loc = {}) {
-    return MCCFIInstruction(OpDefCfaRegister, L, Register, 0, Loc);
+    return MCCFIInstruction(OpDefCfaRegister, L, Register, INT64_C(0), Loc);
----------------
wesleywiser wrote:

Without the explicit cast, gcc complains the call is ambiguous:

```
/home/wesley/llvm-project2/llvm/include/llvm/MC/MCDwarf.h:550:66: error: call of overloaded ‘MCCFIInstruction(llvm::MCCFIInstruction::OpType, llvm::MCSymbol*&, unsigned int&, int, llvm::SMLoc&)’ is ambiguous
  550 |     return MCCFIInstruction(OpDefCfaRegister, L, Register, 0, Loc);
      |                                                                  ^
/home/wesley/llvm-project2/llvm/include/llvm/MC/MCDwarf.h:526:3: note: candidate: ‘llvm::MCCFIInstruction::MCCFIInstruction(llvm::MCCFIInstruction::OpType, llvm::MCSymbol*, unsigned int, unsigned int, llvm::SMLoc)’
  526 |   MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R1, unsigned R2, SMLoc Loc)
      |   ^~~~~~~~~~~~~~~~
/home/wesley/llvm-project2/llvm/include/llvm/MC/MCDwarf.h:519:3: note: candidate: ‘llvm::MCCFIInstruction::MCCFIInstruction(llvm::MCCFIInstruction::OpType, llvm::MCSymbol*, unsigned int, int64_t, llvm::SMLoc, llvm::StringRef, llvm::StringRef)’
  519 |   MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int64_t O, SMLoc Loc,
      |   ^~~~~~~~~~~~~~~~
```

Is there a different way I should solve that?

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


More information about the llvm-commits mailing list