Index: llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp =================================================================== --- llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp +++ llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp @@ -376,8 +376,6 @@ EndIdx = MI.getNumOperands(); Idx < EndIdx; ++Idx) { MachineOperand &MO = MI.getOperand(Idx); - // Leave `undef` operands as is, StackMaps will rewrite them - // into a constant. if (!MO.isReg() || MO.isImplicit() || MO.isUndef()) continue; Register Reg = MO.getReg(); Index: llvm/lib/CodeGen/StackMaps.cpp =================================================================== --- llvm/lib/CodeGen/StackMaps.cpp +++ llvm/lib/CodeGen/StackMaps.cpp @@ -234,12 +234,6 @@ if (MOI->isImplicit()) return ++MOI; - if (MOI->isUndef()) { - // Record `undef` register as constant. Use same value as ISel uses. - Locs.emplace_back(Location::Constant, sizeof(int64_t), 0, 0xFEFEFEFE); - return ++MOI; - } - assert(Register::isPhysicalRegister(MOI->getReg()) && "Virtreg operands should have been rewritten before now."); const TargetRegisterClass *RC = TRI->getMinimalPhysRegClass(MOI->getReg()); Index: llvm/test/CodeGen/X86/stackmap-undef-operand-anyregcc.mir =================================================================== --- /dev/null +++ llvm/test/CodeGen/X86/stackmap-undef-operand-anyregcc.mir @@ -0,0 +1,61 @@ +# RUN: llc -mtriple=x86_64-apple-darwin -start-after=virtregrewriter -o - %s | FileCheck %s + +# Check there's no assertion for anyregcc with an undef operand to a stackmap. + +# CHECK: __LLVM_StackMaps: +# CHECK-NEXT: .byte 3 +# CHECK-NEXT: .byte 0 +# CHECK-NEXT: .short 0 +# CHECK-NEXT: .long 1 +# CHECK-NEXT: .long 0 +# CHECK-NEXT: .long 1 +# CHECK-NEXT: .quad _undef_anyregcc_patchpoint +# CHECK-NEXT: .quad 8 +# CHECK-NEXT: .quad 1 +# CHECK-NEXT: .quad 12 +# CHECK-NEXT: .long Ltmp0-_undef_anyregcc_patchpoint +# CHECK-NEXT: .short 0 +# CHECK-NEXT: .short 2 +# CHECK-NEXT: .byte 1 +# CHECK-NEXT: .byte 0 +# CHECK-NEXT: .short 8 +# CHECK-NEXT: .short 0 +# CHECK-NEXT: .short 0 +# CHECK-NEXT: .long 0 +# CHECK-NEXT: .byte 1 +# CHECK-NEXT: .byte 0 +# CHECK-NEXT: .short 8 +# CHECK-NEXT: .short 0 +# CHECK-NEXT: .short 0 +# CHECK-NEXT: .long 0 +# CHECK-NEXT: .p2align 3 +# CHECK-NEXT: .short 0 +# CHECK-NEXT: .short 2 +# CHECK-NEXT: .short 0 +# CHECK-NEXT: .byte 0 +# CHECK-NEXT: .byte 8 +# CHECK-NEXT: .short 7 +# CHECK-NEXT: .byte 0 +# CHECK-NEXT: .byte 8 +# CHECK-NEXT: .p2align 3 +--- +name: undef_anyregcc_patchpoint +tracksRegLiveness: true +frameInfo: + hasPatchPoint: true + hasCalls: true +fixedStack: + - { id: 0, type: default, offset: 72, size: 8, alignment: 8, stack-id: default, + isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +body: | + bb.0: + liveins: $rcx, $rdi, $rdx, $rsi, $r8, $r9 + + ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp + dead renamable $rax = MOV64rm %fixed-stack.0, 1, $noreg, 0, $noreg :: (load (s64) from %fixed-stack.0) + renamable $rax = PATCHPOINT 12, 15, 0, 1, 13, undef renamable $rax, csr_64_allregs, implicit-def dead early-clobber $r11, implicit-def $rsp, implicit-def $ssp + ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp + RET 0, $rax + +... Index: llvm/test/CodeGen/X86/statepoint-fixup-undef.mir =================================================================== --- llvm/test/CodeGen/X86/statepoint-fixup-undef.mir +++ llvm/test/CodeGen/X86/statepoint-fixup-undef.mir @@ -124,12 +124,11 @@ ; STACKMAP-NEXT: .byte 0 ; STACKMAP-NEXT: .short 0 ; STACKMAP-NEXT: .long 1 - ; STACKMAP-NEXT: .long 1 + ; STACKMAP-NEXT: .long 0 ; STACKMAP-NEXT: .long 1 ; STACKMAP-NEXT: .quad test_undef ; STACKMAP-NEXT: .quad 88 ; STACKMAP-NEXT: .quad 1 - ; STACKMAP-NEXT: .quad 4278124286 ; STACKMAP-NEXT: .quad 2 ; STACKMAP-NEXT: .long .Ltmp0-test_undef ; STACKMAP-NEXT: .short 0 @@ -182,10 +181,10 @@ ; STACKMAP-NEXT: .short 3 ; STACKMAP-NEXT: .short 0 ; STACKMAP-NEXT: .long 0 - ; This is entry we're looking for, reference to constant pool entry 0xFEFEFEFE - ; STACKMAP-NEXT: .byte 5 + ; This is entry we're looking for + ; STACKMAP-NEXT: .byte 1 ; STACKMAP-NEXT: .byte 0 - ; STACKMAP-NEXT: .short 8 + ; STACKMAP-NEXT: .short 4 ; STACKMAP-NEXT: .short 0 ; STACKMAP-NEXT: .short 0 ; STACKMAP-NEXT: .long 0