Commit f3b4140
Dave Bartolomeo
C++/C#: Consistent handling of "may" vs. "must" memory accesses
In the IR, some memory accesses are "must" accesses (the entire memory location is always read or written), and some are "may" accesses (some, all, or none of the bits in the location are written). We previously had to special case specific "may" accesses in a few places. This change regularizes our handling of "may" accesses.
The `MemoryAccessKind` enumeration now describes only the extent of the access (the set of locations potentially accessed), but does not distinguish "must" from "may". The new predicates `Operand.hasMayMemoryAccess()` and `Instruction.hasResultMayMemoryAccess()` hold when the access is a "may" access.
Unaliased SSA now correctly ignores variables that are ever accessed via a "may" access.
Aliased SSA now distinguishes `MemoryLocation`s for "may" and "must" accesses. I've refactored `getOverlap()` into the core `getExtentOverlap()`, which considers only the extent, but not the "may" vs. "must", and `getOverlap()`, which tweaks the result of `getExtentOverlap()` based on "may" vs. "must" and read-only locations.
When determining the overlap between a `Phi` operand and its definition, we now use the result of the defining `Chi` instruction, if one exists. This gives exact definitions for `Phi` operands for virtual variables.1 parent 7d48220 commit f3b4140
File tree
19 files changed
+527
-342
lines changed- cpp/ql
- src/semmle/code/cpp/ir/implementation
- aliased_ssa
- internal
- raw
- unaliased_ssa
- internal
- test/library-tests/ir/ssa
- csharp/ql/src/semmle/code/csharp/ir/implementation
- raw
- unaliased_ssa
- internal
19 files changed
+527
-342
lines changedLines changed: 5 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | | - | |
6 | 4 | | |
7 | | - | |
8 | | - | |
| 5 | + | |
9 | 6 | | |
10 | 7 | | |
11 | 8 | | |
| |||
35 | 32 | | |
36 | 33 | | |
37 | 34 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | 35 | | |
49 | 36 | | |
50 | 37 | | |
| |||
56 | 43 | | |
57 | 44 | | |
58 | 45 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | 46 | | |
71 | 47 | | |
72 | 48 | | |
| |||
75 | 51 | | |
76 | 52 | | |
77 | 53 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 54 | + | |
| 55 | + | |
87 | 56 | | |
88 | | - | |
89 | | - | |
| 57 | + | |
| 58 | + | |
90 | 59 | | |
91 | 60 | | |
92 | 61 | | |
| |||
Lines changed: 25 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
553 | 563 | | |
554 | 564 | | |
555 | 565 | | |
| |||
1206 | 1216 | | |
1207 | 1217 | | |
1208 | 1218 | | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
1212 | 1222 | | |
1213 | 1223 | | |
1214 | 1224 | | |
| |||
1306 | 1316 | | |
1307 | 1317 | | |
1308 | 1318 | | |
1309 | | - | |
1310 | | - | |
1311 | | - | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
1312 | 1322 | | |
1313 | 1323 | | |
1314 | 1324 | | |
| |||
1318 | 1328 | | |
1319 | 1329 | | |
1320 | 1330 | | |
1321 | | - | |
1322 | | - | |
1323 | | - | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
1324 | 1334 | | |
1325 | 1335 | | |
1326 | 1336 | | |
| |||
1332 | 1342 | | |
1333 | 1343 | | |
1334 | 1344 | | |
1335 | | - | |
1336 | | - | |
1337 | | - | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
1338 | 1348 | | |
1339 | 1349 | | |
1340 | 1350 | | |
| |||
1345 | 1355 | | |
1346 | 1356 | | |
1347 | 1357 | | |
1348 | | - | |
1349 | | - | |
1350 | | - | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
1351 | 1361 | | |
1352 | 1362 | | |
1353 | 1363 | | |
| |||
Lines changed: 27 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
197 | 207 | | |
198 | 208 | | |
199 | 209 | | |
| |||
397 | 407 | | |
398 | 408 | | |
399 | 409 | | |
400 | | - | |
| 410 | + | |
401 | 411 | | |
402 | 412 | | |
403 | | - | |
| 413 | + | |
404 | 414 | | |
405 | 415 | | |
406 | | - | |
| 416 | + | |
407 | 417 | | |
408 | 418 | | |
409 | 419 | | |
| |||
418 | 428 | | |
419 | 429 | | |
420 | 430 | | |
421 | | - | |
| 431 | + | |
422 | 432 | | |
423 | 433 | | |
424 | | - | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
425 | 447 | | |
426 | 448 | | |
427 | 449 | | |
| |||
0 commit comments