[llvm-dev] [cfe-dev] RFC: ODR checker for Clang and LLD

David Blaikie via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 15 11:14:41 PDT 2017


+Richards (Smith & Trieu) because building functionality on top of the AST
and AST hashes here seems worth some input from them.

On Tue, Jun 6, 2017 at 10:41 PM Peter Collingbourne via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi all,
>
> I'd like to propose an ODR checker feature for Clang and LLD. The feature
> would be similar to gold's --detect-odr-violations feature, but better: we
> can rely on integration with clang to avoid relying on debug info and to
> perform more precise matching.
>
> The basic idea is that we use clang's ability to create ODR hashes for
> declarations. ODR hashes are computed using all information about a
> declaration that is ODR-relevant. If the flag -fdetect-odr-violations is
> passed, Clang will store the ODR hashes in a so-called ODR table in each
> object file. Each ODR table will contain a mapping from mangled declaration
> names to ODR hashes. At link time, the linker will read the ODR table and
> report any mismatches.
>
> To make this work:
> - LLVM will be extended with the ability to represent ODR tables in the IR
> and emit them to object files
> - Clang will be extended with the ability to emit ODR tables using ODR
> hashes
> - LLD will be extended to read ODR tables from object files
>
> I have implemented a prototype of this feature. It is available here:
> https://github.com/pcc/llvm-project/tree/odr-checker and some results
> from applying it to chromium are here: crbug.com/726071
> As you can see it did indeed find a number of real ODR violations in
> Chromium, including some that wouldn't be detectable using debug info.
>
> If you're interested in what the format of the ODR table would look like,
> that prototype shows pretty much what I had in mind, but I expect many
> other aspects of the implementation to change as it is upstreamed.
>
> Thanks,
> --
> --
> Peter
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170615/aa80c6bf/attachment.html>


More information about the llvm-dev mailing list