fix crash in opt plugin after changes to ignore metadata introduced in tgt
MODIFY
tv/tv.cpp
tv/tv.cpp
@@ -225,14 +225,21 @@ struct TVLegacyPass final : public llvm::ModulePass {
t.tgt = std::move(*fn);
verify(t, I->second.n++, I->second.fn_tostr);
- I->second.fn = *llvm2alive(F, *TLI, true);
+
+ fn = llvm2alive(F, *TLI, true);
+ if (!fn) {
+ fns.erase(I);
+ return false;
+ }
+ I->second.fn = std::move(*fn);
+ if (!opt_always_verify)
I->second.fn_tostr = toString(I->second.fn);
return false;
}
// If it returns true, the caller should regenerate tgt using llvm2alive().
// If it returns false, the caller can simply move t.tgt to info.fn
- static bool verify(Transform &t, int n, const string &src_tostr) {
+ static void verify(Transform &t, int n, const string &src_tostr) {
printDot(t.tgt, n);
if (!opt_always_verify) {
@@ -241,7 +248,7 @@ struct TVLegacyPass final : public llvm::ModulePass {
if (!opt_quiet)
t.print(*out, print_opts);
*out << "Transformation seems to be correct! (syntactically equal)\n\n";
- return false;
+ return;
}
}
@@ -265,7 +272,7 @@ struct TVLegacyPass final : public llvm::ModulePass {
* but only to make parallel output match sequential
* output. we can remove it later if we want.
*/
- return true;
+ return;
}
if (subprocess_timeout != -1) {
@@ -321,10 +328,6 @@ struct TVLegacyPass final : public llvm::ModulePass {
*out << "Transformation seems to be correct!\n\n";
}
- // Regenerate tgt because preprocessing may have changed it
- if (!parallelMgr)
- return true;
-
done:
if (parallelMgr) {
showStats();
@@ -334,7 +337,6 @@ struct TVLegacyPass final : public llvm::ModulePass {
parallelMgr->finishChild(/*is_timeout=*/false);
exit(0);
}
- return false;
}
bool doInitialization(llvm::Module &module) override {

fix crash in opt plugin after changes to ignore metadata introduced in tgt