This is an archive of the discontinued LLVM Phabricator instance.

WholeProgramDevirt: Teach the pass to respect the global's alignment.
ClosedPublic

Authored by pcc on Jul 19 2019, 5:03 PM.

Details

Summary

The bytes inserted before an overaligned global need to be padded according
to the alignment set on the original global in order for the initializer
to meet the global's alignment requirements. The previous implementation
that padded to the pointer width happened to be correct for vtables on most
platforms but may do the wrong thing if the vtable has a larger alignment.

This issue is visible with a prototype implementation of HWASAN for globals,
which will overalign all globals including vtables to 16 bytes.

There is also no padding requirement for the bytes inserted after the global
because they are never read from nor are they significant for alignment
purposes, so stop inserting padding there.

Event Timeline

pcc created this revision.Jul 19 2019, 5:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2019, 5:03 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
vitalybuka accepted this revision.Jul 22 2019, 11:32 AM
This revision is now accepted and ready to land.Jul 22 2019, 11:32 AM
This revision was automatically updated to reflect the committed changes.