fix the error that structure would be pushed twice
authorYang Rong <rong.r.yang@intel.com>
Tue, 5 Nov 2013 05:55:23 +0000 (13:55 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Wed, 6 Nov 2013 03:05:52 +0000 (11:05 +0800)
Signed-off-by: Yang Rong <rong.r.yang@intel.com>
Tested-by: Lu Guanqun <guanqun.lu@intel.com>
Reviewed-by: Lu Guanqun <guanqun.lu@intel.com>
backend/src/ir/lowering.cpp

index 6cccaf5..013878c 100644 (file)
@@ -233,8 +233,14 @@ namespace ir {
         const PushLocation argLocation(*fn, loadAddImm.argID, offset);
         if (inserted.contains(argLocation))
           continue;
+        Register pushed;
         const Register reg = load->getValue(valueID);
-        const Register pushed = fn->newRegister(family);
+        if (offset != 0) {
+            pushed = fn->newRegister(family);
+            this->appendPushedConstant(pushed, argLocation);
+        } else {
+            pushed = fn->getArg(loadAddImm.argID).reg;
+        }
 
         // TODO the MOV instruction can be most of the time avoided if the
         // register is never written. We must however support the register
@@ -243,7 +249,6 @@ namespace ir {
         const Instruction mov = ir::MOV(type, reg, pushed);
         mov.replace(load);
         dead.insert(load);
-        this->appendPushedConstant(pushed, argLocation);
       }
     }