[PATCH] D65031: WholeProgramDevirt: Teach the pass to respect the global's alignment.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 19 17:04:14 PDT 2019


pcc created this revision.
pcc added reviewers: hctim, vitalybuka.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65031

Files:
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/Transforms/WholeProgramDevirt/virtual-const-prop-begin.ll
  llvm/test/Transforms/WholeProgramDevirt/virtual-const-prop-end.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65031.210939.patch
Type: text/x-patch
Size: 9362 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190720/ea315754/attachment.bin>


More information about the llvm-commits mailing list