[llvm-commits] Thread Sanitizer seems to have the dual issue

Chandler Carruth chandlerc at google.com
Thu Nov 29 01:20:24 PST 2012


On Wed, Nov 28, 2012 at 10:14 PM, Kostya Serebryany <kcc at google.com> wrote:
> I see the problem now.
>
> With your patch we have:
>   - asan calls doInitialization and creates Function objects (by calling
> M.getOrInsertFunction).
>   - some other pass kicks in and removes those Functions as unused
>   - asan calls runOnFunction and expects the Function objects to be alive,
> but they are not.
>
> The fix is simple: move the M.getOrInsertFunction calls into runOnFunction.
> Is that what we want?

Yes, this will work...

> This will at least be a compile performance degradation (though probably not
> significant for the majority of cases).

You shouldn't see any performance degradation... Just create a null
pointer for the function in the pass. The first time you need it, if
null, getOrInsert. Afterwards, it isn't null. The null test shouldn't
matter at all.


There is another option you might find cleaner: mark the functions as
used explicitly with
http://llvm.org/docs/LangRef.html#intg_compiler_used so that passes
don't remove them.



More information about the llvm-commits mailing list