Commit 9d05f76
committed
[TBAA] Don't emit pointer-tbaa for void pointers.
While there are no special rules in the standards regarding
void pointers and strict aliasing, emitting distinct tags for void
pointers break some common idioms and there is no good alternative to
re-write the code without strict-aliasing violations. An example is
to count the entries in an array of pointers:
int count_elements(void * values) {
void **seq = values;
int count;
for (count = 0; seq && seq[count]; count++);
return count;
}
https://clang.godbolt.org/z/8dTv51v8W
An example in the wild is from
#119099
This patch avoids emitting distinct tags for void pointers, to avoid
those idioms causing mis-compiles for now.1 parent 2c6ed5f commit 9d05f76
File tree
2 files changed
+11
-10
lines changed- clang
- lib/CodeGen
- test/CodeGen
2 files changed
+11
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
229 | 237 | | |
230 | 238 | | |
231 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
217 | 214 | | |
218 | 215 | | |
219 | 216 | | |
| |||
254 | 251 | | |
255 | 252 | | |
256 | 253 | | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
0 commit comments