[PATCH] D38873: LowerTypeTests: Give imported symbols a type with size 0 so that they are not assumed not to alias.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 18:46:23 PDT 2017


pcc created this revision.
Herald added subscribers: hiraditya, mehdi_amini.

It is possible for both a base and a derived class to be satisfied
with a unique vtable. If a program contains casts of the same pointer
to both of those types, the CFI checks will be lowered to this
(with ThinLTO):

if (p != &__typeid_base_global_addr)

  trap();

if (p != &__typeid_derived_global_addr)

  trap();

The optimizer may then use the first condition combined
with the assumption that __typeid_base_global_addr and
__typeid_derived_global_addr may not alias to optimize away the second
comparison, resulting in an unconditional trap.

This patch fixes the bug by giving imported globals the type [0 x i8]*,
which prevents the optimizer from assuming that they do not alias.


https://reviews.llvm.org/D38873

Files:
  compiler-rt/test/cfi/vtable-may-alias.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/test/Transforms/LowerTypeTests/import.ll
  llvm/test/Transforms/LowerTypeTests/simplify.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38873.118879.patch
Type: text/x-patch
Size: 19524 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171013/041f0a6c/attachment.bin>


More information about the llvm-commits mailing list