INLINEASM instructions use extra operands to carry flags. If a register operand is removed without removing the flag operand, then the flags will no longer make sense.
This patch tries to fix this by preventing the removal when a flag operand is present. I have no idea if this is the right thing to do here.
This fixes a crash for the following test. Previously the Live Variable analysis would remove the edx and eax clobber operands since they are redundant with the rax and rdx operands. But it did not remove their flag operands. A later pass expected a register operand to follow the flag operand, but it was no longer there.
This code was created with MS inline assembly which added clobbers for each instruction without knowing about sub/super registers.
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @test_mem = dso_local global [16 x i8] c"UUUUUUUUUUUUUUUU", align 16 ; Function Attrs: nounwind uwtable define dso_local void @foo() local_unnamed_addr { entry: tail call void asm sideeffect inteldialect "clc\0A\09cmpxchg8b $0\0A\09cmpxchg16b $1\0A\09clc", "=*m,=*m,~{eax},~{edx},~{flags},~{rax},~{rdx},~{dirflag},~{fpsr},~{flags}"([16 x i8]* nonnull @test_mem, [16 x i8]* nonnull @test_mem) #1 ret void }