mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-10 04:33:40 +00:00
PTX: Pass param name strings per const reference.
The copies caused use-after-free bugs on std::string implementations without COW (i.e. anything but libstdc++) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140679 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
adbf7b2c56
commit
8adae0c940
@ -225,7 +225,7 @@ SDValue PTXTargetLowering::
|
|||||||
|
|
||||||
unsigned ParamSize = Ins[i].VT.getStoreSizeInBits();
|
unsigned ParamSize = Ins[i].VT.getStoreSizeInBits();
|
||||||
unsigned Param = PM.addArgumentParam(ParamSize);
|
unsigned Param = PM.addArgumentParam(ParamSize);
|
||||||
std::string ParamName = PM.getParamName(Param);
|
const std::string &ParamName = PM.getParamName(Param);
|
||||||
SDValue ParamValue = DAG.getTargetExternalSymbol(ParamName.c_str(),
|
SDValue ParamValue = DAG.getTargetExternalSymbol(ParamName.c_str(),
|
||||||
MVT::Other);
|
MVT::Other);
|
||||||
SDValue ArgValue = DAG.getNode(PTXISD::LOAD_PARAM, dl, Ins[i].VT, Chain,
|
SDValue ArgValue = DAG.getNode(PTXISD::LOAD_PARAM, dl, Ins[i].VT, Chain,
|
||||||
@ -322,7 +322,7 @@ SDValue PTXTargetLowering::
|
|||||||
if (Outs.size() == 1) {
|
if (Outs.size() == 1) {
|
||||||
unsigned ParamSize = OutVals[0].getValueType().getSizeInBits();
|
unsigned ParamSize = OutVals[0].getValueType().getSizeInBits();
|
||||||
unsigned Param = PM.addReturnParam(ParamSize);
|
unsigned Param = PM.addReturnParam(ParamSize);
|
||||||
std::string ParamName = PM.getParamName(Param);
|
const std::string &ParamName = PM.getParamName(Param);
|
||||||
SDValue ParamValue = DAG.getTargetExternalSymbol(ParamName.c_str(),
|
SDValue ParamValue = DAG.getTargetExternalSymbol(ParamName.c_str(),
|
||||||
MVT::Other);
|
MVT::Other);
|
||||||
Chain = DAG.getNode(PTXISD::STORE_PARAM, dl, MVT::Other, Chain,
|
Chain = DAG.getNode(PTXISD::STORE_PARAM, dl, MVT::Other, Chain,
|
||||||
@ -419,7 +419,7 @@ PTXTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
|
|||||||
for (unsigned i = 0; i != OutVals.size(); ++i) {
|
for (unsigned i = 0; i != OutVals.size(); ++i) {
|
||||||
unsigned Size = OutVals[i].getValueType().getSizeInBits();
|
unsigned Size = OutVals[i].getValueType().getSizeInBits();
|
||||||
unsigned Param = PM.addLocalParam(Size);
|
unsigned Param = PM.addLocalParam(Size);
|
||||||
std::string ParamName = PM.getParamName(Param);
|
const std::string &ParamName = PM.getParamName(Param);
|
||||||
SDValue ParamValue = DAG.getTargetExternalSymbol(ParamName.c_str(),
|
SDValue ParamValue = DAG.getTargetExternalSymbol(ParamName.c_str(),
|
||||||
MVT::Other);
|
MVT::Other);
|
||||||
Chain = DAG.getNode(PTXISD::STORE_PARAM, dl, MVT::Other, Chain,
|
Chain = DAG.getNode(PTXISD::STORE_PARAM, dl, MVT::Other, Chain,
|
||||||
@ -433,7 +433,7 @@ PTXTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
|
|||||||
for (unsigned i = 0; i < Ins.size(); ++i) {
|
for (unsigned i = 0; i < Ins.size(); ++i) {
|
||||||
unsigned Size = Ins[i].VT.getStoreSizeInBits();
|
unsigned Size = Ins[i].VT.getStoreSizeInBits();
|
||||||
unsigned Param = PM.addLocalParam(Size);
|
unsigned Param = PM.addLocalParam(Size);
|
||||||
std::string ParamName = PM.getParamName(Param);
|
const std::string &ParamName = PM.getParamName(Param);
|
||||||
SDValue ParamValue = DAG.getTargetExternalSymbol(ParamName.c_str(),
|
SDValue ParamValue = DAG.getTargetExternalSymbol(ParamName.c_str(),
|
||||||
MVT::Other);
|
MVT::Other);
|
||||||
Ops[i+1] = ParamValue;
|
Ops[i+1] = ParamValue;
|
||||||
|
@ -67,15 +67,15 @@ public:
|
|||||||
unsigned addLocalParam(unsigned Size);
|
unsigned addLocalParam(unsigned Size);
|
||||||
|
|
||||||
/// getParamName - Returns the name of the parameter as a string.
|
/// getParamName - Returns the name of the parameter as a string.
|
||||||
std::string getParamName(unsigned Param) const {
|
const std::string &getParamName(unsigned Param) const {
|
||||||
assert(AllParams.count(Param) == 1 && "Param has not been defined!");
|
assert(AllParams.count(Param) == 1 && "Param has not been defined!");
|
||||||
return AllParams.lookup(Param).Name;
|
return AllParams.find(Param)->second.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getParamSize - Returns the size of the parameter in bits.
|
/// getParamSize - Returns the size of the parameter in bits.
|
||||||
unsigned getParamSize(unsigned Param) const {
|
unsigned getParamSize(unsigned Param) const {
|
||||||
assert(AllParams.count(Param) == 1 && "Param has not been defined!");
|
assert(AllParams.count(Param) == 1 && "Param has not been defined!");
|
||||||
return AllParams.lookup(Param).Size;
|
return AllParams.find(Param)->second.Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user