Skip to content

Commit 12c349d

Browse files
committed
Merging r168320: into 3.2 relase branch.
Handle mixed normal and early-clobber defs on inline asm. PR14376. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_32@168527 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 024e48b commit 12c349d

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/CodeGen/LiveInterval.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,16 @@ VNInfo *LiveInterval::createDeadDef(SlotIndex Def,
5959
return VNI;
6060
}
6161
if (SlotIndex::isSameInstr(Def, I->start)) {
62-
assert(I->start == Def && "Cannot insert def, already live");
63-
assert(I->valno->def == Def && "Inconsistent existing value def");
62+
assert(I->valno->def == I->start && "Inconsistent existing value def");
63+
64+
// It is possible to have both normal and early-clobber defs of the same
65+
// register on an instruction. It doesn't make a lot of sense, but it is
66+
// possible to specify in inline assembly.
67+
//
68+
// Just convert everything to early-clobber.
69+
Def = std::min(Def, I->start);
70+
if (Def != I->start)
71+
I->start = I->valno->def = Def;
6472
return I->valno;
6573
}
6674
assert(SlotIndex::isEarlierInstr(Def, I->start) && "Already live at def");

test/CodeGen/X86/inline-asm.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,10 @@ entry:
5252
%0 = call { i32, i32, i32, i32, i32 } asm sideeffect "", "=&r,=&r,=&r,=&r,=&q,r,~{ecx},~{memory},~{dirflag},~{fpsr},~{flags}"(i8* %h) nounwind
5353
ret void
5454
}
55+
56+
; Mix normal and EC defs of the same register.
57+
define i32 @pr14376() nounwind noinline {
58+
entry:
59+
%asm = tail call i32 asm sideeffect "", "={ax},i,~{eax},~{flags},~{rax}"(i64 61) nounwind
60+
ret i32 %asm
61+
}

0 commit comments

Comments
 (0)