From: Rafael Espindola Date: Wed, 22 Jun 2016 12:44:16 +0000 (+0000) Subject: Delete more dead code. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=117a36f8b116097868c9937ea6aaf72abca8f19b;p=llvm Delete more dead code. Found by gcc 6. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273402 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index a89bb07f052..a9c509809cb 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -281,7 +281,6 @@ class BitcodeReader : public GVMaterializer { public: std::error_code error(BitcodeError E, const Twine &Message); - std::error_code error(BitcodeError E); std::error_code error(const Twine &Message); BitcodeReader(MemoryBuffer *Buffer, LLVMContext &Context); @@ -506,16 +505,11 @@ class ModuleSummaryIndexBitcodeReader { std::string SourceFileName; public: - std::error_code error(BitcodeError E, const Twine &Message); - std::error_code error(BitcodeError E); std::error_code error(const Twine &Message); ModuleSummaryIndexBitcodeReader( MemoryBuffer *Buffer, DiagnosticHandlerFunction DiagnosticHandler, bool CheckGlobalValSummaryPresenceOnly = false); - ModuleSummaryIndexBitcodeReader( - DiagnosticHandlerFunction DiagnosticHandler, - bool CheckGlobalValSummaryPresenceOnly = false); ~ModuleSummaryIndexBitcodeReader() { freeState(); } void freeState(); @@ -559,21 +553,12 @@ static std::error_code error(const DiagnosticHandlerFunction &DiagnosticHandler, return EC; } -static std::error_code error(const DiagnosticHandlerFunction &DiagnosticHandler, - std::error_code EC) { - return error(DiagnosticHandler, EC, EC.message()); -} - static std::error_code error(LLVMContext &Context, std::error_code EC, const Twine &Message) { return error([&](const DiagnosticInfo &DI) { Context.diagnose(DI); }, EC, Message); } -static std::error_code error(LLVMContext &Context, std::error_code EC) { - return error(Context, EC, EC.message()); -} - static std::error_code error(LLVMContext &Context, const Twine &Message) { return error(Context, make_error_code(BitcodeError::CorruptedBitcode), Message); @@ -598,10 +583,6 @@ std::error_code BitcodeReader::error(const Twine &Message) { Message); } -std::error_code BitcodeReader::error(BitcodeError E) { - return ::error(Context, make_error_code(E)); -} - BitcodeReader::BitcodeReader(MemoryBuffer *Buffer, LLVMContext &Context) : Context(Context), Buffer(Buffer), ValueList(Context), MetadataList(Context) {} @@ -5737,32 +5718,17 @@ BitcodeReader::initLazyStream(std::unique_ptr Streamer) { return std::error_code(); } -std::error_code ModuleSummaryIndexBitcodeReader::error(BitcodeError E, - const Twine &Message) { - return ::error(DiagnosticHandler, make_error_code(E), Message); -} - std::error_code ModuleSummaryIndexBitcodeReader::error(const Twine &Message) { return ::error(DiagnosticHandler, make_error_code(BitcodeError::CorruptedBitcode), Message); } -std::error_code ModuleSummaryIndexBitcodeReader::error(BitcodeError E) { - return ::error(DiagnosticHandler, make_error_code(E)); -} - ModuleSummaryIndexBitcodeReader::ModuleSummaryIndexBitcodeReader( MemoryBuffer *Buffer, DiagnosticHandlerFunction DiagnosticHandler, bool CheckGlobalValSummaryPresenceOnly) : DiagnosticHandler(std::move(DiagnosticHandler)), Buffer(Buffer), CheckGlobalValSummaryPresenceOnly(CheckGlobalValSummaryPresenceOnly) {} -ModuleSummaryIndexBitcodeReader::ModuleSummaryIndexBitcodeReader( - DiagnosticHandlerFunction DiagnosticHandler, - bool CheckGlobalValSummaryPresenceOnly) - : DiagnosticHandler(std::move(DiagnosticHandler)), Buffer(nullptr), - CheckGlobalValSummaryPresenceOnly(CheckGlobalValSummaryPresenceOnly) {} - void ModuleSummaryIndexBitcodeReader::freeState() { Buffer = nullptr; } void ModuleSummaryIndexBitcodeReader::releaseBuffer() { Buffer.release(); } diff --git a/lib/Target/AArch64/AArch64AsmPrinter.cpp b/lib/Target/AArch64/AArch64AsmPrinter.cpp index dc69d9e4671..be3efea2255 100644 --- a/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -87,7 +87,6 @@ public: } private: - MachineLocation getDebugValueLocation(const MachineInstr *MI) const; void printOperand(const MachineInstr *MI, unsigned OpNum, raw_ostream &O); bool printAsmMRegister(const MachineOperand &MO, char Mode, raw_ostream &O); bool printAsmRegInClass(const MachineOperand &MO, @@ -133,19 +132,6 @@ void AArch64AsmPrinter::EmitEndOfAsmFile(Module &M) { } } -MachineLocation -AArch64AsmPrinter::getDebugValueLocation(const MachineInstr *MI) const { - MachineLocation Location; - assert(MI->getNumOperands() == 4 && "Invalid no. of machine operands!"); - // Frame address. Currently handles register +- offset only. - if (MI->getOperand(0).isReg() && MI->getOperand(1).isImm()) - Location.set(MI->getOperand(0).getReg(), MI->getOperand(1).getImm()); - else { - DEBUG(dbgs() << "DBG_VALUE instruction ignored! " << *MI << "\n"); - } - return Location; -} - void AArch64AsmPrinter::EmitLOHs() { SmallVector MCArgs; diff --git a/lib/Target/AArch64/AArch64PromoteConstant.cpp b/lib/Target/AArch64/AArch64PromoteConstant.cpp index e8e9947b078..b1e40510b2a 100644 --- a/lib/Target/AArch64/AArch64PromoteConstant.cpp +++ b/lib/Target/AArch64/AArch64PromoteConstant.cpp @@ -186,9 +186,6 @@ private: void insertDefinitions(Function &F, GlobalVariable &GV, InsertionPoints &InsertPts); - /// Sort the updates in a deterministic way. - void sortUpdates(SmallVectorImpl &Updates); - /// Do the constant promotion indicated by the Updates records, keeping track /// of globals in PromotionCache. void promoteConstants(Function &F, SmallVectorImpl &Updates, @@ -514,23 +511,6 @@ void AArch64PromoteConstant::insertDefinitions(Function &F, } } -void AArch64PromoteConstant::sortUpdates( - SmallVectorImpl &Updates) { - // The order the constants were inserted is deterministic (unlike their - // address). - SmallDenseMap InsertionOrder; - for (const auto &Record : Updates) - InsertionOrder.insert(std::make_pair(Record.C, InsertionOrder.size())); - - // This is already sorted by Instruction ordering in the function and operand - // number, which is a good first step. Now reorder by constant. - std::stable_sort( - Updates.begin(), Updates.end(), - [&InsertionOrder](const UpdateRecord &L, const UpdateRecord &R) { - return InsertionOrder.lookup(L.C) < InsertionOrder.lookup(R.C); - }); -} - void AArch64PromoteConstant::promoteConstants( Function &F, SmallVectorImpl &Updates, PromotionCacheTy &PromotionCache) { diff --git a/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp b/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp index 7d8e79bc63c..7b9ff8fa050 100644 --- a/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp +++ b/lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp @@ -154,24 +154,6 @@ public: SmallVectorImpl &Fixups, const MCSubtargetInfo &STI) const; - /// getSIMDShift64OpValue - Return the encoded value for the - // shift-by-immediate AdvSIMD instructions. - uint32_t getSIMDShift64OpValue(const MCInst &MI, unsigned OpIdx, - SmallVectorImpl &Fixups, - const MCSubtargetInfo &STI) const; - - uint32_t getSIMDShift64_32OpValue(const MCInst &MI, unsigned OpIdx, - SmallVectorImpl &Fixups, - const MCSubtargetInfo &STI) const; - - uint32_t getSIMDShift32OpValue(const MCInst &MI, unsigned OpIdx, - SmallVectorImpl &Fixups, - const MCSubtargetInfo &STI) const; - - uint32_t getSIMDShift16OpValue(const MCInst &MI, unsigned OpIdx, - SmallVectorImpl &Fixups, - const MCSubtargetInfo &STI) const; - unsigned fixMOVZ(const MCInst &MI, unsigned EncodedValue, const MCSubtargetInfo &STI) const; @@ -428,41 +410,6 @@ AArch64MCCodeEmitter::getVecShifterOpValue(const MCInst &MI, unsigned OpIdx, llvm_unreachable("Invalid value for vector shift amount!"); } -uint32_t -AArch64MCCodeEmitter::getSIMDShift64OpValue(const MCInst &MI, unsigned OpIdx, - SmallVectorImpl &Fixups, - const MCSubtargetInfo &STI) const { - const MCOperand &MO = MI.getOperand(OpIdx); - assert(MO.isImm() && "Expected an immediate value for the shift amount!"); - return 64 - (MO.getImm()); -} - -uint32_t AArch64MCCodeEmitter::getSIMDShift64_32OpValue( - const MCInst &MI, unsigned OpIdx, SmallVectorImpl &Fixups, - const MCSubtargetInfo &STI) const { - const MCOperand &MO = MI.getOperand(OpIdx); - assert(MO.isImm() && "Expected an immediate value for the shift amount!"); - return 64 - (MO.getImm() | 32); -} - -uint32_t -AArch64MCCodeEmitter::getSIMDShift32OpValue(const MCInst &MI, unsigned OpIdx, - SmallVectorImpl &Fixups, - const MCSubtargetInfo &STI) const { - const MCOperand &MO = MI.getOperand(OpIdx); - assert(MO.isImm() && "Expected an immediate value for the shift amount!"); - return 32 - (MO.getImm() | 16); -} - -uint32_t -AArch64MCCodeEmitter::getSIMDShift16OpValue(const MCInst &MI, unsigned OpIdx, - SmallVectorImpl &Fixups, - const MCSubtargetInfo &STI) const { - const MCOperand &MO = MI.getOperand(OpIdx); - assert(MO.isImm() && "Expected an immediate value for the shift amount!"); - return 16 - (MO.getImm() | 8); -} - /// getFixedPointScaleOpValue - Return the encoded value for the // FP-to-fixed-point scale factor. uint32_t AArch64MCCodeEmitter::getFixedPointScaleOpValue( diff --git a/lib/Target/BPF/BPFAsmPrinter.cpp b/lib/Target/BPF/BPFAsmPrinter.cpp index 10ec6587550..1078b065218 100644 --- a/lib/Target/BPF/BPFAsmPrinter.cpp +++ b/lib/Target/BPF/BPFAsmPrinter.cpp @@ -40,38 +40,10 @@ public: const char *getPassName() const override { return "BPF Assembly Printer"; } - void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O, - const char *Modifier = nullptr); void EmitInstruction(const MachineInstr *MI) override; }; } -void BPFAsmPrinter::printOperand(const MachineInstr *MI, int OpNum, - raw_ostream &O, const char *Modifier) { - const MachineOperand &MO = MI->getOperand(OpNum); - - switch (MO.getType()) { - case MachineOperand::MO_Register: - O << BPFInstPrinter::getRegisterName(MO.getReg()); - break; - - case MachineOperand::MO_Immediate: - O << MO.getImm(); - break; - - case MachineOperand::MO_MachineBasicBlock: - O << *MO.getMBB()->getSymbol(); - break; - - case MachineOperand::MO_GlobalAddress: - O << *getSymbol(MO.getGlobal()); - break; - - default: - llvm_unreachable(""); - } -} - void BPFAsmPrinter::EmitInstruction(const MachineInstr *MI) { BPFMCInstLower MCInstLowering(OutContext, *this); diff --git a/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/lib/Transforms/InstCombine/InstCombineAddSub.cpp index 9e3cf3041a0..dd4e7e27a96 100644 --- a/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -58,7 +58,6 @@ namespace { // operators inevitably call FAddendCoef's constructor which is not cheap. void operator=(const FAddendCoef &A); void operator+=(const FAddendCoef &A); - void operator-=(const FAddendCoef &A); void operator*=(const FAddendCoef &S); bool isOne() const { return isInt() && IntVal == 1; } @@ -279,27 +278,6 @@ void FAddendCoef::operator+=(const FAddendCoef &That) { T.add(createAPFloatFromInt(T.getSemantics(), That.IntVal), RndMode); } -void FAddendCoef::operator-=(const FAddendCoef &That) { - enum APFloat::roundingMode RndMode = APFloat::rmNearestTiesToEven; - if (isInt() == That.isInt()) { - if (isInt()) - IntVal -= That.IntVal; - else - getFpVal().subtract(That.getFpVal(), RndMode); - return; - } - - if (isInt()) { - const APFloat &T = That.getFpVal(); - convertToFpType(T.getSemantics()); - getFpVal().subtract(T, RndMode); - return; - } - - APFloat &T = getFpVal(); - T.subtract(createAPFloatFromInt(T.getSemantics(), IntVal), RndMode); -} - void FAddendCoef::operator*=(const FAddendCoef &That) { if (That.isOne()) return; diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 6b2df2a1d9d..df48897f2c7 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -99,8 +99,6 @@ private: Constant *getEmitFunctionFunc(); Constant *getEmitArcsFunc(); Constant *getSummaryInfoFunc(); - Constant *getDeleteWriteoutFunctionListFunc(); - Constant *getDeleteFlushFunctionListFunc(); Constant *getEndFileFunc(); // Create or retrieve an i32 state value that is used to represent the @@ -817,16 +815,6 @@ Constant *GCOVProfiler::getSummaryInfoFunc() { return M->getOrInsertFunction("llvm_gcda_summary_info", FTy); } -Constant *GCOVProfiler::getDeleteWriteoutFunctionListFunc() { - FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), false); - return M->getOrInsertFunction("llvm_delete_writeout_function_list", FTy); -} - -Constant *GCOVProfiler::getDeleteFlushFunctionListFunc() { - FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), false); - return M->getOrInsertFunction("llvm_delete_flush_function_list", FTy); -} - Constant *GCOVProfiler::getEndFileFunc() { FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), false); return M->getOrInsertFunction("llvm_gcda_end_file", FTy); diff --git a/lib/Transforms/Scalar/LoopInterchange.cpp b/lib/Transforms/Scalar/LoopInterchange.cpp index 6e74a733d11..5dc0de25971 100644 --- a/lib/Transforms/Scalar/LoopInterchange.cpp +++ b/lib/Transforms/Scalar/LoopInterchange.cpp @@ -403,11 +403,9 @@ public: private: void splitInnerLoopLatch(Instruction *); - void splitOuterLoopLatch(); void splitInnerLoopHeader(); bool adjustLoopLinks(); void adjustLoopPreheaders(); - void adjustOuterLoopPreheader(); bool adjustLoopBranches(); void updateIncomingBlock(BasicBlock *CurrBlock, BasicBlock *OldPred, BasicBlock *NewPred); @@ -1074,13 +1072,6 @@ void LoopInterchangeTransform::splitInnerLoopLatch(Instruction *Inc) { InnerLoopLatch = SplitBlock(InnerLoopLatchPred, Inc, DT, LI); } -void LoopInterchangeTransform::splitOuterLoopLatch() { - BasicBlock *OuterLoopLatch = OuterLoop->getLoopLatch(); - BasicBlock *OuterLatchLcssaPhiBlock = OuterLoopLatch; - OuterLoopLatch = SplitBlock(OuterLatchLcssaPhiBlock, - OuterLoopLatch->getFirstNonPHI(), DT, LI); -} - void LoopInterchangeTransform::splitInnerLoopHeader() { // Split the inner loop header out. Here make sure that the reduction PHI's @@ -1125,13 +1116,6 @@ static void moveBBContents(BasicBlock *FromBB, Instruction *InsertBefore) { FromBB->getTerminator()->getIterator()); } -void LoopInterchangeTransform::adjustOuterLoopPreheader() { - BasicBlock *OuterLoopPreHeader = OuterLoop->getLoopPreheader(); - BasicBlock *InnerPreHeader = InnerLoop->getLoopPreheader(); - - moveBBContents(OuterLoopPreHeader, InnerPreHeader->getTerminator()); -} - void LoopInterchangeTransform::updateIncomingBlock(BasicBlock *CurrBlock, BasicBlock *OldPred, BasicBlock *NewPred) { diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp index 7b95ac04b5f..2eade8cbe8e 100644 --- a/lib/Transforms/Utils/ValueMapper.cpp +++ b/lib/Transforms/Utils/ValueMapper.cpp @@ -144,20 +144,6 @@ public: /// (not an MDNode, or MDNode::isResolved() returns true). Metadata *mapMetadata(const Metadata *MD); - // Map LocalAsMetadata, which never gets memoized. - // - // If the referenced local is not mapped, the principled return is nullptr. - // However, optimization passes sometimes move metadata operands *before* the - // SSA values they reference. To prevent crashes in \a RemapInstruction(), - // return "!{}" when RF_IgnoreMissingLocals is not set. - // - // \note Adding a mapping for LocalAsMetadata is unsupported. Add a mapping - // to the value map for the SSA value in question instead. - // - // FIXME: Once we have a verifier check for forward references to SSA values - // through metadata operands, always return nullptr on unmapped locals. - Metadata *mapLocalAsMetadata(const LocalAsMetadata &LAM); - void scheduleMapGlobalInitializer(GlobalVariable &GV, Constant &Init, unsigned MCID); void scheduleMapAppendingVariable(GlobalVariable &GV, Constant *InitPrefix, @@ -817,22 +803,6 @@ Optional Mapper::mapSimpleMetadata(const Metadata *MD) { return None; } -Metadata *Mapper::mapLocalAsMetadata(const LocalAsMetadata &LAM) { - // Lookup the mapping for the value itself, and return the appropriate - // metadata. - if (Value *V = mapValue(LAM.getValue())) { - if (V == LAM.getValue()) - return const_cast(&LAM); - return ValueAsMetadata::get(V); - } - - // FIXME: always return nullptr once Verifier::verifyDominatesUse() ensures - // metadata operands only reference defined SSA values. - return (Flags & RF_IgnoreMissingLocals) - ? nullptr - : MDTuple::get(LAM.getContext(), None); -} - Metadata *Mapper::mapMetadata(const Metadata *MD) { assert(MD && "Expected valid metadata"); assert(!isa(MD) && "Unexpected local metadata");