This is an archive of the discontinued LLVM Phabricator instance.

[asan] Fix dynamic allocas unpoisoning on PowerPC{64}.
ClosedPublic

Authored by m.ostapenko on Dec 1 2015, 6:17 AM.

Details

Summary

Hi!

As discussed in llvm-dev ML (https://groups.google.com/forum/m/#!topic/llvm-dev/42tNzaHISdk), for PowerPC{64} we cannot just pass SP extracted from @llvm.stackrestore to _asan_allocas_unpoison due to specific ABI requirements (http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#DYNAM-STACK). In particular, to get the pointer to the most recent dynamic alloca, we should add a compile-time-known offset to SP. This offset becomes to be known only on the frame index elimination stage, so we have introduced a special @llvm.get.dynamic.area.offset intrinsic (http://reviews.llvm.org/D14983) to reference it in LLVM. For most targets, this intrinsic is just lowered to zero in backend.

This patch just adds the value returned by @llvm.get.dynamic.area.offset to extracted from @llvm.stackrestore SP, so dynamic allocas unpoisoning stuff would work correctly on PowerPC{64}.

Tested on x86_64-unknown-linux-gnu. Jay, could you please check it on your PPC box?

Diff Detail

Repository
rL LLVM

Event Timeline

m.ostapenko updated this revision to Diff 41497.Dec 1 2015, 6:17 AM
m.ostapenko retitled this revision from to [asan] Fix dynamic allocas unpoisoning on PowerPC{64}..
m.ostapenko updated this object.
m.ostapenko added reviewers: kcc, samsonov.
m.ostapenko set the repository for this revision to rL LLVM.
foad added a comment.Dec 2 2015, 12:31 PM

Jay, could you please check it on your PPC box?

Works for me, thanks!

Kostya, Alexey, is this ok for trunk?

samsonov accepted this revision.Dec 3 2015, 10:53 AM
samsonov edited edge metadata.

LGTM (though it would be nice to have llvm test for that as well)

This revision is now accepted and ready to land.Dec 3 2015, 10:53 AM

Thanks! As for test, perhaps I can add it with another commit?

I'm fine either way.

This revision was automatically updated to reflect the committed changes.