Skip to content

Commit e8c4a9a

Browse files
alexmalyshevfacebook-github-bot
authored andcommitted
Improve asserts in autogen.cpp and operand.cpp
Summary: When a bad operand is hit in this case, print the operand and the instruction for easier debugging. Reviewed By: jbower-fb, yoney Differential Revision: D81512872 fbshipit-source-id: 37084cf27d80955dee3b07de60812afb4f8bdcb1
1 parent f3c5e7d commit e8c4a9a

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

cinderx/Jit/codegen/autogen.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "cinderx/Jit/generators_rt.h"
1111
#include "cinderx/Jit/jit_rt.h"
1212
#include "cinderx/Jit/lir/instruction.h"
13+
#include "cinderx/Jit/lir/printer.h"
1314

1415
#include <asmjit/x86/x86operand.h>
1516

@@ -142,7 +143,10 @@ void AutoTranslator::translateInstr(Environ* env, const Instruction* instr)
142143
pattern += "b";
143144
break;
144145
default:
145-
JIT_ABORT("Illegal input type.");
146+
JIT_ABORT(
147+
"Illegal input type {} for instruction {}",
148+
operand->type(),
149+
*instr);
146150
}
147151
});
148152

cinderx/Jit/lir/operand.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ uint64_t Operand::rawValue() const {
320320
} else if (
321321
const auto ptr = std::get_if<std::unique_ptr<MemoryIndirect>>(&value_)) {
322322
return reinterpret_cast<uint64_t>(ptr->get());
323+
} else if (const auto ptr = std::get_if<PhyLocation>(&value_)) {
324+
return static_cast<uint64_t>(ptr->loc);
323325
}
324326

325327
JIT_ABORT("Unknown operand value type, has index {}", value_.index());

0 commit comments

Comments
 (0)