Commit e697303
committed
[llvm] Fix behavior of llvm.objectsize in presence of negative offset
When an object is located before it's allocation point, e.g.
char a[10];
char* b = a[-3];
If we ask for the maximum amount of memory addressable from `b` through
__builtin_object_size(b, 0)
It is better to return -1, even if we actually know everything about the
allocation point, than to return 0, which we currently do and that leads
to sanitizer raising invalid/incorrect diagnostic.1 parent a7e4478 commit e697303
File tree
2 files changed
+32
-8
lines changed- llvm
- lib/Analysis
- test/Transforms/LowerConstantIntrinsics
2 files changed
+32
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
567 | | - | |
568 | | - | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
569 | 574 | | |
570 | 575 | | |
571 | 576 | | |
| |||
580 | 585 | | |
581 | 586 | | |
582 | 587 | | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
583 | 593 | | |
584 | 594 | | |
585 | 595 | | |
| |||
Lines changed: 20 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
| 198 | + | |
199 | 199 | | |
200 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
201 | 215 | | |
202 | 216 | | |
203 | | - | |
| 217 | + | |
204 | 218 | | |
205 | 219 | | |
206 | 220 | | |
| |||
209 | 223 | | |
210 | 224 | | |
211 | 225 | | |
212 | | - | |
213 | | - | |
| 226 | + | |
| 227 | + | |
214 | 228 | | |
215 | 229 | | |
216 | 230 | | |
| |||
251 | 265 | | |
252 | 266 | | |
253 | 267 | | |
254 | | - | |
| 268 | + | |
255 | 269 | | |
256 | 270 | | |
257 | 271 | | |
258 | | - | |
| 272 | + | |
259 | 273 | | |
260 | 274 | | |
261 | 275 | | |
| |||
0 commit comments