This is an archive of the discontinued LLVM Phabricator instance.

[ASTImporter] Fix inequality of functions with different attributes
ClosedPublic

Authored by martong on Oct 25 2018, 7:06 AM.

Details

Summary

FunctionType::ExtInfo holds such properties of a function which are needed
mostly for code gen. We should not compare these bits when checking for
structural equivalency.
Checking ExtInfo caused false ODR errors during CTU analysis (of tmux).

Diff Detail

Repository
rC Clang

Event Timeline

martong created this revision.Oct 25 2018, 7:06 AM

Hi Gabor,
Thank you for the patch. The reason for this change looks clear. However, I don't think omitting this comparison completely is what we want here. Instead, we can do a dance similar to ASTContext::mergeFunctionTypes() where all attributes but NoReturn are compared. What do you think?

That's a good point. I agree, we should check some bits (calling convention bits) but not all (e.g. noreturn bit). I am going to create another patch which replaces this.

martong updated this revision to Diff 175647.Nov 28 2018, 3:08 AM
  • Use ExtInfo in structural equivalency

Hi @a_sidorin ,

I have updated the patch as you suggested, to check the equivalence based on ASTContext::mergeFunctionTypes().

a_sidorin accepted this revision.Dec 1 2018, 12:11 PM

LGTM, thanks!

This revision is now accepted and ready to land.Dec 1 2018, 12:11 PM
shafik added inline comments.Dec 12 2018, 11:15 AM
lib/AST/ASTStructuralEquivalence.cpp
301

This comment is confusing b/c it looks like the noreturn bits are the only one you are not checking.

unittests/AST/StructuralEquivalenceTest.cpp
373

Can we get some more tests to be a little more thorough and can we also get a test where it is expected to to be false as well?

shafik requested changes to this revision.Dec 12 2018, 11:27 AM
This revision now requires changes to proceed.Dec 12 2018, 11:27 AM
martong marked 4 inline comments as done.Dec 13 2018, 7:11 AM
martong added inline comments.
lib/AST/ASTStructuralEquivalence.cpp
301

Ok, I have removed that part of the comment.

unittests/AST/StructuralEquivalenceTest.cpp
373

Ok, I have adder a few more tests and renamed the existing one.

martong updated this revision to Diff 178060.Dec 13 2018, 7:11 AM
martong marked 2 inline comments as done.
  • Add more tests and simplify comment

Ping @shafik, I have addressed you comments, could you please take another look? If you don't have any objections, could you please approve?

shafik accepted this revision.Jan 11 2019, 10:01 AM

LGTM

Thank you for adding the additional test.

This revision is now accepted and ready to land.Jan 11 2019, 10:01 AM
This revision was automatically updated to reflect the committed changes.