[llvm-commits] [asan] Use getTypeAllocSize instead of getTypeStoreSize

Evgeniy Stepanov eugeni.stepanov at gmail.com
Wed Feb 29 23:21:39 PST 2012


Hi,

as Eli correctly pointed out in
http://llvm.org/bugs/show_bug.cgi?id=12047, it is not a good idea to
set up stack allocation redzones based on
TargetData::getTypeStoreSize. One case when this produces undesired
results is an optimization in InstCombine pass
(PromoteCastOfAllocation), which can replace  alloca(T) with
alloca(S), where S has the same AllocSize, but a smaller StoreSize.
Another case is memcpy(long double => long double), where ASan will
poison bytes 10-15 of a stack-allocated long double (StoreSize  10,
AllocSize 16, sizeof(long double) = 16).

This patch replaces getTypeStoreSize with getTypeAllocSize in
AddressSanitizer instrumentation for stack allocations. Another patch
adds a test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: allocsize.patch
Type: text/x-patch
Size: 584 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120301/cae9ed56/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: long-double-negative-test.patch
Type: text/x-patch
Size: 646 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120301/cae9ed56/attachment-0001.bin>


More information about the llvm-commits mailing list