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

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: add test 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
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved.
Mark Seaborn 2014/08/28 19:13:14 Nit: 2014
Derek Schuff 2014/08/28 22:07:24 Done.
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 #include <stdlib.h>
9
10 void call_with_misaligned_stack(void (*func)());
Mark Seaborn 2014/08/28 19:13:13 "()" -> "(void)" This is supposed to be getting c
Derek Schuff 2014/08/28 22:07:24 Done.
Nico 2014/08/29 04:34:09 If you find warnings that don't work right in clan
11
12 volatile uintptr_t addrf;
13
14 /*
15 Test that locals are properly aligned, even if functions are called with a
Mark Seaborn 2014/08/28 19:13:13 Use NaCl comment style
Derek Schuff 2014/08/28 22:07:24 Done.
16 misaligned stack. This tests the effect of LLC's -force-align-stack (and also
17 the fact that doubles must be 8-byte aligned). This test should only pass
18 when using a flag that forces stack realignment.
19 */
20 void testfunc() {
Mark Seaborn 2014/08/28 19:13:13 "(void)"
Derek Schuff 2014/08/28 22:07:24 Done.
21 double f;
22 /* Smart compiler will optimize away the test (it assumes the alignment is
Mark Seaborn 2014/08/28 19:13:14 Nit: Use the NaCl style for multiline comments, wi
Derek Schuff 2014/08/28 22:07:24 Done.
23 correct) unless we write it to a volatile. */
24 addrf = (uintptr_t) &f;
25 if(addrf % 8 != 0) abort();
Mark Seaborn 2014/08/28 19:13:13 Add space after "if", or better, use ASSERT_EQ(add
Derek Schuff 2014/08/28 22:07:24 Done.
26 }
27
28 int main() {
Mark Seaborn 2014/08/28 19:13:13 "(void)"
Derek Schuff 2014/08/28 22:07:24 Done.
29 printf("Calling testfunc with properly aligned stack\n");
30 testfunc();
31 printf("Calling testfunc with misaligned stack\n");
32 call_with_misaligned_stack(testfunc);
33 }
Mark Seaborn 2014/08/28 19:13:13 Add "return 0", otherwise the return value in unde
Derek Schuff 2014/08/28 22:07:24 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698