[clang] [llvm] [SPARC] Support reserving arbitrary general purpose registers (PR #74927)

via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 22 09:35:02 PST 2023


================
@@ -1125,6 +1130,10 @@ Register SparcTargetLowering::getRegisterByName(const char* RegName, LLT VT,
     .Case("g4", SP::G4).Case("g5", SP::G5).Case("g6", SP::G6).Case("g7", SP::G7)
     .Default(0);
 
+  const SparcRegisterInfo *TRI = Subtarget->getRegisterInfo();
+  if (!TRI->isReservedReg(MF, Reg))
+    Reg = 0;
----------------
koachan wrote:

The intention is to make explicit register references (e.g GCC-style `register int r asm("g1");`) to fail unless we also pass the corresponding `-ffixed` flags to reserve it (unless, of course, the target register is already marked as reserved by the ABI).

I've made a test case, but I am not sure how to put it in the .ll files since the expected result is a `report_fatal_error` crash... any idea how to test for this?

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


More information about the cfe-commits mailing list