[llvm] [CFIInserter] Improve `CSRSavedLocation` struct. (PR #168869)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 11 07:54:52 PST 2025
================
@@ -277,10 +319,19 @@ void CFIInstrInserter::calculateOutgoingCFAInfo(MBBCFAInfo &MBBInfo) {
case MCCFIInstruction::OpValOffset:
break;
}
- if (CSRReg || CSROffset) {
- CSRSavedLocation Loc(CSRReg, CSROffset);
- auto [It, Inserted] = CSRLocMap.insert({CFI.getRegister(), Loc});
- if (!Inserted && It->second != Loc) {
+ assert((bool)CSRReg + (bool)CSROffset <= 1 &&
+ "A register can only be at an offset from CFA or in another "
+ "register, but not both!");
+ CSRSavedLocation CSRLoc;
+ if (CSRReg)
+ CSRLoc = CSRSavedLocation::createRegister(*CSRReg);
+ else if (CSROffset)
+ CSRLoc = CSRSavedLocation::createCFAOffset(*CSROffset);
+ if (CSRLoc.isValid()) {
----------------
preames wrote:
I would prefer we not add the Invalid state. The prior code didn't need it, your switch based code shouldn't either. Is there a strong reason this needs to exist?
https://github.com/llvm/llvm-project/pull/168869
More information about the llvm-commits
mailing list