From: Ahmed Charles Date: Sun, 19 Feb 2012 11:37:01 +0000 (+0000) Subject: Remove dead code. Improve llvm_unreachable text. Simplify some control flow. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=b0934ab7d811e23bf530371976b8b35f3242169c Remove dead code. Improve llvm_unreachable text. Simplify some control flow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150918 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index b6f0ae54cfa..47b37102918 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -491,7 +491,6 @@ namespace llvm { RetVal visitCouldNotCompute(const SCEVCouldNotCompute *S) { llvm_unreachable("Invalid use of SCEVCouldNotCompute!"); - return RetVal(); } }; } diff --git a/lib/CodeGen/GCStrategy.cpp b/lib/CodeGen/GCStrategy.cpp index 970c8bcfd8d..506b5cf0945 100644 --- a/lib/CodeGen/GCStrategy.cpp +++ b/lib/CodeGen/GCStrategy.cpp @@ -112,7 +112,7 @@ bool GCStrategy::initializeCustomLowering(Module &M) { return false; } bool GCStrategy::performCustomLowering(Function &F) { dbgs() << "gc " << getName() << " must override performCustomLowering.\n"; - llvm_unreachable(0); + llvm_unreachable("must override performCustomLowering"); } diff --git a/lib/CodeGen/StrongPHIElimination.cpp b/lib/CodeGen/StrongPHIElimination.cpp index 202c4cbd4a2..c6fdc738243 100644 --- a/lib/CodeGen/StrongPHIElimination.cpp +++ b/lib/CodeGen/StrongPHIElimination.cpp @@ -228,7 +228,6 @@ static MachineOperand *findLastUse(MachineBasicBlock *MBB, unsigned Reg) { return &MO; } } - return NULL; } bool StrongPHIElimination::runOnMachineFunction(MachineFunction &MF) { diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index ac4c49f7caf..3dce3b3bf66 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -1235,7 +1235,7 @@ GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE, break; default: dbgs() << "Unhandled ConstantExpr: " << *CE << "\n"; - llvm_unreachable(0); + llvm_unreachable("Unhandled ConstantExpr"); } return Dest; } diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp index 75e4f71ed8c..4553ef42df7 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp @@ -34,7 +34,6 @@ resolveRelocation(uint8_t *Address, uint64_t Value, bool isPCRel, return resolveARMRelocation((uintptr_t)Address, (uintptr_t)Value, isPCRel, Type, Size, Addend); } - llvm_unreachable(""); } bool RuntimeDyldMachO:: diff --git a/lib/MC/MCDisassembler/EDDisassembler.cpp b/lib/MC/MCDisassembler/EDDisassembler.cpp index 9edf50579ee..ea77902112c 100644 --- a/lib/MC/MCDisassembler/EDDisassembler.cpp +++ b/lib/MC/MCDisassembler/EDDisassembler.cpp @@ -104,27 +104,22 @@ EDDisassembler *EDDisassembler::getDisassembler(StringRef str, CPUKey key; key.Triple = str.str(); key.Syntax = syntax; - + EDDisassembler::DisassemblerMap_t::iterator i = sDisassemblers.find(key); - + if (i != sDisassemblers.end()) { return i->second; } - else { - EDDisassembler *sdd = new EDDisassembler(key); - if (!sdd->valid()) { - delete sdd; - return NULL; - } - - sDisassemblers[key] = sdd; - - return sdd; + + EDDisassembler *sdd = new EDDisassembler(key); + if (!sdd->valid()) { + delete sdd; + return NULL; } - - return NULL; - - return getDisassembler(Triple(str).getArch(), syntax); + + sDisassemblers[key] = sdd; + + return sdd; } EDDisassembler::EDDisassembler(CPUKey &key) : diff --git a/lib/Support/CrashRecoveryContext.cpp b/lib/Support/CrashRecoveryContext.cpp index 263114c06f9..e2af0bc1765 100644 --- a/lib/Support/CrashRecoveryContext.cpp +++ b/lib/Support/CrashRecoveryContext.cpp @@ -165,7 +165,6 @@ static LONG CALLBACK ExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo) // Note that we don't actually get here because HandleCrash calls // longjmp, which means the HandleCrash function never returns. llvm_unreachable("Handled the crash, should have longjmp'ed out of here"); - return EXCEPTION_CONTINUE_SEARCH; } // Because the Enable and Disable calls are static, it means that diff --git a/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp b/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp index bbb1dd5cc48..a821192607a 100644 --- a/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp +++ b/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp @@ -673,7 +673,6 @@ void ARMInstPrinter::printMSRMaskOperand(const MCInst *MI, unsigned OpNum, case 8: O << "nzcvq"; return; case 12: O << "nzcvqg"; return; } - llvm_unreachable("Unexpected mask value!"); } if (SpecRegRBit) diff --git a/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp b/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp index 89aa68f3056..32bf18cfae6 100644 --- a/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp +++ b/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp @@ -155,7 +155,6 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT, if (TheTriple.isOSWindows()) { llvm_unreachable("ARM does not support Windows COFF format"); - return NULL; } return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll, NoExecStack); diff --git a/lib/Target/MBlaze/MCTargetDesc/MBlazeMCTargetDesc.cpp b/lib/Target/MBlaze/MCTargetDesc/MBlazeMCTargetDesc.cpp index 9d64cf2306f..f83e8ab1859 100644 --- a/lib/Target/MBlaze/MCTargetDesc/MBlazeMCTargetDesc.cpp +++ b/lib/Target/MBlaze/MCTargetDesc/MBlazeMCTargetDesc.cpp @@ -83,12 +83,10 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT, if (TheTriple.isOSDarwin()) { llvm_unreachable("MBlaze does not support Darwin MACH-O format"); - return NULL; } if (TheTriple.isOSWindows()) { llvm_unreachable("MBlaze does not support Windows COFF format"); - return NULL; } return createELFStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll, NoExecStack); diff --git a/lib/Target/Mips/MipsAsmPrinter.cpp b/lib/Target/Mips/MipsAsmPrinter.cpp index fbc5f7d5ce8..9ddc08a9e09 100644 --- a/lib/Target/Mips/MipsAsmPrinter.cpp +++ b/lib/Target/Mips/MipsAsmPrinter.cpp @@ -246,11 +246,8 @@ const char *MipsAsmPrinter::getCurrentABIString() const { case MipsSubtarget::N32: return "abiN32"; case MipsSubtarget::N64: return "abi64"; case MipsSubtarget::EABI: return "eabi32"; // TODO: handle eabi64 - default: break; + default: llvm_unreachable("Unknown Mips ABI");; } - - llvm_unreachable("Unknown Mips ABI"); - return NULL; } void MipsAsmPrinter::EmitFunctionEntryLabel() { diff --git a/lib/Target/PTX/PTXAsmPrinter.cpp b/lib/Target/PTX/PTXAsmPrinter.cpp index 3a2e8b1e06e..58ac5f243fc 100644 --- a/lib/Target/PTX/PTXAsmPrinter.cpp +++ b/lib/Target/PTX/PTXAsmPrinter.cpp @@ -79,7 +79,6 @@ static const char *getStateSpaceName(unsigned addressSpace) { case PTXStateSpace::Parameter: return "param"; case PTXStateSpace::Shared: return "shared"; } - return NULL; } static const char *getTypeName(Type* type) { diff --git a/lib/Target/PTX/PTXRegisterInfo.cpp b/lib/Target/PTX/PTXRegisterInfo.cpp index b8bb9e8a115..3f087cd97fd 100644 --- a/lib/Target/PTX/PTXRegisterInfo.cpp +++ b/lib/Target/PTX/PTXRegisterInfo.cpp @@ -31,44 +31,8 @@ PTXRegisterInfo::PTXRegisterInfo(PTXTargetMachine &TM, : PTXGenRegisterInfo(0), TII(tii) { } -void PTXRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II, - int SPAdj, - RegScavenger *RS) const { - unsigned Index; - MachineInstr &MI = *II; - //MachineBasicBlock &MBB = *MI.getParent(); - //DebugLoc dl = MI.getDebugLoc(); - //MachineRegisterInfo &MRI = MI.getParent()->getParent()->getRegInfo(); - - //unsigned Reg = MRI.createVirtualRegister(PTX::RegF32RegisterClass); - +void PTXRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator /*II*/, + int /*SPAdj*/, + RegScavenger * /*RS*/) const { llvm_unreachable("FrameIndex should have been previously eliminated!"); - - Index = 0; - while (!MI.getOperand(Index).isFI()) { - ++Index; - assert(Index < MI.getNumOperands() && - "Instr does not have a FrameIndex operand!"); - } - - int FrameIndex = MI.getOperand(Index).getIndex(); - - DEBUG(dbgs() << "eliminateFrameIndex: " << MI); - DEBUG(dbgs() << "- SPAdj: " << SPAdj << "\n"); - DEBUG(dbgs() << "- FrameIndex: " << FrameIndex << "\n"); - - //MachineInstr* MI2 = BuildMI(MBB, II, dl, TII.get(PTX::LOAD_LOCAL_F32)) - //.addReg(Reg, RegState::Define).addImm(FrameIndex); - //if (MI2->findFirstPredOperandIdx() == -1) { - // MI2->addOperand(MachineOperand::CreateReg(PTX::NoRegister, /*IsDef=*/false)); - // MI2->addOperand(MachineOperand::CreateImm(PTX::PRED_NORMAL)); - //} - //MI2->dump(); - - //MachineOperand ESOp = MachineOperand::CreateES("__local__"); - - // This frame index is post stack slot re-use assignments - //MI.getOperand(Index).ChangeToRegister(Reg, false); - MI.getOperand(Index).ChangeToImmediate(FrameIndex); - //MI.getOperand(Index) = ESOp; } diff --git a/lib/Target/Sparc/SparcISelDAGToDAG.cpp b/lib/Target/Sparc/SparcISelDAGToDAG.cpp index 8c6103dd8a3..93710c4e0b0 100644 --- a/lib/Target/Sparc/SparcISelDAGToDAG.cpp +++ b/lib/Target/Sparc/SparcISelDAGToDAG.cpp @@ -176,7 +176,6 @@ SDNode *SparcDAGToDAGISel::Select(SDNode *N) { MulLHS, MulRHS); // The high part is in the Y register. return CurDAG->SelectNodeTo(N, SP::RDY, MVT::i32, SDValue(Mul, 1)); - return NULL; } } diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index a1f1d5cf8b6..05340c17839 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -1444,7 +1444,6 @@ processInstruction(MCInst &Inst, return true; } } - return false; } bool X86AsmParser:: diff --git a/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c b/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c index 3740f497c19..e055773750f 100644 --- a/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c +++ b/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c @@ -82,11 +82,9 @@ static int modRMRequired(OpcodeType type, decision = &THREEBYTEA7_SYM; break; } - + return decision->opcodeDecisions[insnContext].modRMDecisions[opcode]. modrm_type != MODRM_ONEENTRY; - - return 0; } /* diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 917ec5886ca..d1e57e101bf 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -920,7 +920,6 @@ Instruction *WidenIV::CloneIVUser(NarrowIVDefUse DU) { } return WideBO; } - llvm_unreachable(0); } /// No-wrap operations can transfer sign extension of their result to their diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index d113aca7308..11fd5b6eae4 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -2559,9 +2559,8 @@ CastInst::getCastOpcode( assert(DestBits == SrcBits && "Casting vector to floating point of different width"); return BitCast; // same size, no-op cast - } else { - llvm_unreachable("Casting pointer or non-first class to float"); } + llvm_unreachable("Casting pointer or non-first class to float"); } else if (DestTy->isVectorTy()) { assert(DestBits == SrcBits && "Illegal cast to vector (wrong type or size)"); @@ -2571,24 +2570,16 @@ CastInst::getCastOpcode( return BitCast; // ptr -> ptr } else if (SrcTy->isIntegerTy()) { return IntToPtr; // int -> ptr - } else { - llvm_unreachable("Casting pointer to other than pointer or int"); } + llvm_unreachable("Casting pointer to other than pointer or int"); } else if (DestTy->isX86_MMXTy()) { if (SrcTy->isVectorTy()) { assert(DestBits == SrcBits && "Casting vector of wrong width to X86_MMX"); return BitCast; // 64-bit vector to MMX - } else { - llvm_unreachable("Illegal cast to X86_MMX"); } - } else { - llvm_unreachable("Casting to type that is not first-class"); + llvm_unreachable("Illegal cast to X86_MMX"); } - - // If we fall through to here we probably hit an assertion cast above - // and assertions are not turned on. Anything we return is an error, so - // BitCast is as good a choice as any. - return BitCast; + llvm_unreachable("Casting to type that is not first-class"); } //===----------------------------------------------------------------------===// diff --git a/tools/llvm-ld/llvm-ld.cpp b/tools/llvm-ld/llvm-ld.cpp index f1ee4ad56fb..ecf0476eb29 100644 --- a/tools/llvm-ld/llvm-ld.cpp +++ b/tools/llvm-ld/llvm-ld.cpp @@ -423,7 +423,7 @@ static void EmitShellScript(char **argv, Module *M) { PrintAndExit(ErrMsg, M); return; -#endif +#else // Output the script to start the program... std::string ErrorInfo; @@ -469,6 +469,7 @@ static void EmitShellScript(char **argv, Module *M) { } Out2.os() << " " << BitcodeOutputFilename << " ${1+\"$@\"}\n"; Out2.keep(); +#endif } // BuildLinkItems -- This function generates a LinkItemList for the LinkItems diff --git a/utils/KillTheDoctor/KillTheDoctor.cpp b/utils/KillTheDoctor/KillTheDoctor.cpp index 1ddae0bc8bb..70713b25bf2 100644 --- a/utils/KillTheDoctor/KillTheDoctor.cpp +++ b/utils/KillTheDoctor/KillTheDoctor.cpp @@ -211,19 +211,6 @@ static error_code GetFileNameFromHandle(HANDLE FileHandle, } } -static std::string QuoteProgramPathIfNeeded(StringRef Command) { - if (Command.find_first_of(' ') == StringRef::npos) - return Command; - else { - std::string ret; - ret.reserve(Command.size() + 3); - ret.push_back('"'); - ret.append(Command.begin(), Command.end()); - ret.push_back('"'); - return ret; - } -} - /// @brief Find program using shell lookup rules. /// @param Program This is either an absolute path, relative path, or simple a /// program name. Look in PATH for any programs that match. If no @@ -269,39 +256,6 @@ static std::string FindProgram(const std::string &Program, error_code &ec) { return PathName; } -static error_code EnableDebugPrivileges() { - HANDLE TokenHandle; - BOOL success = ::OpenProcessToken(::GetCurrentProcess(), - TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, - &TokenHandle); - if (!success) - return windows_error(::GetLastError()); - - TokenScopedHandle Token(TokenHandle); - TOKEN_PRIVILEGES TokenPrivileges; - LUID LocallyUniqueID; - - success = ::LookupPrivilegeValueA(NULL, - SE_DEBUG_NAME, - &LocallyUniqueID); - if (!success) - return windows_error(::GetLastError()); - - TokenPrivileges.PrivilegeCount = 1; - TokenPrivileges.Privileges[0].Luid = LocallyUniqueID; - TokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - - success = ::AdjustTokenPrivileges(Token, - FALSE, - &TokenPrivileges, - sizeof(TOKEN_PRIVILEGES), - NULL, - NULL); - // The value of success is basically useless. Either way we are just returning - // the value of ::GetLastError(). - return windows_error(::GetLastError()); -} - static StringRef ExceptionCodeToString(DWORD ExceptionCode) { switch(ExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: return "EXCEPTION_ACCESS_VIOLATION"; diff --git a/utils/TableGen/X86DisassemblerTables.cpp b/utils/TableGen/X86DisassemblerTables.cpp index b22aeddb7d9..33cc017abaf 100644 --- a/utils/TableGen/X86DisassemblerTables.cpp +++ b/utils/TableGen/X86DisassemblerTables.cpp @@ -140,8 +140,6 @@ static inline const char* stringForContext(InstructionContext insnContext) { INSTRUCTION_CONTEXTS #undef ENUM_ENTRY } - - return 0; } /// stringForOperandType - Like stringForContext, but for OperandTypes.