diff options
Diffstat (limited to 'toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99521.patch')
-rw-r--r-- | toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99521.patch | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99521.patch b/toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99521.patch new file mode 100644 index 0000000000..6d2d75bf91 --- /dev/null +++ b/toolchain-layer/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99521.patch | |||
@@ -0,0 +1,166 @@ | |||
1 | 2011-07-08 Richard Sandiford <rdsandiford@googlemail.com> | ||
2 | |||
3 | gcc/ | ||
4 | * builtins.c (get_object_alignment): Fix comment. | ||
5 | * fold-const.c (get_pointer_modulus_and_residue): Remove | ||
6 | allow_func_align. Use get_object_alignment. | ||
7 | (fold_binary_loc): Update caller. | ||
8 | |||
9 | 2011-07-08 Richard Sandiford <rdsandiford@googlemail.com> | ||
10 | |||
11 | gcc/ | ||
12 | Backport from mainline: | ||
13 | |||
14 | 2011-06-29 Richard Sandiford <richard.sandiford@linaro.org> | ||
15 | |||
16 | PR tree-optimization/49545 | ||
17 | * builtins.c (get_object_alignment_1): Update function comment. | ||
18 | Do not use DECL_ALIGN for functions, but test | ||
19 | TARGET_PTRMEMFUNC_VBIT_LOCATION instead. | ||
20 | * fold-const.c (get_pointer_modulus_and_residue): Don't check | ||
21 | for functions here. | ||
22 | |||
23 | gcc/testsuite/ | ||
24 | Backport from mainline: | ||
25 | |||
26 | 2011-06-29 Richard Sandiford <richard.sandiford@linaro.org> | ||
27 | |||
28 | * gcc.dg/torture/pr49169.c: Restrict to ARM and MIPS targets. | ||
29 | |||
30 | 2011-07-08 Richard Sandiford <richard.sandiford@linaro.org> | ||
31 | |||
32 | gcc/ | ||
33 | Backport from mainline: | ||
34 | |||
35 | 2011-07-27 Richard Guenther <rguenther@suse.de> | ||
36 | |||
37 | PR tree-optimization/49169 | ||
38 | * fold-const.c (get_pointer_modulus_and_residue): Don't rely on | ||
39 | the alignment of function decls. | ||
40 | |||
41 | gcc/testsuite/ | ||
42 | Backport from mainline: | ||
43 | |||
44 | 2011-07-27 Michael Hope <michael.hope@linaro.org> | ||
45 | Richard Sandiford <richard.sandiford@linaro.org> | ||
46 | |||
47 | PR tree-optimization/49169 | ||
48 | * gcc.dg/torture/pr49169.c: New test. | ||
49 | |||
50 | === modified file 'gcc/builtins.c' | ||
51 | --- old/gcc/builtins.c 2011-01-06 11:02:44 +0000 | ||
52 | +++ new/gcc/builtins.c 2011-06-29 09:59:48 +0000 | ||
53 | @@ -263,7 +263,14 @@ | ||
54 | |||
55 | /* Return the alignment in bits of EXP, an object. | ||
56 | Don't return more than MAX_ALIGN no matter what, ALIGN is the inital | ||
57 | - guessed alignment e.g. from type alignment. */ | ||
58 | + guessed alignment e.g. from type alignment. | ||
59 | + | ||
60 | + Note that the address (and thus the alignment) computed here is based | ||
61 | + on the address to which a symbol resolves, whereas DECL_ALIGN is based | ||
62 | + on the address at which an object is actually located. These two | ||
63 | + addresses are not always the same. For example, on ARM targets, | ||
64 | + the address &foo of a Thumb function foo() has the lowest bit set, | ||
65 | + whereas foo() itself starts on an even address. */ | ||
66 | |||
67 | int | ||
68 | get_object_alignment (tree exp, unsigned int align, unsigned int max_align) | ||
69 | @@ -327,7 +334,21 @@ | ||
70 | exp = DECL_INITIAL (exp); | ||
71 | if (DECL_P (exp) | ||
72 | && TREE_CODE (exp) != LABEL_DECL) | ||
73 | - align = MIN (inner, DECL_ALIGN (exp)); | ||
74 | + { | ||
75 | + if (TREE_CODE (exp) == FUNCTION_DECL) | ||
76 | + { | ||
77 | + /* Function addresses can encode extra information besides their | ||
78 | + alignment. However, if TARGET_PTRMEMFUNC_VBIT_LOCATION | ||
79 | + allows the low bit to be used as a virtual bit, we know | ||
80 | + that the address itself must be 2-byte aligned. */ | ||
81 | + if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn) | ||
82 | + align = 2 * BITS_PER_UNIT; | ||
83 | + else | ||
84 | + align = BITS_PER_UNIT; | ||
85 | + } | ||
86 | + else | ||
87 | + align = MIN (inner, DECL_ALIGN (exp)); | ||
88 | + } | ||
89 | #ifdef CONSTANT_ALIGNMENT | ||
90 | else if (CONSTANT_CLASS_P (exp)) | ||
91 | align = MIN (inner, (unsigned)CONSTANT_ALIGNMENT (exp, align)); | ||
92 | |||
93 | === modified file 'gcc/fold-const.c' | ||
94 | --- old/gcc/fold-const.c 2011-05-05 14:28:53 +0000 | ||
95 | +++ new/gcc/fold-const.c 2011-07-08 12:54:44 +0000 | ||
96 | @@ -10030,15 +10030,10 @@ | ||
97 | 0 <= N < M as is common. In general, the precise value of P is unknown. | ||
98 | M is chosen as large as possible such that constant N can be determined. | ||
99 | |||
100 | - Returns M and sets *RESIDUE to N. | ||
101 | - | ||
102 | - If ALLOW_FUNC_ALIGN is true, do take functions' DECL_ALIGN_UNIT into | ||
103 | - account. This is not always possible due to PR 35705. | ||
104 | - */ | ||
105 | + Returns M and sets *RESIDUE to N. */ | ||
106 | |||
107 | static unsigned HOST_WIDE_INT | ||
108 | -get_pointer_modulus_and_residue (tree expr, unsigned HOST_WIDE_INT *residue, | ||
109 | - bool allow_func_align) | ||
110 | +get_pointer_modulus_and_residue (tree expr, unsigned HOST_WIDE_INT *residue) | ||
111 | { | ||
112 | enum tree_code code; | ||
113 | |||
114 | @@ -10068,9 +10063,8 @@ | ||
115 | } | ||
116 | } | ||
117 | |||
118 | - if (DECL_P (expr) | ||
119 | - && (allow_func_align || TREE_CODE (expr) != FUNCTION_DECL)) | ||
120 | - return DECL_ALIGN_UNIT (expr); | ||
121 | + if (DECL_P (expr)) | ||
122 | + return get_object_alignment (expr, BITS_PER_UNIT, ~0U) / BITS_PER_UNIT; | ||
123 | } | ||
124 | else if (code == POINTER_PLUS_EXPR) | ||
125 | { | ||
126 | @@ -10080,8 +10074,7 @@ | ||
127 | |||
128 | op0 = TREE_OPERAND (expr, 0); | ||
129 | STRIP_NOPS (op0); | ||
130 | - modulus = get_pointer_modulus_and_residue (op0, residue, | ||
131 | - allow_func_align); | ||
132 | + modulus = get_pointer_modulus_and_residue (op0, residue); | ||
133 | |||
134 | op1 = TREE_OPERAND (expr, 1); | ||
135 | STRIP_NOPS (op1); | ||
136 | @@ -11801,8 +11794,7 @@ | ||
137 | unsigned HOST_WIDE_INT modulus, residue; | ||
138 | unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (arg1); | ||
139 | |||
140 | - modulus = get_pointer_modulus_and_residue (arg0, &residue, | ||
141 | - integer_onep (arg1)); | ||
142 | + modulus = get_pointer_modulus_and_residue (arg0, &residue); | ||
143 | |||
144 | /* This works because modulus is a power of 2. If this weren't the | ||
145 | case, we'd have to replace it by its greatest power-of-2 | ||
146 | |||
147 | === added file 'gcc/testsuite/gcc.dg/torture/pr49169.c' | ||
148 | --- old/gcc/testsuite/gcc.dg/torture/pr49169.c 1970-01-01 00:00:00 +0000 | ||
149 | +++ new/gcc/testsuite/gcc.dg/torture/pr49169.c 2011-06-29 09:59:48 +0000 | ||
150 | @@ -0,0 +1,15 @@ | ||
151 | +/* { dg-do compile { target { arm*-*-* || mips*-*-* } } } */ | ||
152 | + | ||
153 | +#include <stdlib.h> | ||
154 | +#include <stdint.h> | ||
155 | + | ||
156 | +int | ||
157 | +main (void) | ||
158 | +{ | ||
159 | + void *p = main; | ||
160 | + if ((intptr_t) p & 1) | ||
161 | + abort (); | ||
162 | + return 0; | ||
163 | +} | ||
164 | + | ||
165 | +/* { dg-final { scan-assembler "abort" } } */ | ||
166 | |||