Index: include/llvm/CodeGen/GCStrategy.h =================================================================== --- include/llvm/CodeGen/GCStrategy.h +++ include/llvm/CodeGen/GCStrategy.h @@ -76,8 +76,6 @@ bool CustomReadBarriers; ///< Default is to insert loads. bool CustomWriteBarriers; ///< Default is to insert stores. bool CustomRoots; ///< Default is to pass through to backend. - bool CustomSafePoints; ///< Default is to use NeededSafePoints - ///< to find safe points. bool InitRoots; ///< If set, roots are nulled during lowering. bool UsesMetadata; ///< If set, backend must emit metadata tables. @@ -124,7 +122,7 @@ /// True if safe points of any kind are required. By default, none are /// recorded. bool needsSafePoints() const { - return CustomSafePoints || NeededSafePoints != 0; + return NeededSafePoints != 0; } /// True if the given kind of safe point is required. By default, none are @@ -137,10 +135,6 @@ /// stack map. If true, then performCustomLowering must delete them. bool customRoots() const { return CustomRoots; } - /// By default, the GC analysis will find safe points according to - /// NeededSafePoints. If true, then findCustomSafePoints must create them. - bool customSafePoints() const { return CustomSafePoints; } - /// If set, gcroot intrinsics should initialize their allocas to null /// before the first use. This is necessary for most GCs and is enabled by /// default. @@ -170,14 +164,6 @@ llvm_unreachable("GCStrategy subclass specified a configuration which" "requires a custom lowering without providing one"); } - ///@} - /// Called if customSafepoints returns true, used only by gc.root - /// implementations. - virtual bool findCustomSafePoints(GCFunctionInfo& FI, MachineFunction& MF) { - llvm_unreachable("GCStrategy subclass specified a configuration which" - "requests custom safepoint identification without" - "providing an implementation for such"); - } }; /// Subclasses of GCStrategy are made available for use during compilation by Index: lib/CodeGen/ErlangGC.cpp =================================================================== --- lib/CodeGen/ErlangGC.cpp +++ lib/CodeGen/ErlangGC.cpp @@ -28,12 +28,8 @@ namespace { class ErlangGC : public GCStrategy { - MCSymbol *InsertLabel(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MI, - DebugLoc DL) const; public: ErlangGC(); - bool findCustomSafePoints(GCFunctionInfo &FI, MachineFunction &MF) override; }; } @@ -48,35 +44,4 @@ NeededSafePoints = 1 << GC::PostCall; UsesMetadata = true; CustomRoots = false; - CustomSafePoints = true; -} - -MCSymbol *ErlangGC::InsertLabel(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MI, - DebugLoc DL) const { - const TargetInstrInfo *TII = MBB.getParent()->getSubtarget().getInstrInfo(); - MCSymbol *Label = MBB.getParent()->getContext().CreateTempSymbol(); - BuildMI(MBB, MI, DL, TII->get(TargetOpcode::GC_LABEL)).addSym(Label); - return Label; -} - -bool ErlangGC::findCustomSafePoints(GCFunctionInfo &FI, MachineFunction &MF) { - for (MachineFunction::iterator BBI = MF.begin(), BBE = MF.end(); BBI != BBE; - ++BBI) - for (MachineBasicBlock::iterator MI = BBI->begin(), ME = BBI->end(); - MI != ME; ++MI) - - if (MI->getDesc().isCall()) { - - // Do not treat tail call sites as safe points. - if (MI->getDesc().isTerminator()) - continue; - - /* Code copied from VisitCallPoint(...) */ - MachineBasicBlock::iterator RAI = MI; ++RAI; - MCSymbol* Label = InsertLabel(*MI->getParent(), RAI, MI->getDebugLoc()); - FI.addSafePoint(GC::PostCall, Label, MI->getDebugLoc()); - } - - return false; } Index: lib/CodeGen/GCRootLowering.cpp =================================================================== --- lib/CodeGen/GCRootLowering.cpp +++ lib/CodeGen/GCRootLowering.cpp @@ -329,8 +329,15 @@ ++BBI) for (MachineBasicBlock::iterator MI = BBI->begin(), ME = BBI->end(); MI != ME; ++MI) - if (MI->isCall()) + if (MI->isCall()) { + // Do not treat tail or sibling call sites as safe points. This is + // legal since any arguments passed to the callee which live in the + // remnants of the callers frame will be owned and updated by the + // callee if required. + if (MI->isTerminator()) + continue; VisitCallPoint(MI); + } } void GCMachineCodeAnalysis::FindStackOffsets(MachineFunction &MF) { @@ -366,11 +373,7 @@ FI->setFrameSize(MF.getFrameInfo()->getStackSize()); // Find all safe points. - if (FI->getStrategy().customSafePoints()) { - FI->getStrategy().findCustomSafePoints(*FI, MF); - } else { - FindSafePoints(MF); - } + FindSafePoints(MF); // Find the stack offsets for all roots. FindStackOffsets(MF); Index: lib/CodeGen/GCStrategy.cpp =================================================================== --- lib/CodeGen/GCStrategy.cpp +++ lib/CodeGen/GCStrategy.cpp @@ -18,5 +18,5 @@ GCStrategy::GCStrategy() : UseStatepoints(false), NeededSafePoints(0), CustomReadBarriers(false), - CustomWriteBarriers(false), CustomRoots(false), CustomSafePoints(false), + CustomWriteBarriers(false), CustomRoots(false), InitRoots(true), UsesMetadata(false) {} Index: lib/CodeGen/StatepointExampleGC.cpp =================================================================== --- lib/CodeGen/StatepointExampleGC.cpp +++ lib/CodeGen/StatepointExampleGC.cpp @@ -33,7 +33,6 @@ NeededSafePoints = 0; UsesMetadata = false; CustomRoots = false; - CustomSafePoints = false; } Optional isGCManagedPointer(const Value *V) const override { // Method is only valid on pointer typed values.