This is an archive of the discontinued LLVM Phabricator instance.

Make attribute-target on a Definition-after-use update the LLVM attributes
ClosedPublic

Authored by erichkeane on Feb 8 2018, 3:32 PM.

Details

Summary

As reported here: https://bugs.llvm.org/show_bug.cgi?id=36301
The issue is that the 'use' causes the plain declaration to emit
the attributes to LLVM-IR. However, if the definition added it
later, these would silently disappear.

This commit extracts that logic to its own function in CodeGenModule,
and has the attribute-applications done during 'definition' update
the attributes properly.

Diff Detail

Repository
rC Clang

Event Timeline

erichkeane created this revision.Feb 8 2018, 3:32 PM
aaron.ballman accepted this revision.Feb 11 2018, 6:06 AM

This looks reasonable to me, but you should wait a few days to commit in case someone more into CodeGen has comments.

Your choice on updating the code you factored into a function; those changes are just style nits.

lib/CodeGen/CodeGenModule.cpp
1258

Could use const auto * here.

1266–1268

Could switch this to a range-base for loop?

1275

Could hoist this out of the if statement so we don't do a has/get operation.

This revision is now accepted and ready to land.Feb 11 2018, 6:06 AM
echristo added inline comments.Feb 12 2018, 9:02 AM
lib/CodeGen/CodeGenModule.cpp
1316–1323

This feels awkward here. On a quick glance I'm not sure why we need this if we're adding above... is it possible to delay in such a way that we're not trying to add twice?

erichkeane marked 3 inline comments as done.Feb 12 2018, 9:05 AM
erichkeane added inline comments.
lib/CodeGen/CodeGenModule.cpp
1316–1323

I hadn't seen any. The other call happens only on a declaration, this happens only on definition. There doesn't really seem to be a way to tell if something is GOING to be defined later, since we often emit the declaration immediately.

This revision was automatically updated to reflect the committed changes.
echristo added inline comments.Feb 12 2018, 9:07 AM
lib/CodeGen/CodeGenModule.cpp
1316–1323

OK, sounds good. I didn't have any other feedback here :)