[PATCH] D33151: ThinLTO: Verify bitcode before lauching the ThinLTOCodeGenerator.

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 20:20:05 PDT 2017


aprantl added a comment.

This turns out to be quite ugly. 
There are two different code paths, by their llvm-lto options:
 -thinlto-action=run  uses PassManagerBuilder and sets VerifyInput=true, which causes a VerifierLegacyPass to be scheduled
 -thinlto-action=codegen (which mimics llc) doesn't.
The obvious correct fix for -thinlto-action=codegen is to also schedule a Verifier pass. That is easy — but wait.

The VerifierLegacyPass pass doesn't work at all like one might expect. The crux is that VerifierLegacyPass is a FunctionPass, which implements runOnFunction for function-level verification (this part is fine) and does all of its module-level verification in doFinalization(), but doFinalization runs when the PassManager is done with running the entire pipeline, so the per-module verifications are running *after* the bugs happen that they are supposed to prevent.

I think that the right solution for this is to turn VerifierLegacyPass into a ModulePass so the per-module verification can be scheduled to run first.

That is not all, however. There is also the problem that the verifier wants to assert on invalid debug info, which makes this behavior untestable in an asserts build. I will also have to thread a flag to disable the assertion into the VerifierLegacyPass so we can write a testcase for it.

Back to the drawing board...


Repository:
  rL LLVM

https://reviews.llvm.org/D33151





More information about the llvm-commits mailing list