[LLVMbugs] [Bug 7982] New: Assertion fires when running TwoAddressInstructionPass more than once

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Aug 24 06:03:20 PDT 2010


           Summary: Assertion fires when running TwoAddressInstructionPass
                    more than once
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: gergo at complang.tuwien.ac.at
                CC: llvmbugs at cs.uiuc.edu

I am working on a backend (llc) pass that is to be run shortly before register
allocation. It uses, and makes some last-minute changes to, some of the
analyses used by register allocators. Thus, a number of passes must be run
twice: Once before my pass, then again between my pass and register allocation.
In particular, pass dependences force TwoAddressInstructionPass to run twice
(even if my pass says it will preserve the two-address information).

On the second run on some functions, TwoAddressInstructionPass aborts with this

llc: /<...>/TwoAddressInstructionPass.cpp:712:
llvm::MachineBasicBlock*, llvm::SmallPtrSet<llvm::MachineInstr*, 8u>&):
Assertion `SrcRegMap[NewReg] == DstReg && "Can't map to two src physical
registers!"' failed.

To reproduce, apply the following quick-and-dirty changes against trunk to
force TwoAddressInstructionPass to run twice:

Index: lib/CodeGen/LLVMTargetMachine.cpp
--- lib/CodeGen/LLVMTargetMachine.cpp    (revision 111910)
+++ lib/CodeGen/LLVMTargetMachine.cpp    (working copy)
@@ -387,6 +387,9 @@
   if (addPreRegAlloc(PM, OptLevel))
     printAndVerify(PM, "After PreRegAlloc passes");

+  extern FunctionPass *createTwoAddressInstructionPass();
+  PM.add(createTwoAddressInstructionPass());
   // Perform register allocation.
   printAndVerify(PM, "After Register Allocation");
Index: lib/CodeGen/TwoAddressInstructionPass.cpp
--- lib/CodeGen/TwoAddressInstructionPass.cpp    (revision 111910)
+++ lib/CodeGen/TwoAddressInstructionPass.cpp    (working copy)
@@ -1496,3 +1496,7 @@
   return true;
+FunctionPass *createTwoAddressInstructionPass() {
+  return new TwoAddressInstructionPass();

Then run:

> llc -march=x86 get_image.ll

on the attached bitcode file get_image.ll (derived from the MiBench suite's
susan benchmark). The second time it is run, TwoAddressInstructionPass will
abort with the above assertion. (The -march=x86 flag is needed for this to

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list