[llvm-commits] [llvm] r76373 - in /llvm/trunk: lib/CodeGen/MachineInstr.cpp test/CodeGen/X86/2009-07-19-AsmExtraOperands.ll

Jakob Stoklund Olesen stoklund at 2pi.dk
Sun Jul 19 12:09:59 PDT 2009


Author: stoklund
Date: Sun Jul 19 14:09:59 2009
New Revision: 76373

URL: http://llvm.org/viewvc/llvm-project?rev=76373&view=rev
Log:
Fix http://llvm.org/bugs/show_bug.cgi?id=4583

Inline asm instructions may have additional <imp-def,kill> register operands.
These operands are not marked with a flag like the normal asm operands, so we
must not assert that there is a flag.

Added:
    llvm/trunk/test/CodeGen/X86/2009-07-19-AsmExtraOperands.ll
Modified:
    llvm/trunk/lib/CodeGen/MachineInstr.cpp

Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=76373&r1=76372&r2=76373&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Sun Jul 19 14:09:59 2009
@@ -732,7 +732,9 @@
     unsigned DefPart = 0;
     for (unsigned i = 1, e = getNumOperands(); i < e; ) {
       const MachineOperand &FMO = getOperand(i);
-      assert(FMO.isImm());
+      // After the normal asm operands there may be additional imp-def regs.
+      if (!FMO.isImm())
+        return false;
       // Skip over this def.
       unsigned NumOps = InlineAsm::getNumOperandRegisters(FMO.getImm());
       unsigned PrevDef = i + 1;
@@ -788,7 +790,9 @@
     unsigned FlagIdx, NumOps=0;
     for (FlagIdx = 1; FlagIdx < UseOpIdx; FlagIdx += NumOps+1) {
       const MachineOperand &UFMO = getOperand(FlagIdx);
-      assert(UFMO.isImm() && "Expecting flag operand on inline asm");
+      // After the normal asm operands there may be additional imp-def regs.
+      if (!UFMO.isImm())
+        return false;
       NumOps = InlineAsm::getNumOperandRegisters(UFMO.getImm());
       assert(NumOps < getNumOperands() && "Invalid inline asm flag");
       if (UseOpIdx < FlagIdx+NumOps+1)

Added: llvm/trunk/test/CodeGen/X86/2009-07-19-AsmExtraOperands.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-07-19-AsmExtraOperands.ll?rev=76373&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/2009-07-19-AsmExtraOperands.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2009-07-19-AsmExtraOperands.ll Sun Jul 19 14:09:59 2009
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s | llc -march=x86-64
+; PR4583
+
+define i32 @atomic_cmpset_long(i64* %dst, i64 %exp, i64 %src) nounwind ssp noredzone noimplicitfloat {
+entry:
+	%0 = call i8 asm sideeffect "\09lock ; \09\09\09cmpxchgq $2,$1 ;\09       sete\09$0 ;\09\091:\09\09\09\09# atomic_cmpset_long", "={ax},=*m,r,{ax},*m,~{memory},~{dirflag},~{fpsr},~{flags}"(i64* undef, i64 undef, i64 undef, i64* undef) nounwind		; <i8> [#uses=0]
+	br label %1
+
+; <label>:1		; preds = %entry
+	ret i32 undef
+}





More information about the llvm-commits mailing list