[PATCH] D14563: [SelectionDAGBuilder] Make sure DemoteReg ends up in right reg-class in visitRet().

Jonas Paulsson via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 11 00:20:24 PST 2015


jonpa created this revision.
jonpa added a subscriber: llvm-commits.

The virtual register containing the address for returned value on
stack should in the DAG be represented with a CopyFromReg node and not
a Register node. Otherwise, InstrEmitter will not make sure that it
ends up in the right register class for the target instruction.
    
SystemZ needs this, because the reg class for address registers is a
subset of the general 64 bit register class.  
test/SystemZ/CodeGen/args-07.ll and args-04.ll updated to run with
-verify-machineinstrs.

Note: InstrEmitter will not check for proper regclass for a Register node, as it
does for a CopyFromReg. It seems that the Register nodes as they are handled
in InstrEmitter are intended for call / return phys reg operands which need to be
flagged as implicit. But since the DemoteReg is a virtual register, it therefore
seems it doesn't really need to be a Register node for any particular reason.


http://reviews.llvm.org/D14563

Files:
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  test/CodeGen/SystemZ/args-04.ll
  test/CodeGen/SystemZ/args-07.ll

Index: test/CodeGen/SystemZ/args-07.ll
===================================================================
--- test/CodeGen/SystemZ/args-07.ll
+++ test/CodeGen/SystemZ/args-07.ll
@@ -1,6 +1,6 @@
 ; Test multiple return values (LLVM ABI extension)
 ;
-; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
+; RUN: llc < %s -mtriple=s390x-linux-gnu -verify-machineinstrs| FileCheck %s
 
 ; Up to four integer return values fit into GPRs.
 define { i64, i64, i64, i64 } @f1() {
Index: test/CodeGen/SystemZ/args-04.ll
===================================================================
--- test/CodeGen/SystemZ/args-04.ll
+++ test/CodeGen/SystemZ/args-04.ll
@@ -1,7 +1,7 @@
 ; Test incoming GPR, FPR and stack arguments when no extension type is given.
 ; This type of argument is used for passing structures, etc.
 ;
-; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
+; RUN: llc < %s -mtriple=s390x-linux-gnu -verify-machineinstrs | FileCheck %s
 
 ; Do some arithmetic so that we can see the register being used.
 define i8 @f1(i8 %r2) {
Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1346,7 +1346,8 @@
     ComputeValueVTs(TLI, DL, PointerType::getUnqual(F->getReturnType()),
                     PtrValueVTs);
 
-    SDValue RetPtr = DAG.getRegister(DemoteReg, PtrValueVTs[0]);
+    SDValue RetPtr = DAG.getCopyFromReg(DAG.getEntryNode(), getCurSDLoc(),
+                                        DemoteReg, PtrValueVTs[0]);
     SDValue RetOp = getValue(I.getOperand(0));
 
     SmallVector<EVT, 4> ValueVTs;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14563.39885.patch
Type: text/x-patch
Size: 1704 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151111/27f12624/attachment.bin>


More information about the llvm-commits mailing list