[llvm] r237166 - [Statepoints] Split the calling convention and statepoint flags operand to STATEPOINT into two separate operands.

Pat Gavlin pagavlin at microsoft.com
Tue May 12 12:50:20 PDT 2015


Author: pgavlin
Date: Tue May 12 14:50:19 2015
New Revision: 237166

URL: http://llvm.org/viewvc/llvm-project?rev=237166&view=rev
Log:
[Statepoints] Split the calling convention and statepoint flags operand to STATEPOINT into two separate operands.

Differential Revision: http://reviews.llvm.org/D9623

Modified:
    llvm/trunk/docs/Statepoints.rst
    llvm/trunk/include/llvm/CodeGen/StackMaps.h
    llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
    llvm/trunk/test/CodeGen/X86/statepoint-allocas.ll
    llvm/trunk/test/CodeGen/X86/statepoint-stackmap-format.ll

Modified: llvm/trunk/docs/Statepoints.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/Statepoints.rst?rev=237166&r1=237165&r2=237166&view=diff
==============================================================================
--- llvm/trunk/docs/Statepoints.rst (original)
+++ llvm/trunk/docs/Statepoints.rst Tue May 12 14:50:19 2015
@@ -483,6 +483,12 @@ the runtime or collector are provided vi
 
 Each statepoint generates the following Locations:
 
+* Constant which describes the calling convention of the call target. This
+  constant is a valid :ref:`calling convention identifier <callingconv>` for
+  the version of LLVM used to generate the stackmap. No additional compatibility
+  guarantees are made for this constant over what LLVM provides elsewhere w.r.t.
+  these identifiers.
+* Constant which describes the flags passed to the statepoint intrinsic
 * Constant which describes number of following deopt *Locations* (not
   operands)
 * Variable number of Locations, one for each deopt parameter listed in

Modified: llvm/trunk/include/llvm/CodeGen/StackMaps.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/StackMaps.h?rev=237166&r1=237165&r2=237166&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/StackMaps.h (original)
+++ llvm/trunk/include/llvm/CodeGen/StackMaps.h Tue May 12 14:50:19 2015
@@ -86,22 +86,33 @@ public:
 ///
 /// Statepoint operands take the form:
 ///   <num call arguments>, <call target>, [call arguments],
-///   <StackMaps::ConstantOp>, <flags>,
+///   <StackMaps::ConstantOp>, <calling convention>,
+///   <StackMaps::ConstantOp>, <statepoint flags>,
 ///   <StackMaps::ConstantOp>, <num other args>, [other args],
 ///   [gc values]
 class StatepointOpers {
 private:
+  // These values are aboolute offsets into the operands of the statepoint
+  // instruction.
   enum {
     NCallArgsPos = 0,
     CallTargetPos = 1
   };
 
+  // These values are relative offests from the start of the statepoint meta
+  // arguments (i.e. the end of the call arguments).
+  enum {
+    CCOffset = 1,
+    FlagsOffset = 3,
+    NumVMSArgsOffset = 5
+  };
+
 public:
   explicit StatepointOpers(const MachineInstr *MI):
     MI(MI) { }
 
   /// Get starting index of non call related arguments
-  /// (statepoint flags, vm state and gc state).
+  /// (calling convention, statepoint flags, vm state and gc state).
   unsigned getVarIdx() const {
     return MI->getOperand(NCallArgsPos).getImm() + 2;
   }
@@ -109,7 +120,7 @@ public:
   /// Returns the index of the operand containing the number of non-gc non-call
   /// arguments. 
   unsigned getNumVMSArgsIdx() const {
-    return getVarIdx() + 3;
+    return getVarIdx() + NumVMSArgsOffset;
   }
 
   /// Returns the number of non-gc non-call arguments attached to the

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp?rev=237166&r1=237165&r2=237166&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp Tue May 12 14:50:19 2015
@@ -38,6 +38,14 @@ STATISTIC(NumOfStatepoints, "Number of s
 STATISTIC(StatepointMaxSlotsRequired,
           "Maximum number of stack slots required for a singe statepoint");
 
+static void pushStackMapConstant(SmallVectorImpl<SDValue>& Ops,
+                                 SelectionDAGBuilder &Builder, uint64_t Value) {
+  SDLoc L = Builder.getCurSDLoc();
+  Ops.push_back(Builder.DAG.getTargetConstant(StackMaps::ConstantOp, L,
+                                              MVT::i64));
+  Ops.push_back(Builder.DAG.getTargetConstant(Value, L, MVT::i64));
+}
+
 void StatepointLoweringState::startNewStatepoint(SelectionDAGBuilder &Builder) {
   // Consistency check
   assert(PendingGCRelocateCalls.empty() &&
@@ -386,12 +394,7 @@ static void lowerIncomingStatepointValue
     // such in the stackmap.  This is required so that the consumer can
     // parse any internal format to the deopt state.  It also handles null
     // pointers and other constant pointers in GC states
-    Ops.push_back(Builder.DAG.getTargetConstant(StackMaps::ConstantOp,
-                                                Builder.getCurSDLoc(),
-                                                MVT::i64));
-    Ops.push_back(Builder.DAG.getTargetConstant(C->getSExtValue(),
-                                                Builder.getCurSDLoc(),
-                                                MVT::i64));
+    pushStackMapConstant(Ops, Builder, C->getSExtValue());
   } else if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(Incoming)) {
     // This handles allocas as arguments to the statepoint (this is only
     // really meaningful for a deopt value.  For GC, we'd be trying to
@@ -485,11 +488,7 @@ static void lowerStatepointMetaArgs(Smal
   // lowered.  Note that this is the number of *Values* not the
   // number of SDValues required to lower them.
   const int NumVMSArgs = StatepointSite.getNumTotalVMSArgs();
-  Ops.push_back( Builder.DAG.getTargetConstant(StackMaps::ConstantOp,
-                                               Builder.getCurSDLoc(),
-                                               MVT::i64));
-  Ops.push_back(Builder.DAG.getTargetConstant(NumVMSArgs, Builder.getCurSDLoc(),
-                                              MVT::i64));
+  pushStackMapConstant(Ops, Builder, NumVMSArgs);
 
   assert(NumVMSArgs + 1 == std::distance(StatepointSite.vm_state_begin(),
                                          StatepointSite.vm_state_end()));
@@ -662,21 +661,15 @@ void SelectionDAGBuilder::LowerStatepoin
     RegMaskIt = CallNode->op_end() - 1;
   Ops.insert(Ops.end(), CallNode->op_begin() + 2, RegMaskIt);
 
-  // Add a leading constant argument with the Flags and the calling convention
-  // masked together
-  CallingConv::ID CallConv = CS.getCallingConv();
+  // Add a constant argument for the calling convention
+  pushStackMapConstant(Ops, *this, CS.getCallingConv());
+
+  // Add a constant argument for the flags
   uint64_t Flags = cast<ConstantInt>(CS.getArgument(2))->getZExtValue();
   assert(
       ((Flags & ~(uint64_t)StatepointFlags::MaskAll) == 0)
           && "unknown flag used");
-  const int Shift = 1;
-  static_assert(
-      ((~(uint64_t)0 << Shift) & (uint64_t)StatepointFlags::MaskAll) == 0,
-      "shift width too small");
-  Ops.push_back(DAG.getTargetConstant(StackMaps::ConstantOp, getCurSDLoc(),
-                                      MVT::i64));
-  Ops.push_back(DAG.getTargetConstant(Flags | ((unsigned)CallConv << Shift),
-                                      getCurSDLoc(), MVT::i64));
+  pushStackMapConstant(Ops, *this, Flags);
 
   // Insert all vmstate and gcstate arguments
   Ops.insert(Ops.end(), LoweredMetaArgs.begin(), LoweredMetaArgs.end());

Modified: llvm/trunk/test/CodeGen/X86/statepoint-allocas.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/statepoint-allocas.ll?rev=237166&r1=237165&r2=237166&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/statepoint-allocas.ll (original)
+++ llvm/trunk/test/CodeGen/X86/statepoint-allocas.ll Tue May 12 14:50:19 2015
@@ -72,7 +72,12 @@ declare i32 @llvm.experimental.gc.statep
 ; The GC one
 ; CHECK: .long	.Ltmp1-test
 ; CHECK: .short	0
-; CHECK: .short	3
+; CHECK: .short	4
+; SmallConstant (0)
+; CHECK: .byte	4
+; CHECK: .byte	8
+; CHECK: .short	0
+; CHECK: .long	0
 ; SmallConstant (0)
 ; CHECK: .byte	4
 ; CHECK: .byte	8
@@ -96,7 +101,12 @@ declare i32 @llvm.experimental.gc.statep
 ; The Deopt one
 ; CHECK: .long	.Ltmp3-test2
 ; CHECK: .short	0
-; CHECK: .short	3
+; CHECK: .short	4
+; SmallConstant (0)
+; CHECK: .byte	4
+; CHECK: .byte	8
+; CHECK: .short	0
+; CHECK: .long	0
 ; SmallConstant (0)
 ; CHECK: .byte	4
 ; CHECK: .byte	8

Modified: llvm/trunk/test/CodeGen/X86/statepoint-stackmap-format.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/statepoint-stackmap-format.ll?rev=237166&r1=237165&r2=237166&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/statepoint-stackmap-format.ll (original)
+++ llvm/trunk/test/CodeGen/X86/statepoint-stackmap-format.ll Tue May 12 14:50:19 2015
@@ -97,7 +97,12 @@ declare i32 addrspace(1)* @llvm.experime
 ; Constant arguments
 ; CHECK: .long	.Ltmp1-test
 ; CHECK: .short	0
-; CHECK: .short	10
+; CHECK: .short	11
+; SmallConstant (0)
+; CHECK: .byte	4
+; CHECK: .byte	8
+; CHECK: .short	0
+; CHECK: .long	0
 ; SmallConstant (0)
 ; CHECK: .byte	4
 ; CHECK: .byte	8
@@ -166,7 +171,7 @@ declare i32 addrspace(1)* @llvm.experime
 ; Constant arguments
 ; CHECK: .long	.Ltmp3-test_derived_arg
 ; CHECK: .short	0
-; CHECK: .short	10
+; CHECK: .short	11
 ; SmallConstant (0)
 ; CHECK: .byte	4
 ; CHECK: .byte	8





More information about the llvm-commits mailing list