Commit 6b16488c authored by Mike Wittman's avatar Mike Wittman Committed by Commit Bot

[Sampling profiler] Fix alloca unwind test

Inhibits compiler optimizations in release builds that were
causing the dynamic stack allocation with alloca to be optimized
out, resulting in the same execution as CallWithPlainFunction().
The disassembly for this implementation shows that the dynamic
allocation is now present.

Change-Id: Id8507c70aa89b132847b267b579661c532339f65
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1582320
Auto-Submit: Mike Wittman <wittman@chromium.org>
Commit-Queue: Charlie Andrews <charliea@chromium.org>
Reviewed-by: default avatarCharlie Andrews <charliea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653599}
parent 1f771e50
......@@ -221,9 +221,14 @@ CallWithPlainFunction(const Closure& wait_for_sample) {
NOINLINE FunctionAddressRange CallWithAlloca(const Closure& wait_for_sample) {
const void* start_program_counter = GetProgramCounter();
const size_t alloca_size = 100;
// Memset to 0 to generate a clean failure.
std::memset(alloca(alloca_size), 0, alloca_size);
// Volatile to force a dynamic stack allocation.
const volatile size_t alloca_size = 100;
// Use the memory via volatile writes to prevent the allocation from being
// optimized out.
volatile char* const allocation =
const_cast<volatile char*>(static_cast<char*>(alloca(alloca_size)));
for (volatile char* p = allocation; p < allocation + alloca_size; ++p)
*p = '\0';
if (!wait_for_sample.is_null())
wait_for_sample.Run();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment