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
This commit is contained in:
Ahmed Charles 2012-02-19 11:37:01 +00:00
parent d7ace3f8d1
commit b0934ab7d8
21 changed files with 24 additions and 138 deletions

View File

@ -491,7 +491,6 @@ namespace llvm {
RetVal visitCouldNotCompute(const SCEVCouldNotCompute *S) {
llvm_unreachable("Invalid use of SCEVCouldNotCompute!");
return RetVal();
}
};
}

View File

@ -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");
}

View File

@ -228,7 +228,6 @@ static MachineOperand *findLastUse(MachineBasicBlock *MBB, unsigned Reg) {
return &MO;
}
}
return NULL;
}
bool StrongPHIElimination::runOnMachineFunction(MachineFunction &MF) {

View File

@ -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;
}

View File

@ -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::

View File

@ -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) :

View File

@ -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

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -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() {

View File

@ -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) {

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -1444,7 +1444,6 @@ processInstruction(MCInst &Inst,
return true;
}
}
return false;
}
bool X86AsmParser::

View File

@ -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;
}
/*

View File

@ -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

View File

@ -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");
}
//===----------------------------------------------------------------------===//

View File

@ -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

View File

@ -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";

View File

@ -140,8 +140,6 @@ static inline const char* stringForContext(InstructionContext insnContext) {
INSTRUCTION_CONTEXTS
#undef ENUM_ENTRY
}
return 0;
}
/// stringForOperandType - Like stringForContext, but for OperandTypes.