test/CodeGen/X86/shadow-stack.ll has the following machine verifier errors:
*** Bad machine code: Using a killed virtual register *** - function: bar - basic block: %bb.6 entry (0x7fdc81857818) - instruction: %3:gr64 = MOV64rm killed %2:gr64, 1, $noreg, 8, $noreg - operand 1: killed %2:gr64 *** Bad machine code: Using a killed virtual register *** - function: bar - basic block: %bb.6 entry (0x7fdc81857818) - instruction: $rsp = MOV64rm killed %2:gr64, 1, $noreg, 16, $noreg - operand 1: killed %2:gr64 *** Bad machine code: Virtual register killed in block, but needed live out. *** - function: bar - basic block: %bb.2 entry (0x7fdc818574f8) Virtual register %2 is used after the block.
The fix here is to only copy the machine operand's register without the
kill flags for all the instructions except the very last one of the
sequence.
I had to insert dummy PHIs in the test case to force the NoPHI function
property to be set to false. More on this here: https://llvm.org/PR38439