forked from OSchip/llvm-project
Fix null reference creation in SelectionDAG constructor.
Store TargetSelectionDAGInfo as a pointer instead of a reference: getSelectionDAGInfo() may not be implemented for certain backends (e.g. it's not currently implemented for R600). This bug is reported by UBSan. llvm-svn: 216129
This commit is contained in:
parent
b8478abd2e
commit
e229ec5bfc
|
@ -168,7 +168,7 @@ void checkForCycles(const SelectionDAG *DAG, bool force = false);
|
||||||
///
|
///
|
||||||
class SelectionDAG {
|
class SelectionDAG {
|
||||||
const TargetMachine &TM;
|
const TargetMachine &TM;
|
||||||
const TargetSelectionDAGInfo &TSI;
|
const TargetSelectionDAGInfo *TSI;
|
||||||
const TargetLowering *TLI;
|
const TargetLowering *TLI;
|
||||||
MachineFunction *MF;
|
MachineFunction *MF;
|
||||||
LLVMContext *Context;
|
LLVMContext *Context;
|
||||||
|
@ -279,7 +279,7 @@ public:
|
||||||
const TargetMachine &getTarget() const { return TM; }
|
const TargetMachine &getTarget() const { return TM; }
|
||||||
const TargetSubtargetInfo &getSubtarget() const { return MF->getSubtarget(); }
|
const TargetSubtargetInfo &getSubtarget() const { return MF->getSubtarget(); }
|
||||||
const TargetLowering &getTargetLoweringInfo() const { return *TLI; }
|
const TargetLowering &getTargetLoweringInfo() const { return *TLI; }
|
||||||
const TargetSelectionDAGInfo &getSelectionDAGInfo() const { return TSI; }
|
const TargetSelectionDAGInfo &getSelectionDAGInfo() const { return *TSI; }
|
||||||
LLVMContext *getContext() const {return Context; }
|
LLVMContext *getContext() const {return Context; }
|
||||||
|
|
||||||
/// viewGraph - Pop up a GraphViz/gv window with the DAG rendered using 'dot'.
|
/// viewGraph - Pop up a GraphViz/gv window with the DAG rendered using 'dot'.
|
||||||
|
|
|
@ -907,7 +907,7 @@ unsigned SelectionDAG::getEVTAlignment(EVT VT) const {
|
||||||
|
|
||||||
// EntryNode could meaningfully have debug info if we can find it...
|
// EntryNode could meaningfully have debug info if we can find it...
|
||||||
SelectionDAG::SelectionDAG(const TargetMachine &tm, CodeGenOpt::Level OL)
|
SelectionDAG::SelectionDAG(const TargetMachine &tm, CodeGenOpt::Level OL)
|
||||||
: TM(tm), TSI(*tm.getSubtargetImpl()->getSelectionDAGInfo()), TLI(nullptr),
|
: TM(tm), TSI(tm.getSubtargetImpl()->getSelectionDAGInfo()), TLI(nullptr),
|
||||||
OptLevel(OL),
|
OptLevel(OL),
|
||||||
EntryNode(ISD::EntryToken, 0, DebugLoc(), getVTList(MVT::Other)),
|
EntryNode(ISD::EntryToken, 0, DebugLoc(), getVTList(MVT::Other)),
|
||||||
Root(getEntryNode()), NewNodesMustHaveLegalTypes(false),
|
Root(getEntryNode()), NewNodesMustHaveLegalTypes(false),
|
||||||
|
@ -4228,9 +4228,8 @@ SDValue SelectionDAG::getMemcpy(SDValue Chain, SDLoc dl, SDValue Dst,
|
||||||
// Then check to see if we should lower the memcpy with target-specific
|
// Then check to see if we should lower the memcpy with target-specific
|
||||||
// code. If the target chooses to do this, this is the next best.
|
// code. If the target chooses to do this, this is the next best.
|
||||||
SDValue Result =
|
SDValue Result =
|
||||||
TSI.EmitTargetCodeForMemcpy(*this, dl, Chain, Dst, Src, Size, Align,
|
TSI->EmitTargetCodeForMemcpy(*this, dl, Chain, Dst, Src, Size, Align,
|
||||||
isVol, AlwaysInline,
|
isVol, AlwaysInline, DstPtrInfo, SrcPtrInfo);
|
||||||
DstPtrInfo, SrcPtrInfo);
|
|
||||||
if (Result.getNode())
|
if (Result.getNode())
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
|
@ -4296,9 +4295,8 @@ SDValue SelectionDAG::getMemmove(SDValue Chain, SDLoc dl, SDValue Dst,
|
||||||
|
|
||||||
// Then check to see if we should lower the memmove with target-specific
|
// Then check to see if we should lower the memmove with target-specific
|
||||||
// code. If the target chooses to do this, this is the next best.
|
// code. If the target chooses to do this, this is the next best.
|
||||||
SDValue Result =
|
SDValue Result = TSI->EmitTargetCodeForMemmove(
|
||||||
TSI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, isVol,
|
*this, dl, Chain, Dst, Src, Size, Align, isVol, DstPtrInfo, SrcPtrInfo);
|
||||||
DstPtrInfo, SrcPtrInfo);
|
|
||||||
if (Result.getNode())
|
if (Result.getNode())
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
|
@ -4351,9 +4349,8 @@ SDValue SelectionDAG::getMemset(SDValue Chain, SDLoc dl, SDValue Dst,
|
||||||
|
|
||||||
// Then check to see if we should lower the memset with target-specific
|
// Then check to see if we should lower the memset with target-specific
|
||||||
// code. If the target chooses to do this, this is the next best.
|
// code. If the target chooses to do this, this is the next best.
|
||||||
SDValue Result =
|
SDValue Result = TSI->EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src,
|
||||||
TSI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, isVol,
|
Size, Align, isVol, DstPtrInfo);
|
||||||
DstPtrInfo);
|
|
||||||
if (Result.getNode())
|
if (Result.getNode())
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue