Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: tests/toolchain/stackalign_test.c

Issue 508823007: Expose LLC's -force-align-stack flag to pnacl-translate (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: review Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/toolchain/nacl.scons ('k') | toolchain_build/toolchain_build_pnacl.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
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.
5 */
6
7 #include <stdio.h>
8
9 #include "native_client/src/include/nacl_assert.h"
10
11 void call_with_misaligned_stack(void (*func)(void));
12
13 volatile uintptr_t addrf;
14
15 /*
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.
20 */
21 void testfunc(void) {
22 double f;
23 /*
24 * Smart compiler will optimize away the test (it assumes the alignment is
25 * correct) unless we write it to a volatile.
26 */
27 addrf = (uintptr_t) &f;
28 ASSERT_EQ(addrf % 8, 0);
29 }
30
31 int main(void) {
32 printf("Calling testfunc with properly aligned stack\n");
33 testfunc();
34 printf("Calling testfunc with misaligned stack\n");
35 call_with_misaligned_stack(testfunc);
36 return 0;
37 }
OLDNEW
« no previous file with comments | « tests/toolchain/nacl.scons ('k') | toolchain_build/toolchain_build_pnacl.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698