llvm2alive: skip functions with too many constants
MODIFY
llvm_util/llvm2alive.cpp
llvm_util/llvm2alive.cpp
@@ -57,6 +57,7 @@ FpExceptionMode parse_exceptions(llvm::Instruction &i) {
}
}
+bool hit_limits;
unsigned constexpr_idx;
unsigned copy_idx;
unsigned alignopbundle_idx;
@@ -134,6 +135,13 @@ class llvm2alive_ : public llvm::InstVisitor<llvm2alive_, unique_ptr<Instr>> {
newI->setName("__constexpr_" + to_string(constexpr_idx++));
i_constexprs.push_back(newI);
+ // don't bother if the number of instructions exploded
+ if (constexpr_idx > 5'000) {
+ hit_limits = true;
+ *out << "ERROR: Too many constants\n";
+ return {};
+ }
+
auto ptr = this->visit(*newI);
if (!ptr)
return nullptr;
@@ -1164,7 +1172,13 @@ public:
RetTy visitInstruction(llvm::Instruction &i) { return error(i); }
RetTy error(llvm::Instruction &i) {
- *out << "ERROR: Unsupported instruction: " << i << '\n';
+ if (hit_limits)
+ return {};
+ stringstream ss;
+ ss << i;
+
+ *out << "ERROR: Unsupported instruction: "
+ << string_view(std::move(ss).str()).substr(0, 80) << '\n';
return {};
}
RetTy errorAttr(const llvm::Attribute &attr) {
@@ -1511,6 +1525,7 @@ public:
optional<Function> run() {
+ hit_limits = false;
constexpr_idx = 0;
copy_idx = 0;
alignopbundle_idx = 0;

llvm2alive: skip functions with too many constants