[PATCH] D51728: [ARC] Prevent InstPrinter from crashing on unknown condition codes.
Tatyana Krasnukha via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 6 04:37:48 PDT 2018
tatyana-krasnukha created this revision.
tatyana-krasnukha added a reviewer: petecoup.
Herald added a subscriber: llvm-commits.
Instruction printer shouldn't crash with assertions due to incorrect input data. `llvm_unreachable` is not intended for runtime error handling.
Repository:
rL LLVM
https://reviews.llvm.org/D51728
Files:
lib/Target/ARC/InstPrinter/ARCInstPrinter.cpp
Index: lib/Target/ARC/InstPrinter/ARCInstPrinter.cpp
===================================================================
--- lib/Target/ARC/InstPrinter/ARCInstPrinter.cpp
+++ 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 @@
#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 @@
case ARCCC::BRHS:
return "hs";
}
- llvm_unreachable("Unhandled ARCCC::BRCondCode");
+ return BadConditionCode(BRCC);
}
static const char *ARCCondCodeToString(ARCCC::CondCode CC) {
@@ -86,7 +91,7 @@
case ARCCC::Z:
return "z";
}
- llvm_unreachable("Unhandled ARCCC::CondCode");
+ return BadConditionCode(CC);
}
void ARCInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51728.164187.patch
Type: text/x-patch
Size: 1207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180906/f884b92b/attachment.bin>
More information about the llvm-commits
mailing list