This is an archive of the discontinued LLVM Phabricator instance.

[stack-clash] Fix probing of dynamic alloca
ClosedPublic

Authored by serge-sans-paille on Oct 27 2020, 3:17 AM.

Details

Summary

Perform the probing in the *cough* correct direction.

Related to https://github.com/rust-lang/rust/pull/77885#issuecomment-711062924

Diff Detail

Event Timeline

serge-sans-paille requested review of this revision.Oct 27 2020, 3:17 AM

I tried the C reproducer from that Rust bug, and it turns out that alloca(0) was already fixed by D88548. But if I change that to a larger size, then it was skipping right over the probe loop. I confirmed that your change here does make it go through the loop.

It would be nice to have tests that actually execute this stuff, rather than just relying on manual reviews of the expected assembly, but I don't know if that's feasible in the current infrastructure.

llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
29–30

Shouldn't this sub before mov 0? I think right now, the first iteration is going to clobber the most recent thing on the stack, in this case the saved value from pushq %rbp.

Fix issue with clobbered stack memory

cuviper accepted this revision.Oct 28 2020, 1:49 PM

Works for me!

This revision is now accepted and ready to land.Oct 28 2020, 1:49 PM
This revision was automatically updated to reflect the committed changes.