Knowledge (XXG)

Aliasing (computing)

Source 📝

335:
is also used to describe the situation where, due to either a hardware design choice or a hardware failure, one or more of the available address bits is not used in the memory selection process. This may be a design decision if there are more address bits available than are necessary to support the
57:
can be accessed through different symbolic names in the program. Thus, modifying the data through one name implicitly modifies the values associated with all aliased names, which may not be expected by the programmer. As a result, aliasing makes it particularly difficult to understand, analyze and
658:
If this change occurred to a different address bit, the decoding results would be different, but in general the effect would be the same: the loss of a single address bit cuts the available memory space in half, with resulting duplication (aliasing) of the remaining space.
74:). This is a common problem with functions that accept pointer arguments, and their tolerance (or the lack thereof) for aliasing must be carefully documented, particularly for functions that perform complex manipulations on memory areas passed to them. 298:
edition, see section 6.5, paragraph 7) specifies that it is illegal (with some exceptions) to access the same memory location using pointers of different types. A compiler may therefore assume that such pointers do not alias. This rule, known as the
489:
In the table above, each of the 8 unique combinations of address bits selects a different memory location. However, if one address bit (say A2) were to be shorted to ground, the table would be modified as follows:
303:, sometimes allows for impressive increases in performance, but has been known to break some otherwise valid code. Several software projects intentionally violate this portion of the C99 standard. For example, 655:
In this case, with A2 always being zero, the first four memory locations are duplicated and appear again as the second four. Memory locations 4 through 7 have become inaccessible.
82:
Controlled aliasing behaviour may be desirable in some cases (that is, aliasing behaviour that is specified, unlike that enabled by memory layout in C). It is common practice in
185:
will print out "2 3 4" as a result. If one wanted to bypass aliasing effects, one could copy the contents of the index variable into another and change the copy.
740: 196:
often have to make conservative assumptions about variables when aliasing is possible. For example, knowing the value of a variable (such as
763: 35: 785: 71: 695: 352:, since 2 = 8). Address bits (named A2 through A0) are decoded to select unique memory locations as follows, in standard 315:
does this because strict aliasing causes problems with optimization of inlined code. In such cases, when compiled with
70:
Aliasing can occur in any language that can refer to one location in memory with more than one name (for example, with
244:). However, if there is information about pointers, the constant propagation process could make a query like: can 790: 204:). However, the compiler cannot use this information after an assignment to another variable (for example, in C, 336:
installed memory device(s). In a failure, one or more address bits may be shorted together, or may be forced to
295: 291: 287: 316: 276: 337: 90: 710: 193: 348:
For this example, assuming a memory design with 8 locations, requiring only 3 address lines (or
308: 54: 311:, and required changes to the basic object structs in Python 3 to enable this optimization. The 97:
loops. This allows certain data structures to be modified directly with less code. For example,
757: 353: 280: 201: 259:
Another optimization impacted by aliasing is code reordering. If the compiler decides that
769: 39: 59: 62:
intend to make and compute useful information for understanding aliasing in programs.
779: 668: 676:
for uses of the word when applied to signal processing, including computer graphics
312: 17: 323:
is invoked to prevent unwanted optimizations that could yield unexpected code.
46: 673: 31: 772:– article on strict aliasing originally from the boost developer's wiki 304: 83: 725: 30:
For the term used in signals processing and computer graphics, see
156:# modifying @array, since $ element is ''aliased'' 87: 349: 228:
would be changed as well, so propagating the information that
93:
specifies, in some constructs, aliasing behaviour, such as in
766:– Informational article on type-based alias analysis in C++ 726:"Re: Invalid compilation without -fno-strict-aliasing" 286:
To enable such optimizations in a predictable manner,
200:
is 5) normally allows certain optimizations (such as
94: 216:. This could be the case after an assignment like 53:describes a situation in which a data location in 760:– informational article on NetBSD mailing list 267:, then code that uses or changes the value of 8: 340:(logic 0) or the supply voltage (logic 1). 159:# to each of @array's elements in turn. 34:. For aliasing in statistical design, see 153:# Increment $ element, thus automatically 27:Multiple names for the same data location 492: 358: 686: 220:. As an effect of this assignment to 7: 758:Aliasing, pointer casts and gcc 3.3 271:can be moved before the assignment 25: 711:"ANSI strict aliasing and Python" 232:is 5 to the statements following 770:Understand C/C++ Strict Aliasing 764:Type-based alias analysis in C++ 36:Aliasing (factorial experiments) 741:"Software Based Memory Testing" 709:Neil Schemenauer (2003-07-17). 696:"Understanding Strict Aliasing" 236:would be potentially wrong (if 1: 724:Linus Torvalds (2003-02-26). 252:? Then, if the answer is no, 739:Michael Barr (2012-07-27). 208:) because it could be that 189:Conflicts with optimization 807: 256:can be propagated safely. 29: 694:Mike Acton (2006-06-01). 275:, if this would improve 99: 38:. For the command, see 292:C programming language 240:is indeed an alias of 786:Compiler construction 294:(including its newer 177:"@array \n" 321:-fno-strict-aliasing 307:did so to implement 301:strict aliasing rule 202:constant propagation 91:programming language 283:to be carried out. 58:optimize programs. 309:reference counting 281:loop optimizations 263:is not aliased by 78:Specified aliasing 60:Aliasing analysers 653: 652: 487: 486: 327:Hardware aliasing 16:(Redirected from 798: 791:Program analysis 745: 744: 736: 730: 729: 721: 715: 714: 706: 700: 699: 691: 649: 636: 627: 614: 605: 592: 583: 570: 505:Memory location 493: 371:Memory location 359: 322: 288:the ISO standard 274: 270: 266: 262: 255: 251: 247: 243: 239: 235: 231: 227: 223: 219: 215: 211: 207: 199: 181: 178: 175: 172: 169: 166: 163: 160: 157: 154: 151: 148: 145: 142: 139: 136: 133: 130: 127: 124: 121: 118: 115: 112: 109: 106: 103: 96: 66:Aliased pointers 21: 18:Pointer aliasing 806: 805: 801: 800: 799: 797: 796: 795: 776: 775: 754: 749: 748: 738: 737: 733: 723: 722: 718: 708: 707: 703: 693: 692: 688: 683: 665: 645: 632: 623: 610: 601: 588: 579: 566: 329: 320: 279:or enable more 272: 268: 264: 260: 253: 249: 248:be an alias of 245: 241: 237: 233: 229: 225: 224:, the value of 221: 217: 213: 212:is an alias of 209: 205: 197: 191: 183: 182: 179: 176: 173: 170: 167: 164: 161: 158: 155: 152: 149: 146: 143: 140: 137: 134: 131: 128: 125: 122: 119: 116: 113: 110: 107: 104: 101: 80: 68: 43: 40:Alias (command) 28: 23: 22: 15: 12: 11: 5: 804: 802: 794: 793: 788: 778: 777: 774: 773: 767: 761: 753: 752:External links 750: 747: 746: 731: 716: 701: 685: 684: 682: 679: 678: 677: 671: 664: 661: 651: 650: 643: 640: 637: 629: 628: 621: 618: 615: 607: 606: 599: 596: 593: 585: 584: 577: 574: 571: 563: 562: 559: 556: 553: 549: 548: 545: 542: 539: 535: 534: 531: 528: 525: 521: 520: 517: 514: 511: 507: 506: 503: 500: 497: 485: 484: 481: 478: 475: 471: 470: 467: 464: 461: 457: 456: 453: 450: 447: 443: 442: 439: 436: 433: 429: 428: 425: 422: 419: 415: 414: 411: 408: 405: 401: 400: 397: 394: 391: 387: 386: 383: 380: 377: 373: 372: 369: 366: 363: 354:binary counter 346: 345: 328: 325: 190: 187: 100: 79: 76: 67: 64: 26: 24: 14: 13: 10: 9: 6: 4: 3: 2: 803: 792: 789: 787: 784: 783: 781: 771: 768: 765: 762: 759: 756: 755: 751: 742: 735: 732: 727: 720: 717: 712: 705: 702: 697: 690: 687: 680: 675: 672: 670: 669:Anti-aliasing 667: 666: 662: 660: 656: 648: 644: 641: 638: 635: 631: 630: 626: 622: 619: 616: 613: 609: 608: 604: 600: 597: 594: 591: 587: 586: 582: 578: 575: 572: 569: 565: 564: 560: 557: 554: 551: 550: 546: 543: 540: 537: 536: 532: 529: 526: 523: 522: 518: 515: 512: 509: 508: 504: 501: 498: 495: 494: 491: 482: 479: 476: 473: 472: 468: 465: 462: 459: 458: 454: 451: 448: 445: 444: 440: 437: 434: 431: 430: 426: 423: 420: 417: 416: 412: 409: 406: 403: 402: 398: 395: 392: 389: 388: 384: 381: 378: 375: 374: 370: 367: 364: 361: 360: 357: 355: 351: 343: 342: 341: 339: 334: 326: 324: 319:, the option 318: 314: 310: 306: 302: 297: 293: 289: 284: 282: 278: 257: 203: 195: 188: 186: 98: 92: 89: 85: 77: 75: 73: 65: 63: 61: 56: 52: 48: 41: 37: 33: 19: 734: 719: 704: 689: 657: 654: 646: 633: 624: 611: 602: 589: 580: 567: 488: 347: 332: 330: 313:Linux kernel 300: 285: 258: 192: 184: 81: 69: 50: 44: 780:Categories 681:References 305:Python 2.x 277:scheduling 218:y = &x 194:Optimizers 356:fashion: 331:The term 162:$ element 138:$ element 47:computing 674:Aliasing 663:See also 333:aliasing 290:for the 72:pointers 51:aliasing 32:Aliasing 344:Example 273:*y = 10 234:*y = 10 206:*y = 10 132:foreach 95:foreach 84:Fortran 338:ground 144:@array 105:@array 86:. The 55:memory 254:x = 5 174:print 350:bits 88:Perl 317:gcc 296:C99 45:In 782:: 561:3 547:2 533:1 519:0 502:A0 499:A1 496:A2 483:7 469:6 455:5 441:4 427:3 413:2 399:1 385:0 368:A0 365:A1 362:A2 265:*y 250:*y 238:*y 222:*y 210:*y 165:++ 135:my 129:); 102:my 49:, 743:. 728:. 713:. 698:. 647:3 642:1 639:1 634:0 625:2 620:0 617:1 612:0 603:1 598:1 595:0 590:0 581:0 576:0 573:0 568:0 558:1 555:1 552:0 544:0 541:1 538:0 530:1 527:0 524:0 516:0 513:0 510:0 480:1 477:1 474:1 466:0 463:1 460:1 452:1 449:0 446:1 438:0 435:0 432:1 424:1 421:1 418:0 410:0 407:1 404:0 396:1 393:0 390:0 382:0 379:0 376:0 269:x 261:x 246:x 242:x 230:x 226:x 214:x 198:x 180:; 171:} 168:; 150:{ 147:) 141:( 126:3 123:, 120:2 117:, 114:1 111:( 108:= 42:. 20:)

Index

Pointer aliasing
Aliasing
Aliasing (factorial experiments)
Alias (command)
computing
memory
Aliasing analysers
pointers
Fortran
Perl
programming language
Optimizers
constant propagation
scheduling
loop optimizations
the ISO standard
C programming language
C99
Python 2.x
reference counting
Linux kernel
gcc
ground
bits
binary counter
Anti-aliasing
Aliasing
"Understanding Strict Aliasing"
"ANSI strict aliasing and Python"
"Re: Invalid compilation without -fno-strict-aliasing"

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.