2 * Copyright (c) 2014 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
9 #include "native_client/src/include/nacl_assert.h"
11 void call_with_misaligned_stack(void (*func)(void));
13 volatile uintptr_t addrf;
16 * Test that locals are properly aligned, even if functions are called with a
17 * misaligned stack. This tests the effect of LLC's -force-align-stack (and also
18 * the fact that doubles must be 8-byte aligned). This test should only pass
19 * when using a flag that forces stack realignment.
24 * Smart compiler will optimize away the test (it assumes the alignment is
25 * correct) unless we write it to a volatile.
27 addrf = (uintptr_t) &f;
28 ASSERT_EQ(addrf % 8, 0);
32 printf("Calling testfunc with properly aligned stack\n");
34 printf("Calling testfunc with misaligned stack\n");
35 call_with_misaligned_stack(testfunc);