@@ -2008,8 +2008,17 @@ void SelectionDAGBuilder::visitInvoke(const InvokeInst &I) {
2008
2008
if (isa<InlineAsm>(Callee))
2009
2009
visitInlineAsm (&I);
2010
2010
else if (Fn && Fn->isIntrinsic ()) {
2011
- assert (Fn->getIntrinsicID () == Intrinsic::donothing);
2012
- // Ignore invokes to @llvm.donothing: jump directly to the next BB.
2011
+ switch (Fn->getIntrinsicID ()) {
2012
+ default :
2013
+ llvm_unreachable (" Cannot invoke this intrinsic" );
2014
+ case Intrinsic::donothing:
2015
+ // Ignore invokes to @llvm.donothing: jump directly to the next BB.
2016
+ break ;
2017
+ case Intrinsic::experimental_patchpoint_void:
2018
+ case Intrinsic::experimental_patchpoint_i64:
2019
+ visitPatchpoint (&I, LandingPad);
2020
+ break ;
2021
+ }
2013
2022
} else
2014
2023
LowerCallTo (&I, getValue (Callee), false , LandingPad);
2015
2024
@@ -5429,7 +5438,7 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
5429
5438
}
5430
5439
case Intrinsic::experimental_patchpoint_void:
5431
5440
case Intrinsic::experimental_patchpoint_i64: {
5432
- visitPatchpoint (I);
5441
+ visitPatchpoint (& I);
5433
5442
return nullptr ;
5434
5443
}
5435
5444
}
@@ -6786,18 +6795,18 @@ void SelectionDAGBuilder::visitVACopy(const CallInst &I) {
6786
6795
// / convention or require stack pointer adjustment. Only a subset of the
6787
6796
// / intrinsic's operands need to participate in the calling convention.
6788
6797
std::pair<SDValue, SDValue>
6789
- SelectionDAGBuilder::LowerCallOperands ( const CallInst &CI , unsigned ArgIdx,
6798
+ SelectionDAGBuilder::lowerCallOperands (ImmutableCallSite CS , unsigned ArgIdx,
6790
6799
unsigned NumArgs, SDValue Callee,
6791
- bool useVoidTy) {
6800
+ bool UseVoidTy,
6801
+ MachineBasicBlock *LandingPad) {
6792
6802
TargetLowering::ArgListTy Args;
6793
6803
Args.reserve (NumArgs);
6794
6804
6795
6805
// Populate the argument list.
6796
6806
// Attributes for args start at offset 1, after the return attribute.
6797
- ImmutableCallSite CS (&CI);
6798
6807
for (unsigned ArgI = ArgIdx, ArgE = ArgIdx + NumArgs, AttrI = ArgIdx + 1 ;
6799
6808
ArgI != ArgE; ++ArgI) {
6800
- const Value *V = CI. getOperand (ArgI);
6809
+ const Value *V = CS-> getOperand (ArgI);
6801
6810
6802
6811
assert (!V->getType ()->isEmptyTy () && " Empty type passed to intrinsic." );
6803
6812
@@ -6808,13 +6817,13 @@ SelectionDAGBuilder::LowerCallOperands(const CallInst &CI, unsigned ArgIdx,
6808
6817
Args.push_back (Entry);
6809
6818
}
6810
6819
6811
- Type *retTy = useVoidTy ? Type::getVoidTy (*DAG.getContext ()) : CI. getType ();
6820
+ Type *retTy = UseVoidTy ? Type::getVoidTy (*DAG.getContext ()) : CS-> getType ();
6812
6821
TargetLowering::CallLoweringInfo CLI (DAG);
6813
6822
CLI.setDebugLoc (getCurSDLoc ()).setChain (getRoot ())
6814
- .setCallee (CI .getCallingConv (), retTy, Callee, std::move (Args), NumArgs)
6815
- .setDiscardResult (!CI. use_empty ());
6823
+ .setCallee (CS .getCallingConv (), retTy, Callee, std::move (Args), NumArgs)
6824
+ .setDiscardResult (CS-> use_empty ());
6816
6825
6817
- return lowerInvokable (CLI, nullptr );
6826
+ return lowerInvokable (CLI, LandingPad );
6818
6827
}
6819
6828
6820
6829
// / \brief Add a stack map intrinsic call's live variable operands to a stackmap
@@ -6834,11 +6843,11 @@ SelectionDAGBuilder::LowerCallOperands(const CallInst &CI, unsigned ArgIdx,
6834
6843
// / assumption made by the llvm.gcroot intrinsic). If the alloca's location were
6835
6844
// / only available in a register, then the runtime would need to trap when
6836
6845
// / execution reaches the StackMap in order to read the alloca's location.
6837
- static void addStackMapLiveVars (const CallInst &CI , unsigned StartIdx,
6846
+ static void addStackMapLiveVars (ImmutableCallSite CS , unsigned StartIdx,
6838
6847
SmallVectorImpl<SDValue> &Ops,
6839
6848
SelectionDAGBuilder &Builder) {
6840
- for (unsigned i = StartIdx, e = CI. getNumArgOperands (); i != e; ++i) {
6841
- SDValue OpVal = Builder.getValue (CI. getArgOperand (i));
6849
+ for (unsigned i = StartIdx, e = CS. arg_size (); i != e; ++i) {
6850
+ SDValue OpVal = Builder.getValue (CS. getArgument (i));
6842
6851
if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(OpVal)) {
6843
6852
Ops.push_back (
6844
6853
Builder.DAG .getTargetConstant (StackMaps::ConstantOp, MVT::i64));
@@ -6889,7 +6898,7 @@ void SelectionDAGBuilder::visitStackmap(const CallInst &CI) {
6889
6898
cast<ConstantSDNode>(NBytesVal)->getZExtValue (), MVT::i32));
6890
6899
6891
6900
// Push live variables for the stack map.
6892
- addStackMapLiveVars (CI, 2 , Ops, *this );
6901
+ addStackMapLiveVars (& CI, 2 , Ops, *this );
6893
6902
6894
6903
// We are not pushing any register mask info here on the operands list,
6895
6904
// because the stackmap doesn't clobber anything.
@@ -6916,54 +6925,55 @@ void SelectionDAGBuilder::visitStackmap(const CallInst &CI) {
6916
6925
}
6917
6926
6918
6927
// / \brief Lower llvm.experimental.patchpoint directly to its target opcode.
6919
- void SelectionDAGBuilder::visitPatchpoint (const CallInst &CI) {
6928
+ void SelectionDAGBuilder::visitPatchpoint (ImmutableCallSite CS,
6929
+ MachineBasicBlock *LandingPad) {
6920
6930
// void|i64 @llvm.experimental.patchpoint.void|i64(i64 <id>,
6921
6931
// i32 <numBytes>,
6922
6932
// i8* <target>,
6923
6933
// i32 <numArgs>,
6924
6934
// [Args...],
6925
6935
// [live variables...])
6926
6936
6927
- CallingConv::ID CC = CI .getCallingConv ();
6928
- bool isAnyRegCC = CC == CallingConv::AnyReg;
6929
- bool hasDef = !CI. getType ()->isVoidTy ();
6930
- SDValue Callee = getValue (CI. getOperand (2 )); // <target>
6937
+ CallingConv::ID CC = CS .getCallingConv ();
6938
+ bool IsAnyRegCC = CC == CallingConv::AnyReg;
6939
+ bool HasDef = !CS-> getType ()->isVoidTy ();
6940
+ SDValue Callee = getValue (CS-> getOperand (2 )); // <target>
6931
6941
6932
6942
// Get the real number of arguments participating in the call <numArgs>
6933
- SDValue NArgVal = getValue (CI. getArgOperand (PatchPointOpers::NArgPos));
6943
+ SDValue NArgVal = getValue (CS. getArgument (PatchPointOpers::NArgPos));
6934
6944
unsigned NumArgs = cast<ConstantSDNode>(NArgVal)->getZExtValue ();
6935
6945
6936
6946
// Skip the four meta args: <id>, <numNopBytes>, <target>, <numArgs>
6937
6947
// Intrinsics include all meta-operands up to but not including CC.
6938
6948
unsigned NumMetaOpers = PatchPointOpers::CCPos;
6939
- assert (CI. getNumArgOperands () >= NumMetaOpers + NumArgs &&
6949
+ assert (CS. arg_size () >= NumMetaOpers + NumArgs &&
6940
6950
" Not enough arguments provided to the patchpoint intrinsic" );
6941
6951
6942
6952
// For AnyRegCC the arguments are lowered later on manually.
6943
- unsigned NumCallArgs = isAnyRegCC ? 0 : NumArgs;
6953
+ unsigned NumCallArgs = IsAnyRegCC ? 0 : NumArgs;
6944
6954
std::pair<SDValue, SDValue> Result =
6945
- LowerCallOperands (CI, NumMetaOpers, NumCallArgs, Callee, isAnyRegCC);
6955
+ lowerCallOperands (CS, NumMetaOpers, NumCallArgs, Callee, IsAnyRegCC,
6956
+ LandingPad);
6946
6957
6947
- SDValue Chain = Result.second ;
6948
- SDNode *CallEnd = Chain.getNode ();
6949
- if (hasDef && (CallEnd->getOpcode () == ISD::CopyFromReg))
6958
+ SDNode *CallEnd = Result.second .getNode ();
6959
+ if (HasDef && (CallEnd->getOpcode () == ISD::CopyFromReg))
6950
6960
CallEnd = CallEnd->getOperand (0 ).getNode ();
6951
6961
6952
6962
// / Get a call instruction from the call sequence chain.
6953
6963
// / Tail calls are not allowed.
6954
6964
assert (CallEnd->getOpcode () == ISD::CALLSEQ_END &&
6955
6965
" Expected a callseq node." );
6956
6966
SDNode *Call = CallEnd->getOperand (0 ).getNode ();
6957
- bool hasGlue = Call->getGluedNode ();
6967
+ bool HasGlue = Call->getGluedNode ();
6958
6968
6959
6969
// Replace the target specific call node with the patchable intrinsic.
6960
6970
SmallVector<SDValue, 8 > Ops;
6961
6971
6962
6972
// Add the <id> and <numBytes> constants.
6963
- SDValue IDVal = getValue (CI. getOperand (PatchPointOpers::IDPos));
6973
+ SDValue IDVal = getValue (CS-> getOperand (PatchPointOpers::IDPos));
6964
6974
Ops.push_back (DAG.getTargetConstant (
6965
6975
cast<ConstantSDNode>(IDVal)->getZExtValue (), MVT::i64));
6966
- SDValue NBytesVal = getValue (CI. getOperand (PatchPointOpers::NBytesPos));
6976
+ SDValue NBytesVal = getValue (CS-> getOperand (PatchPointOpers::NBytesPos));
6967
6977
Ops.push_back (DAG.getTargetConstant (
6968
6978
cast<ConstantSDNode>(NBytesVal)->getZExtValue (), MVT::i32));
6969
6979
@@ -6976,29 +6986,29 @@ void SelectionDAGBuilder::visitPatchpoint(const CallInst &CI) {
6976
6986
// Adjust <numArgs> to account for any arguments that have been passed on the
6977
6987
// stack instead.
6978
6988
// Call Node: Chain, Target, {Args}, RegMask, [Glue]
6979
- unsigned NumCallRegArgs = Call->getNumOperands () - (hasGlue ? 4 : 3 );
6980
- NumCallRegArgs = isAnyRegCC ? NumArgs : NumCallRegArgs;
6989
+ unsigned NumCallRegArgs = Call->getNumOperands () - (HasGlue ? 4 : 3 );
6990
+ NumCallRegArgs = IsAnyRegCC ? NumArgs : NumCallRegArgs;
6981
6991
Ops.push_back (DAG.getTargetConstant (NumCallRegArgs, MVT::i32));
6982
6992
6983
6993
// Add the calling convention
6984
6994
Ops.push_back (DAG.getTargetConstant ((unsigned )CC, MVT::i32));
6985
6995
6986
6996
// Add the arguments we omitted previously. The register allocator should
6987
6997
// place these in any free register.
6988
- if (isAnyRegCC )
6998
+ if (IsAnyRegCC )
6989
6999
for (unsigned i = NumMetaOpers, e = NumMetaOpers + NumArgs; i != e; ++i)
6990
- Ops.push_back (getValue (CI. getArgOperand (i)));
7000
+ Ops.push_back (getValue (CS. getArgument (i)));
6991
7001
6992
7002
// Push the arguments from the call instruction up to the register mask.
6993
- SDNode::op_iterator e = hasGlue ? Call->op_end ()-2 : Call->op_end ()-1 ;
7003
+ SDNode::op_iterator e = HasGlue ? Call->op_end ()-2 : Call->op_end ()-1 ;
6994
7004
for (SDNode::op_iterator i = Call->op_begin ()+2 ; i != e; ++i)
6995
7005
Ops.push_back (*i);
6996
7006
6997
7007
// Push live variables for the stack map.
6998
- addStackMapLiveVars (CI , NumMetaOpers + NumArgs, Ops, *this );
7008
+ addStackMapLiveVars (CS , NumMetaOpers + NumArgs, Ops, *this );
6999
7009
7000
7010
// Push the register mask info.
7001
- if (hasGlue )
7011
+ if (HasGlue )
7002
7012
Ops.push_back (*(Call->op_end ()-2 ));
7003
7013
else
7004
7014
Ops.push_back (*(Call->op_end ()-1 ));
@@ -7008,15 +7018,15 @@ void SelectionDAGBuilder::visitPatchpoint(const CallInst &CI) {
7008
7018
Ops.push_back (*(Call->op_begin ()));
7009
7019
7010
7020
// Push the glue flag (last operand).
7011
- if (hasGlue )
7021
+ if (HasGlue )
7012
7022
Ops.push_back (*(Call->op_end ()-1 ));
7013
7023
7014
7024
SDVTList NodeTys;
7015
- if (isAnyRegCC && hasDef ) {
7025
+ if (IsAnyRegCC && HasDef ) {
7016
7026
// Create the return types based on the intrinsic definition
7017
7027
const TargetLowering &TLI = DAG.getTargetLoweringInfo ();
7018
7028
SmallVector<EVT, 3 > ValueVTs;
7019
- ComputeValueVTs (TLI, CI. getType (), ValueVTs);
7029
+ ComputeValueVTs (TLI, CS-> getType (), ValueVTs);
7020
7030
assert (ValueVTs.size () == 1 && " Expected only one return value type." );
7021
7031
7022
7032
// There is always a chain and a glue type at the end
@@ -7031,18 +7041,18 @@ void SelectionDAGBuilder::visitPatchpoint(const CallInst &CI) {
7031
7041
getCurSDLoc (), NodeTys, Ops);
7032
7042
7033
7043
// Update the NodeMap.
7034
- if (hasDef ) {
7035
- if (isAnyRegCC )
7036
- setValue (&CI , SDValue (MN, 0 ));
7044
+ if (HasDef ) {
7045
+ if (IsAnyRegCC )
7046
+ setValue (CS. getInstruction () , SDValue (MN, 0 ));
7037
7047
else
7038
- setValue (&CI , Result.first );
7048
+ setValue (CS. getInstruction () , Result.first );
7039
7049
}
7040
7050
7041
7051
// Fixup the consumers of the intrinsic. The chain and glue may be used in the
7042
7052
// call sequence. Furthermore the location of the chain and glue can change
7043
7053
// when the AnyReg calling convention is used and the intrinsic returns a
7044
7054
// value.
7045
- if (isAnyRegCC && hasDef ) {
7055
+ if (IsAnyRegCC && HasDef ) {
7046
7056
SDValue From[] = {SDValue (Call, 0 ), SDValue (Call, 1 )};
7047
7057
SDValue To[] = {SDValue (MN, 1 ), SDValue (MN, 2 )};
7048
7058
DAG.ReplaceAllUsesOfValuesWith (From, To, 2 );
0 commit comments