[PATCH] D14473: [Verifier] Improve error for cross-module references

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 8 16:16:09 PST 2015


> On 2015-Nov-06, at 18:23, Keno Fischer via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> loladiro created this revision.
> loladiro added a subscriber: llvm-commits.
> loladiro set the repository for this revision to rL LLVM.
> 
> By including the module name in the error message. This makes the error message much more useful and saves a trip to the debugger.
> 
> Repository:
>  rL LLVM
> 
> http://reviews.llvm.org/D14473
> 
> Files:
>  lib/IR/Verifier.cpp
> 
> Index: lib/IR/Verifier.cpp
> ===================================================================
> --- lib/IR/Verifier.cpp
> +++ lib/IR/Verifier.cpp
> @@ -3153,8 +3153,14 @@
>           "Cannot invoke an intrinsinc other than"
>           " donothing or patchpoint",
>           &I);
> -      Assert(F->getParent() == M, "Referencing function in another module!",
> -             &I);
> +      Module *ParentM = F->getParent();
> +      Assert(ParentM == M,
> +             "Referencing function in module `" +
> +                 (ParentM ? std::string(ParentM->getName())
> +                          : std::string("null")) +
> +                 "` from another module (`" +
> +                 (M ? std::string(M->getName()) : std::string("null")) + "`)!",
> +             &I, F, BB->getParent());

I think the message would be almost as good if you used:
--
Assert(F->getParent() == M, "Referencing function in another module!",
       &I, BB->getParent(), M, F, F->getParent());
--
and the check itself would be easier to maintain.

You just need to add:
--
void VerifierSupport::Write(Module *M) {
  if (M)
    OS << M->getName();
}
--
and then the logic can be reused easily in other verifier checks.


>     } else if (BasicBlock *OpBB = dyn_cast<BasicBlock>(I.getOperand(i))) {
>       Assert(OpBB->getParent() == BB->getParent(),
>              "Referring to a basic block in another function!", &I);
> 
> 
> <D14473.39617.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list