diff options
author | Tatyana Krasnukha <tatyana@synopsys.com> | 2018-09-06 19:58:26 +0000 |
---|---|---|
committer | Tatyana Krasnukha <tatyana@synopsys.com> | 2018-09-06 19:58:26 +0000 |
commit | b5f42976ad8be39d7ab60cf091a5ca82a8e944a6 (patch) | |
tree | 4656b3085921b9ada0fd66afa0d8a35c79b9eefa /llvm/lib/Target | |
parent | 95dd7a25bab98a93bd58c47e0b6d6f91791bf987 (diff) | |
download | bcm5719-llvm-b5f42976ad8be39d7ab60cf091a5ca82a8e944a6.tar.gz bcm5719-llvm-b5f42976ad8be39d7ab60cf091a5ca82a8e944a6.zip |
[ARC] Prevent InstPrinter from crashing on unknown condition codes.
Summary:
Instruction printer shouldn't crash with assertions due to incorrect input data. llvm_unreachable is not intended for runtime error handling.
Reviewers: petecoup
Reviewed By: petecoup
Differential Revision: https://reviews.llvm.org/D51728
llvm-svn: 341581
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r-- | llvm/lib/Target/ARC/InstPrinter/ARCInstPrinter.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Target/ARC/InstPrinter/ARCInstPrinter.cpp b/llvm/lib/Target/ARC/InstPrinter/ARCInstPrinter.cpp index 0c627d04698..f0625800ccc 100644 --- a/llvm/lib/Target/ARC/InstPrinter/ARCInstPrinter.cpp +++ b/llvm/lib/Target/ARC/InstPrinter/ARCInstPrinter.cpp @@ -20,7 +20,6 @@ #include "llvm/MC/MCSymbol.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Debug.h" -#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -29,6 +28,12 @@ using namespace llvm; #include "ARCGenAsmWriter.inc" +template <class T> +static const char *BadConditionCode(T cc) { + DEBUG(dbgs() << "Unknown condition code passed: " << cc << "\n"); + return "{unknown-cc}"; +} + static const char *ARCBRCondCodeToString(ARCCC::BRCondCode BRCC) { switch (BRCC) { case ARCCC::BREQ: @@ -44,7 +49,7 @@ static const char *ARCBRCondCodeToString(ARCCC::BRCondCode BRCC) { case ARCCC::BRHS: return "hs"; } - llvm_unreachable("Unhandled ARCCC::BRCondCode"); + return BadConditionCode(BRCC); } static const char *ARCCondCodeToString(ARCCC::CondCode CC) { @@ -86,7 +91,7 @@ static const char *ARCCondCodeToString(ARCCC::CondCode CC) { case ARCCC::Z: return "z"; } - llvm_unreachable("Unhandled ARCCC::CondCode"); + return BadConditionCode(CC); } void ARCInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const { |