[PATCH] D90340: [NFC] Add more tests for DISubprogram verifier

Scott Linder via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 29 07:31:34 PDT 2020


scott.linder added a comment.

In D90340#2360585 <https://reviews.llvm.org/D90340#2360585>, @vsk wrote:

> Thanks, lgtm.
>
> It looks like verifyFunction asserts that the DISubprogram attached to any function, declaration or definition, is distinct:
>
>     } else if (F.isDeclaration()) {
>       for (const auto &I : MDs) {
>         // This is used for call site debug information.
>         AssertDI(I.first != LLVMContext::MD_dbg ||
>                      !cast<DISubprogram>(I.second)->isDistinct(),
>                  "function declaration may only have a unique !dbg attachment",
>   ...
>           AssertDI(cast<DISubprogram>(I.second)->isDistinct(),
>                    "function definition may only have a distinct !dbg attachment",
>                    &F);
>
> It should be possible to simplify that. I don't think checking `isDistinct()` in verifyDISubprogram is redundant though. You might have DISubprogram metadata that's not attached to a function.

Yeah, there are several layers where this is enforced, but I didn't get to the bottom of where exactly each applies. I tried to test with "free standing" DISubprogram metadata like that, but it appeared to just be dropped before the verifier would see it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90340/new/

https://reviews.llvm.org/D90340



More information about the llvm-commits mailing list