Apply some workaround for known crashers.

llvm-svn: 137991
This commit is contained in:
Johnny Chen 2011-08-18 22:05:58 +00:00
parent 901209dcca
commit f6cb9bcf55
1 changed files with 30 additions and 1 deletions

View File

@ -132,6 +132,13 @@ static inline void RStrip(llvm::StringRef &Str, char c)
if (!Str.empty() && Str.back() == c)
Str = Str.substr(0, Str.size()-1);
}
static inline void RStripNumber(llvm::StringRef &Str)
{
while (!Str.empty() && isnumber(Str.back()))
Str = Str.substr(0, Str.size()-1);
if (!Str.empty() && Str.back() == '-')
Str = Str.substr(0, Str.size()-1);
}
// Aligns the raw disassembly (passed as 'str') with the rest of edis'ed disassembly output.
// This is called from non-raw mode when edis of the current m_inst fails for some reason.
static void
@ -146,6 +153,19 @@ Align(Stream *s, const char *str, size_t opcodeColWidth, size_t operandColWidth)
PadString(s, p.second, operandColWidth);
}
static bool
apply_workaround(const char *str)
{
llvm::StringRef Str(str);
StripSpaces(Str);
if (Str.startswith("mov.w")) {
RStripNumber(Str);
if (Str.endswith("#"))
return true;
}
return false;
}
#define AlignPC(pc_val) (pc_val & 0xFFFFFFFC)
void
InstructionLLVM::Dump
@ -212,7 +232,16 @@ InstructionLLVM::Dump
*/
/* .... when we fix the edis for arm/thumb. */
if (!raw)
const char *lookahead;
bool workaround = false;
if (EDGetInstString(&lookahead, m_inst)) // 0 on success
return;
else if (m_arch_type == llvm::Triple::thumb) {
if (apply_workaround(lookahead))
workaround = true;
}
if (!raw && !workaround)
numTokens = EDNumTokens(m_inst);
int currentOpIndex = -1;