/usr/share/doc/llvm-4.0-doc/html/Passes.html is in llvm-4.0-doc 1:4.0.1-10.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LLVM’s Analysis and Transform Passes — LLVM 4 documentation</title>
<link rel="stylesheet" href="_static/llvm-theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '4',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="YAML I/O" href="YamlIO.html" />
<link rel="prev" title="LLVM 4.0.0 Release Notes" href="ReleaseNotes.html" />
<style type="text/css">
table.right { float: right; margin-left: 20px; }
table.right td { border: 1px solid #ccc; }
</style>
</head>
<body>
<div class="logo">
<a href="index.html">
<img src="_static/logo.png"
alt="LLVM Logo" width="250" height="88"/></a>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="YamlIO.html" title="YAML I/O"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="ReleaseNotes.html" title="LLVM 4.0.0 Release Notes"
accesskey="P">previous</a> |</li>
<li><a href="http://llvm.org/">LLVM Home</a> | </li>
<li><a href="index.html">Documentation</a>»</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="body" role="main">
<div class="section" id="llvm-s-analysis-and-transform-passes">
<h1>LLVM’s Analysis and Transform Passes<a class="headerlink" href="#llvm-s-analysis-and-transform-passes" title="Permalink to this headline">¶</a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#introduction" id="id1">Introduction</a></li>
<li><a class="reference internal" href="#analysis-passes" id="id2">Analysis Passes</a><ul>
<li><a class="reference internal" href="#aa-eval-exhaustive-alias-analysis-precision-evaluator" id="id3"><code class="docutils literal"><span class="pre">-aa-eval</span></code>: Exhaustive Alias Analysis Precision Evaluator</a></li>
<li><a class="reference internal" href="#basicaa-basic-alias-analysis-stateless-aa-impl" id="id4"><code class="docutils literal"><span class="pre">-basicaa</span></code>: Basic Alias Analysis (stateless AA impl)</a></li>
<li><a class="reference internal" href="#basiccg-basic-callgraph-construction" id="id5"><code class="docutils literal"><span class="pre">-basiccg</span></code>: Basic CallGraph Construction</a></li>
<li><a class="reference internal" href="#count-aa-count-alias-analysis-query-responses" id="id6"><code class="docutils literal"><span class="pre">-count-aa</span></code>: Count Alias Analysis Query Responses</a></li>
<li><a class="reference internal" href="#da-dependence-analysis" id="id7"><code class="docutils literal"><span class="pre">-da</span></code>: Dependence Analysis</a></li>
<li><a class="reference internal" href="#debug-aa-aa-use-debugger" id="id8"><code class="docutils literal"><span class="pre">-debug-aa</span></code>: AA use debugger</a></li>
<li><a class="reference internal" href="#domfrontier-dominance-frontier-construction" id="id9"><code class="docutils literal"><span class="pre">-domfrontier</span></code>: Dominance Frontier Construction</a></li>
<li><a class="reference internal" href="#domtree-dominator-tree-construction" id="id10"><code class="docutils literal"><span class="pre">-domtree</span></code>: Dominator Tree Construction</a></li>
<li><a class="reference internal" href="#dot-callgraph-print-call-graph-to-dot-file" id="id11"><code class="docutils literal"><span class="pre">-dot-callgraph</span></code>: Print Call Graph to “dot” file</a></li>
<li><a class="reference internal" href="#dot-cfg-print-cfg-of-function-to-dot-file" id="id12"><code class="docutils literal"><span class="pre">-dot-cfg</span></code>: Print CFG of function to “dot” file</a></li>
<li><a class="reference internal" href="#dot-cfg-only-print-cfg-of-function-to-dot-file-with-no-function-bodies" id="id13"><code class="docutils literal"><span class="pre">-dot-cfg-only</span></code>: Print CFG of function to “dot” file (with no function bodies)</a></li>
<li><a class="reference internal" href="#dot-dom-print-dominance-tree-of-function-to-dot-file" id="id14"><code class="docutils literal"><span class="pre">-dot-dom</span></code>: Print dominance tree of function to “dot” file</a></li>
<li><a class="reference internal" href="#dot-dom-only-print-dominance-tree-of-function-to-dot-file-with-no-function-bodies" id="id15"><code class="docutils literal"><span class="pre">-dot-dom-only</span></code>: Print dominance tree of function to “dot” file (with no function bodies)</a></li>
<li><a class="reference internal" href="#dot-postdom-print-postdominance-tree-of-function-to-dot-file" id="id16"><code class="docutils literal"><span class="pre">-dot-postdom</span></code>: Print postdominance tree of function to “dot” file</a></li>
<li><a class="reference internal" href="#dot-postdom-only-print-postdominance-tree-of-function-to-dot-file-with-no-function-bodies" id="id17"><code class="docutils literal"><span class="pre">-dot-postdom-only</span></code>: Print postdominance tree of function to “dot” file (with no function bodies)</a></li>
<li><a class="reference internal" href="#globalsmodref-aa-simple-mod-ref-analysis-for-globals" id="id18"><code class="docutils literal"><span class="pre">-globalsmodref-aa</span></code>: Simple mod/ref analysis for globals</a></li>
<li><a class="reference internal" href="#instcount-counts-the-various-types-of-instructions" id="id19"><code class="docutils literal"><span class="pre">-instcount</span></code>: Counts the various types of <code class="docutils literal"><span class="pre">Instruction</span></code>s</a></li>
<li><a class="reference internal" href="#intervals-interval-partition-construction" id="id20"><code class="docutils literal"><span class="pre">-intervals</span></code>: Interval Partition Construction</a></li>
<li><a class="reference internal" href="#iv-users-induction-variable-users" id="id21"><code class="docutils literal"><span class="pre">-iv-users</span></code>: Induction Variable Users</a></li>
<li><a class="reference internal" href="#lazy-value-info-lazy-value-information-analysis" id="id22"><code class="docutils literal"><span class="pre">-lazy-value-info</span></code>: Lazy Value Information Analysis</a></li>
<li><a class="reference internal" href="#libcall-aa-libcall-alias-analysis" id="id23"><code class="docutils literal"><span class="pre">-libcall-aa</span></code>: LibCall Alias Analysis</a></li>
<li><a class="reference internal" href="#lint-statically-lint-checks-llvm-ir" id="id24"><code class="docutils literal"><span class="pre">-lint</span></code>: Statically lint-checks LLVM IR</a></li>
<li><a class="reference internal" href="#loops-natural-loop-information" id="id25"><code class="docutils literal"><span class="pre">-loops</span></code>: Natural Loop Information</a></li>
<li><a class="reference internal" href="#memdep-memory-dependence-analysis" id="id26"><code class="docutils literal"><span class="pre">-memdep</span></code>: Memory Dependence Analysis</a></li>
<li><a class="reference internal" href="#module-debuginfo-decodes-module-level-debug-info" id="id27"><code class="docutils literal"><span class="pre">-module-debuginfo</span></code>: Decodes module-level debug info</a></li>
<li><a class="reference internal" href="#postdomfrontier-post-dominance-frontier-construction" id="id28"><code class="docutils literal"><span class="pre">-postdomfrontier</span></code>: Post-Dominance Frontier Construction</a></li>
<li><a class="reference internal" href="#postdomtree-post-dominator-tree-construction" id="id29"><code class="docutils literal"><span class="pre">-postdomtree</span></code>: Post-Dominator Tree Construction</a></li>
<li><a class="reference internal" href="#print-alias-sets-alias-set-printer" id="id30"><code class="docutils literal"><span class="pre">-print-alias-sets</span></code>: Alias Set Printer</a></li>
<li><a class="reference internal" href="#print-callgraph-print-a-call-graph" id="id31"><code class="docutils literal"><span class="pre">-print-callgraph</span></code>: Print a call graph</a></li>
<li><a class="reference internal" href="#print-callgraph-sccs-print-sccs-of-the-call-graph" id="id32"><code class="docutils literal"><span class="pre">-print-callgraph-sccs</span></code>: Print SCCs of the Call Graph</a></li>
<li><a class="reference internal" href="#print-cfg-sccs-print-sccs-of-each-function-cfg" id="id33"><code class="docutils literal"><span class="pre">-print-cfg-sccs</span></code>: Print SCCs of each function CFG</a></li>
<li><a class="reference internal" href="#print-dom-info-dominator-info-printer" id="id34"><code class="docutils literal"><span class="pre">-print-dom-info</span></code>: Dominator Info Printer</a></li>
<li><a class="reference internal" href="#print-externalfnconstants-print-external-fn-callsites-passed-constants" id="id35"><code class="docutils literal"><span class="pre">-print-externalfnconstants</span></code>: Print external fn callsites passed constants</a></li>
<li><a class="reference internal" href="#print-function-print-function-to-stderr" id="id36"><code class="docutils literal"><span class="pre">-print-function</span></code>: Print function to stderr</a></li>
<li><a class="reference internal" href="#print-module-print-module-to-stderr" id="id37"><code class="docutils literal"><span class="pre">-print-module</span></code>: Print module to stderr</a></li>
<li><a class="reference internal" href="#print-used-types-find-used-types" id="id38"><code class="docutils literal"><span class="pre">-print-used-types</span></code>: Find Used Types</a></li>
<li><a class="reference internal" href="#regions-detect-single-entry-single-exit-regions" id="id39"><code class="docutils literal"><span class="pre">-regions</span></code>: Detect single entry single exit regions</a></li>
<li><a class="reference internal" href="#scalar-evolution-scalar-evolution-analysis" id="id40"><code class="docutils literal"><span class="pre">-scalar-evolution</span></code>: Scalar Evolution Analysis</a></li>
<li><a class="reference internal" href="#scev-aa-scalarevolution-based-alias-analysis" id="id41"><code class="docutils literal"><span class="pre">-scev-aa</span></code>: ScalarEvolution-based Alias Analysis</a></li>
<li><a class="reference internal" href="#targetdata-target-data-layout" id="id42"><code class="docutils literal"><span class="pre">-targetdata</span></code>: Target Data Layout</a></li>
</ul>
</li>
<li><a class="reference internal" href="#transform-passes" id="id43">Transform Passes</a><ul>
<li><a class="reference internal" href="#adce-aggressive-dead-code-elimination" id="id44"><code class="docutils literal"><span class="pre">-adce</span></code>: Aggressive Dead Code Elimination</a></li>
<li><a class="reference internal" href="#always-inline-inliner-for-always-inline-functions" id="id45"><code class="docutils literal"><span class="pre">-always-inline</span></code>: Inliner for <code class="docutils literal"><span class="pre">always_inline</span></code> functions</a></li>
<li><a class="reference internal" href="#argpromotion-promote-by-reference-arguments-to-scalars" id="id46"><code class="docutils literal"><span class="pre">-argpromotion</span></code>: Promote ‘by reference’ arguments to scalars</a></li>
<li><a class="reference internal" href="#bb-vectorize-basic-block-vectorization" id="id47"><code class="docutils literal"><span class="pre">-bb-vectorize</span></code>: Basic-Block Vectorization</a></li>
<li><a class="reference internal" href="#block-placement-profile-guided-basic-block-placement" id="id48"><code class="docutils literal"><span class="pre">-block-placement</span></code>: Profile Guided Basic Block Placement</a></li>
<li><a class="reference internal" href="#break-crit-edges-break-critical-edges-in-cfg" id="id49"><code class="docutils literal"><span class="pre">-break-crit-edges</span></code>: Break critical edges in CFG</a></li>
<li><a class="reference internal" href="#codegenprepare-optimize-for-code-generation" id="id50"><code class="docutils literal"><span class="pre">-codegenprepare</span></code>: Optimize for code generation</a></li>
<li><a class="reference internal" href="#constmerge-merge-duplicate-global-constants" id="id51"><code class="docutils literal"><span class="pre">-constmerge</span></code>: Merge Duplicate Global Constants</a></li>
<li><a class="reference internal" href="#constprop-simple-constant-propagation" id="id52"><code class="docutils literal"><span class="pre">-constprop</span></code>: Simple constant propagation</a></li>
<li><a class="reference internal" href="#dce-dead-code-elimination" id="id53"><code class="docutils literal"><span class="pre">-dce</span></code>: Dead Code Elimination</a></li>
<li><a class="reference internal" href="#deadargelim-dead-argument-elimination" id="id54"><code class="docutils literal"><span class="pre">-deadargelim</span></code>: Dead Argument Elimination</a></li>
<li><a class="reference internal" href="#deadtypeelim-dead-type-elimination" id="id55"><code class="docutils literal"><span class="pre">-deadtypeelim</span></code>: Dead Type Elimination</a></li>
<li><a class="reference internal" href="#die-dead-instruction-elimination" id="id56"><code class="docutils literal"><span class="pre">-die</span></code>: Dead Instruction Elimination</a></li>
<li><a class="reference internal" href="#dse-dead-store-elimination" id="id57"><code class="docutils literal"><span class="pre">-dse</span></code>: Dead Store Elimination</a></li>
<li><a class="reference internal" href="#functionattrs-deduce-function-attributes" id="id58"><code class="docutils literal"><span class="pre">-functionattrs</span></code>: Deduce function attributes</a></li>
<li><a class="reference internal" href="#globaldce-dead-global-elimination" id="id59"><code class="docutils literal"><span class="pre">-globaldce</span></code>: Dead Global Elimination</a></li>
<li><a class="reference internal" href="#globalopt-global-variable-optimizer" id="id60"><code class="docutils literal"><span class="pre">-globalopt</span></code>: Global Variable Optimizer</a></li>
<li><a class="reference internal" href="#gvn-global-value-numbering" id="id61"><code class="docutils literal"><span class="pre">-gvn</span></code>: Global Value Numbering</a></li>
<li><a class="reference internal" href="#indvars-canonicalize-induction-variables" id="id62"><code class="docutils literal"><span class="pre">-indvars</span></code>: Canonicalize Induction Variables</a></li>
<li><a class="reference internal" href="#inline-function-integration-inlining" id="id63"><code class="docutils literal"><span class="pre">-inline</span></code>: Function Integration/Inlining</a></li>
<li><a class="reference internal" href="#instcombine-combine-redundant-instructions" id="id64"><code class="docutils literal"><span class="pre">-instcombine</span></code>: Combine redundant instructions</a></li>
<li><a class="reference internal" href="#internalize-internalize-global-symbols" id="id65"><code class="docutils literal"><span class="pre">-internalize</span></code>: Internalize Global Symbols</a></li>
<li><a class="reference internal" href="#ipconstprop-interprocedural-constant-propagation" id="id66"><code class="docutils literal"><span class="pre">-ipconstprop</span></code>: Interprocedural constant propagation</a></li>
<li><a class="reference internal" href="#ipsccp-interprocedural-sparse-conditional-constant-propagation" id="id67"><code class="docutils literal"><span class="pre">-ipsccp</span></code>: Interprocedural Sparse Conditional Constant Propagation</a></li>
<li><a class="reference internal" href="#jump-threading-jump-threading" id="id68"><code class="docutils literal"><span class="pre">-jump-threading</span></code>: Jump Threading</a></li>
<li><a class="reference internal" href="#lcssa-loop-closed-ssa-form-pass" id="id69"><code class="docutils literal"><span class="pre">-lcssa</span></code>: Loop-Closed SSA Form Pass</a></li>
<li><a class="reference internal" href="#licm-loop-invariant-code-motion" id="id70"><code class="docutils literal"><span class="pre">-licm</span></code>: Loop Invariant Code Motion</a></li>
<li><a class="reference internal" href="#loop-deletion-delete-dead-loops" id="id71"><code class="docutils literal"><span class="pre">-loop-deletion</span></code>: Delete dead loops</a></li>
<li><a class="reference internal" href="#loop-extract-extract-loops-into-new-functions" id="id72"><code class="docutils literal"><span class="pre">-loop-extract</span></code>: Extract loops into new functions</a></li>
<li><a class="reference internal" href="#loop-extract-single-extract-at-most-one-loop-into-a-new-function" id="id73"><code class="docutils literal"><span class="pre">-loop-extract-single</span></code>: Extract at most one loop into a new function</a></li>
<li><a class="reference internal" href="#loop-reduce-loop-strength-reduction" id="id74"><code class="docutils literal"><span class="pre">-loop-reduce</span></code>: Loop Strength Reduction</a></li>
<li><a class="reference internal" href="#loop-rotate-rotate-loops" id="id75"><code class="docutils literal"><span class="pre">-loop-rotate</span></code>: Rotate Loops</a></li>
<li><a class="reference internal" href="#loop-simplify-canonicalize-natural-loops" id="id76"><code class="docutils literal"><span class="pre">-loop-simplify</span></code>: Canonicalize natural loops</a></li>
<li><a class="reference internal" href="#loop-unroll-unroll-loops" id="id77"><code class="docutils literal"><span class="pre">-loop-unroll</span></code>: Unroll loops</a></li>
<li><a class="reference internal" href="#loop-unswitch-unswitch-loops" id="id78"><code class="docutils literal"><span class="pre">-loop-unswitch</span></code>: Unswitch loops</a></li>
<li><a class="reference internal" href="#loweratomic-lower-atomic-intrinsics-to-non-atomic-form" id="id79"><code class="docutils literal"><span class="pre">-loweratomic</span></code>: Lower atomic intrinsics to non-atomic form</a></li>
<li><a class="reference internal" href="#lowerinvoke-lower-invokes-to-calls-for-unwindless-code-generators" id="id80"><code class="docutils literal"><span class="pre">-lowerinvoke</span></code>: Lower invokes to calls, for unwindless code generators</a></li>
<li><a class="reference internal" href="#lowerswitch-lower-switchinsts-to-branches" id="id81"><code class="docutils literal"><span class="pre">-lowerswitch</span></code>: Lower <code class="docutils literal"><span class="pre">SwitchInst</span></code>s to branches</a></li>
<li><a class="reference internal" href="#mem2reg-promote-memory-to-register" id="id82"><code class="docutils literal"><span class="pre">-mem2reg</span></code>: Promote Memory to Register</a></li>
<li><a class="reference internal" href="#memcpyopt-memcpy-optimization" id="id83"><code class="docutils literal"><span class="pre">-memcpyopt</span></code>: MemCpy Optimization</a></li>
<li><a class="reference internal" href="#mergefunc-merge-functions" id="id84"><code class="docutils literal"><span class="pre">-mergefunc</span></code>: Merge Functions</a></li>
<li><a class="reference internal" href="#mergereturn-unify-function-exit-nodes" id="id85"><code class="docutils literal"><span class="pre">-mergereturn</span></code>: Unify function exit nodes</a></li>
<li><a class="reference internal" href="#partial-inliner-partial-inliner" id="id86"><code class="docutils literal"><span class="pre">-partial-inliner</span></code>: Partial Inliner</a></li>
<li><a class="reference internal" href="#prune-eh-remove-unused-exception-handling-info" id="id87"><code class="docutils literal"><span class="pre">-prune-eh</span></code>: Remove unused exception handling info</a></li>
<li><a class="reference internal" href="#reassociate-reassociate-expressions" id="id88"><code class="docutils literal"><span class="pre">-reassociate</span></code>: Reassociate expressions</a></li>
<li><a class="reference internal" href="#reg2mem-demote-all-values-to-stack-slots" id="id89"><code class="docutils literal"><span class="pre">-reg2mem</span></code>: Demote all values to stack slots</a></li>
<li><a class="reference internal" href="#sroa-scalar-replacement-of-aggregates" id="id90"><code class="docutils literal"><span class="pre">-sroa</span></code>: Scalar Replacement of Aggregates</a></li>
<li><a class="reference internal" href="#sccp-sparse-conditional-constant-propagation" id="id91"><code class="docutils literal"><span class="pre">-sccp</span></code>: Sparse Conditional Constant Propagation</a></li>
<li><a class="reference internal" href="#simplifycfg-simplify-the-cfg" id="id92"><code class="docutils literal"><span class="pre">-simplifycfg</span></code>: Simplify the CFG</a></li>
<li><a class="reference internal" href="#sink-code-sinking" id="id93"><code class="docutils literal"><span class="pre">-sink</span></code>: Code sinking</a></li>
<li><a class="reference internal" href="#strip-strip-all-symbols-from-a-module" id="id94"><code class="docutils literal"><span class="pre">-strip</span></code>: Strip all symbols from a module</a></li>
<li><a class="reference internal" href="#strip-dead-debug-info-strip-debug-info-for-unused-symbols" id="id95"><code class="docutils literal"><span class="pre">-strip-dead-debug-info</span></code>: Strip debug info for unused symbols</a></li>
<li><a class="reference internal" href="#strip-dead-prototypes-strip-unused-function-prototypes" id="id96"><code class="docutils literal"><span class="pre">-strip-dead-prototypes</span></code>: Strip Unused Function Prototypes</a></li>
<li><a class="reference internal" href="#strip-debug-declare-strip-all-llvm-dbg-declare-intrinsics" id="id97"><code class="docutils literal"><span class="pre">-strip-debug-declare</span></code>: Strip all <code class="docutils literal"><span class="pre">llvm.dbg.declare</span></code> intrinsics</a></li>
<li><a class="reference internal" href="#strip-nondebug-strip-all-symbols-except-dbg-symbols-from-a-module" id="id98"><code class="docutils literal"><span class="pre">-strip-nondebug</span></code>: Strip all symbols, except dbg symbols, from a module</a></li>
<li><a class="reference internal" href="#tailcallelim-tail-call-elimination" id="id99"><code class="docutils literal"><span class="pre">-tailcallelim</span></code>: Tail Call Elimination</a></li>
</ul>
</li>
<li><a class="reference internal" href="#utility-passes" id="id100">Utility Passes</a><ul>
<li><a class="reference internal" href="#deadarghax0r-dead-argument-hacking-bugpoint-use-only-do-not-use" id="id101"><code class="docutils literal"><span class="pre">-deadarghaX0r</span></code>: Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)</a></li>
<li><a class="reference internal" href="#extract-blocks-extract-basic-blocks-from-module-for-bugpoint-use" id="id102"><code class="docutils literal"><span class="pre">-extract-blocks</span></code>: Extract Basic Blocks From Module (for bugpoint use)</a></li>
<li><a class="reference internal" href="#instnamer-assign-names-to-anonymous-instructions" id="id103"><code class="docutils literal"><span class="pre">-instnamer</span></code>: Assign names to anonymous instructions</a></li>
<li><a class="reference internal" href="#verify-module-verifier" id="id104"><code class="docutils literal"><span class="pre">-verify</span></code>: Module Verifier</a></li>
<li><a class="reference internal" href="#view-cfg-view-cfg-of-function" id="id105"><code class="docutils literal"><span class="pre">-view-cfg</span></code>: View CFG of function</a></li>
<li><a class="reference internal" href="#view-cfg-only-view-cfg-of-function-with-no-function-bodies" id="id106"><code class="docutils literal"><span class="pre">-view-cfg-only</span></code>: View CFG of function (with no function bodies)</a></li>
<li><a class="reference internal" href="#view-dom-view-dominance-tree-of-function" id="id107"><code class="docutils literal"><span class="pre">-view-dom</span></code>: View dominance tree of function</a></li>
<li><a class="reference internal" href="#view-dom-only-view-dominance-tree-of-function-with-no-function-bodies" id="id108"><code class="docutils literal"><span class="pre">-view-dom-only</span></code>: View dominance tree of function (with no function bodies)</a></li>
<li><a class="reference internal" href="#view-postdom-view-postdominance-tree-of-function" id="id109"><code class="docutils literal"><span class="pre">-view-postdom</span></code>: View postdominance tree of function</a></li>
<li><a class="reference internal" href="#view-postdom-only-view-postdominance-tree-of-function-with-no-function-bodies" id="id110"><code class="docutils literal"><span class="pre">-view-postdom-only</span></code>: View postdominance tree of function (with no function bodies)</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="introduction">
<h2><a class="toc-backref" href="#id1">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>This document serves as a high level summary of the optimization features that
LLVM provides. Optimizations are implemented as Passes that traverse some
portion of a program to either collect information or transform the program.
The table below divides the passes that LLVM provides into three categories.
Analysis passes compute information that other passes can use or for debugging
or program visualization purposes. Transform passes can use (or invalidate)
the analysis passes. Transform passes all mutate the program in some way.
Utility passes provides some utility but don’t otherwise fit categorization.
For example passes to extract functions to bitcode or write a module to bitcode
are neither analysis nor transform passes. The table of contents above
provides a quick summary of each pass and links to the more complete pass
description later in the document.</p>
</div>
<div class="section" id="analysis-passes">
<h2><a class="toc-backref" href="#id2">Analysis Passes</a><a class="headerlink" href="#analysis-passes" title="Permalink to this headline">¶</a></h2>
<p>This section describes the LLVM Analysis Passes.</p>
<div class="section" id="aa-eval-exhaustive-alias-analysis-precision-evaluator">
<h3><a class="toc-backref" href="#id3"><code class="docutils literal"><span class="pre">-aa-eval</span></code>: Exhaustive Alias Analysis Precision Evaluator</a><a class="headerlink" href="#aa-eval-exhaustive-alias-analysis-precision-evaluator" title="Permalink to this headline">¶</a></h3>
<p>This is a simple N^2 alias analysis accuracy evaluator. Basically, for each
function in the program, it simply queries to see how the alias analysis
implementation answers alias queries between each pair of pointers in the
function.</p>
<p>This is inspired and adapted from code by: Naveen Neelakantam, Francesco
Spadini, and Wojciech Stryjewski.</p>
</div>
<div class="section" id="basicaa-basic-alias-analysis-stateless-aa-impl">
<h3><a class="toc-backref" href="#id4"><code class="docutils literal"><span class="pre">-basicaa</span></code>: Basic Alias Analysis (stateless AA impl)</a><a class="headerlink" href="#basicaa-basic-alias-analysis-stateless-aa-impl" title="Permalink to this headline">¶</a></h3>
<p>A basic alias analysis pass that implements identities (two different globals
cannot alias, etc), but does no stateful analysis.</p>
</div>
<div class="section" id="basiccg-basic-callgraph-construction">
<h3><a class="toc-backref" href="#id5"><code class="docutils literal"><span class="pre">-basiccg</span></code>: Basic CallGraph Construction</a><a class="headerlink" href="#basiccg-basic-callgraph-construction" title="Permalink to this headline">¶</a></h3>
<p>Yet to be written.</p>
</div>
<div class="section" id="count-aa-count-alias-analysis-query-responses">
<h3><a class="toc-backref" href="#id6"><code class="docutils literal"><span class="pre">-count-aa</span></code>: Count Alias Analysis Query Responses</a><a class="headerlink" href="#count-aa-count-alias-analysis-query-responses" title="Permalink to this headline">¶</a></h3>
<p>A pass which can be used to count how many alias queries are being made and how
the alias analysis implementation being used responds.</p>
</div>
<div class="section" id="da-dependence-analysis">
<h3><a class="toc-backref" href="#id7"><code class="docutils literal"><span class="pre">-da</span></code>: Dependence Analysis</a><a class="headerlink" href="#da-dependence-analysis" title="Permalink to this headline">¶</a></h3>
<p>Dependence analysis framework, which is used to detect dependences in memory
accesses.</p>
</div>
<div class="section" id="debug-aa-aa-use-debugger">
<h3><a class="toc-backref" href="#id8"><code class="docutils literal"><span class="pre">-debug-aa</span></code>: AA use debugger</a><a class="headerlink" href="#debug-aa-aa-use-debugger" title="Permalink to this headline">¶</a></h3>
<p>This simple pass checks alias analysis users to ensure that if they create a
new value, they do not query AA without informing it of the value. It acts as
a shim over any other AA pass you want.</p>
<p>Yes keeping track of every value in the program is expensive, but this is a
debugging pass.</p>
</div>
<div class="section" id="domfrontier-dominance-frontier-construction">
<h3><a class="toc-backref" href="#id9"><code class="docutils literal"><span class="pre">-domfrontier</span></code>: Dominance Frontier Construction</a><a class="headerlink" href="#domfrontier-dominance-frontier-construction" title="Permalink to this headline">¶</a></h3>
<p>This pass is a simple dominator construction algorithm for finding forward
dominator frontiers.</p>
</div>
<div class="section" id="domtree-dominator-tree-construction">
<h3><a class="toc-backref" href="#id10"><code class="docutils literal"><span class="pre">-domtree</span></code>: Dominator Tree Construction</a><a class="headerlink" href="#domtree-dominator-tree-construction" title="Permalink to this headline">¶</a></h3>
<p>This pass is a simple dominator construction algorithm for finding forward
dominators.</p>
</div>
<div class="section" id="dot-callgraph-print-call-graph-to-dot-file">
<h3><a class="toc-backref" href="#id11"><code class="docutils literal"><span class="pre">-dot-callgraph</span></code>: Print Call Graph to “dot” file</a><a class="headerlink" href="#dot-callgraph-print-call-graph-to-dot-file" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal"><span class="pre">opt</span></code>, prints the call graph into a <code class="docutils literal"><span class="pre">.dot</span></code>
graph. This graph can then be processed with the “dot” tool to convert it to
postscript or some other suitable format.</p>
</div>
<div class="section" id="dot-cfg-print-cfg-of-function-to-dot-file">
<h3><a class="toc-backref" href="#id12"><code class="docutils literal"><span class="pre">-dot-cfg</span></code>: Print CFG of function to “dot” file</a><a class="headerlink" href="#dot-cfg-print-cfg-of-function-to-dot-file" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal"><span class="pre">opt</span></code>, prints the control flow graph into a
<code class="docutils literal"><span class="pre">.dot</span></code> graph. This graph can then be processed with the <strong class="program">dot</strong> tool
to convert it to postscript or some other suitable format.</p>
</div>
<div class="section" id="dot-cfg-only-print-cfg-of-function-to-dot-file-with-no-function-bodies">
<h3><a class="toc-backref" href="#id13"><code class="docutils literal"><span class="pre">-dot-cfg-only</span></code>: Print CFG of function to “dot” file (with no function bodies)</a><a class="headerlink" href="#dot-cfg-only-print-cfg-of-function-to-dot-file-with-no-function-bodies" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal"><span class="pre">opt</span></code>, prints the control flow graph into a
<code class="docutils literal"><span class="pre">.dot</span></code> graph, omitting the function bodies. This graph can then be processed
with the <strong class="program">dot</strong> tool to convert it to postscript or some other suitable
format.</p>
</div>
<div class="section" id="dot-dom-print-dominance-tree-of-function-to-dot-file">
<h3><a class="toc-backref" href="#id14"><code class="docutils literal"><span class="pre">-dot-dom</span></code>: Print dominance tree of function to “dot” file</a><a class="headerlink" href="#dot-dom-print-dominance-tree-of-function-to-dot-file" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal"><span class="pre">opt</span></code>, prints the dominator tree into a <code class="docutils literal"><span class="pre">.dot</span></code>
graph. This graph can then be processed with the <strong class="program">dot</strong> tool to
convert it to postscript or some other suitable format.</p>
</div>
<div class="section" id="dot-dom-only-print-dominance-tree-of-function-to-dot-file-with-no-function-bodies">
<h3><a class="toc-backref" href="#id15"><code class="docutils literal"><span class="pre">-dot-dom-only</span></code>: Print dominance tree of function to “dot” file (with no function bodies)</a><a class="headerlink" href="#dot-dom-only-print-dominance-tree-of-function-to-dot-file-with-no-function-bodies" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal"><span class="pre">opt</span></code>, prints the dominator tree into a <code class="docutils literal"><span class="pre">.dot</span></code>
graph, omitting the function bodies. This graph can then be processed with the
<strong class="program">dot</strong> tool to convert it to postscript or some other suitable format.</p>
</div>
<div class="section" id="dot-postdom-print-postdominance-tree-of-function-to-dot-file">
<h3><a class="toc-backref" href="#id16"><code class="docutils literal"><span class="pre">-dot-postdom</span></code>: Print postdominance tree of function to “dot” file</a><a class="headerlink" href="#dot-postdom-print-postdominance-tree-of-function-to-dot-file" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal"><span class="pre">opt</span></code>, prints the post dominator tree into a
<code class="docutils literal"><span class="pre">.dot</span></code> graph. This graph can then be processed with the <strong class="program">dot</strong> tool
to convert it to postscript or some other suitable format.</p>
</div>
<div class="section" id="dot-postdom-only-print-postdominance-tree-of-function-to-dot-file-with-no-function-bodies">
<h3><a class="toc-backref" href="#id17"><code class="docutils literal"><span class="pre">-dot-postdom-only</span></code>: Print postdominance tree of function to “dot” file (with no function bodies)</a><a class="headerlink" href="#dot-postdom-only-print-postdominance-tree-of-function-to-dot-file-with-no-function-bodies" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal"><span class="pre">opt</span></code>, prints the post dominator tree into a
<code class="docutils literal"><span class="pre">.dot</span></code> graph, omitting the function bodies. This graph can then be processed
with the <strong class="program">dot</strong> tool to convert it to postscript or some other suitable
format.</p>
</div>
<div class="section" id="globalsmodref-aa-simple-mod-ref-analysis-for-globals">
<h3><a class="toc-backref" href="#id18"><code class="docutils literal"><span class="pre">-globalsmodref-aa</span></code>: Simple mod/ref analysis for globals</a><a class="headerlink" href="#globalsmodref-aa-simple-mod-ref-analysis-for-globals" title="Permalink to this headline">¶</a></h3>
<p>This simple pass provides alias and mod/ref information for global values that
do not have their address taken, and keeps track of whether functions read or
write memory (are “pure”). For this simple (but very common) case, we can
provide pretty accurate and useful information.</p>
</div>
<div class="section" id="instcount-counts-the-various-types-of-instructions">
<h3><a class="toc-backref" href="#id19"><code class="docutils literal"><span class="pre">-instcount</span></code>: Counts the various types of <code class="docutils literal"><span class="pre">Instruction</span></code>s</a><a class="headerlink" href="#instcount-counts-the-various-types-of-instructions" title="Permalink to this headline">¶</a></h3>
<p>This pass collects the count of all instructions and reports them.</p>
</div>
<div class="section" id="intervals-interval-partition-construction">
<h3><a class="toc-backref" href="#id20"><code class="docutils literal"><span class="pre">-intervals</span></code>: Interval Partition Construction</a><a class="headerlink" href="#intervals-interval-partition-construction" title="Permalink to this headline">¶</a></h3>
<p>This analysis calculates and represents the interval partition of a function,
or a preexisting interval partition.</p>
<p>In this way, the interval partition may be used to reduce a flow graph down to
its degenerate single node interval partition (unless it is irreducible).</p>
</div>
<div class="section" id="iv-users-induction-variable-users">
<h3><a class="toc-backref" href="#id21"><code class="docutils literal"><span class="pre">-iv-users</span></code>: Induction Variable Users</a><a class="headerlink" href="#iv-users-induction-variable-users" title="Permalink to this headline">¶</a></h3>
<p>Bookkeeping for “interesting” users of expressions computed from induction
variables.</p>
</div>
<div class="section" id="lazy-value-info-lazy-value-information-analysis">
<h3><a class="toc-backref" href="#id22"><code class="docutils literal"><span class="pre">-lazy-value-info</span></code>: Lazy Value Information Analysis</a><a class="headerlink" href="#lazy-value-info-lazy-value-information-analysis" title="Permalink to this headline">¶</a></h3>
<p>Interface for lazy computation of value constraint information.</p>
</div>
<div class="section" id="libcall-aa-libcall-alias-analysis">
<h3><a class="toc-backref" href="#id23"><code class="docutils literal"><span class="pre">-libcall-aa</span></code>: LibCall Alias Analysis</a><a class="headerlink" href="#libcall-aa-libcall-alias-analysis" title="Permalink to this headline">¶</a></h3>
<p>LibCall Alias Analysis.</p>
</div>
<div class="section" id="lint-statically-lint-checks-llvm-ir">
<h3><a class="toc-backref" href="#id24"><code class="docutils literal"><span class="pre">-lint</span></code>: Statically lint-checks LLVM IR</a><a class="headerlink" href="#lint-statically-lint-checks-llvm-ir" title="Permalink to this headline">¶</a></h3>
<p>This pass statically checks for common and easily-identified constructs which
produce undefined or likely unintended behavior in LLVM IR.</p>
<p>It is not a guarantee of correctness, in two ways. First, it isn’t
comprehensive. There are checks which could be done statically which are not
yet implemented. Some of these are indicated by TODO comments, but those
aren’t comprehensive either. Second, many conditions cannot be checked
statically. This pass does no dynamic instrumentation, so it can’t check for
all possible problems.</p>
<p>Another limitation is that it assumes all code will be executed. A store
through a null pointer in a basic block which is never reached is harmless, but
this pass will warn about it anyway.</p>
<p>Optimization passes may make conditions that this pass checks for more or less
obvious. If an optimization pass appears to be introducing a warning, it may
be that the optimization pass is merely exposing an existing condition in the
code.</p>
<p>This code may be run before <a class="reference internal" href="#passes-instcombine"><span class="std std-ref">instcombine</span></a>. In many
cases, instcombine checks for the same kinds of things and turns instructions
with undefined behavior into unreachable (or equivalent). Because of this,
this pass makes some effort to look through bitcasts and so on.</p>
</div>
<div class="section" id="loops-natural-loop-information">
<h3><a class="toc-backref" href="#id25"><code class="docutils literal"><span class="pre">-loops</span></code>: Natural Loop Information</a><a class="headerlink" href="#loops-natural-loop-information" title="Permalink to this headline">¶</a></h3>
<p>This analysis is used to identify natural loops and determine the loop depth of
various nodes of the CFG. Note that the loops identified may actually be
several natural loops that share the same header node… not just a single
natural loop.</p>
</div>
<div class="section" id="memdep-memory-dependence-analysis">
<h3><a class="toc-backref" href="#id26"><code class="docutils literal"><span class="pre">-memdep</span></code>: Memory Dependence Analysis</a><a class="headerlink" href="#memdep-memory-dependence-analysis" title="Permalink to this headline">¶</a></h3>
<p>An analysis that determines, for a given memory operation, what preceding
memory operations it depends on. It builds on alias analysis information, and
tries to provide a lazy, caching interface to a common kind of alias
information query.</p>
</div>
<div class="section" id="module-debuginfo-decodes-module-level-debug-info">
<h3><a class="toc-backref" href="#id27"><code class="docutils literal"><span class="pre">-module-debuginfo</span></code>: Decodes module-level debug info</a><a class="headerlink" href="#module-debuginfo-decodes-module-level-debug-info" title="Permalink to this headline">¶</a></h3>
<p>This pass decodes the debug info metadata in a module and prints in a
(sufficiently-prepared-) human-readable form.</p>
<p>For example, run this pass from <code class="docutils literal"><span class="pre">opt</span></code> along with the <code class="docutils literal"><span class="pre">-analyze</span></code> option, and
it’ll print to standard output.</p>
</div>
<div class="section" id="postdomfrontier-post-dominance-frontier-construction">
<h3><a class="toc-backref" href="#id28"><code class="docutils literal"><span class="pre">-postdomfrontier</span></code>: Post-Dominance Frontier Construction</a><a class="headerlink" href="#postdomfrontier-post-dominance-frontier-construction" title="Permalink to this headline">¶</a></h3>
<p>This pass is a simple post-dominator construction algorithm for finding
post-dominator frontiers.</p>
</div>
<div class="section" id="postdomtree-post-dominator-tree-construction">
<h3><a class="toc-backref" href="#id29"><code class="docutils literal"><span class="pre">-postdomtree</span></code>: Post-Dominator Tree Construction</a><a class="headerlink" href="#postdomtree-post-dominator-tree-construction" title="Permalink to this headline">¶</a></h3>
<p>This pass is a simple post-dominator construction algorithm for finding
post-dominators.</p>
</div>
<div class="section" id="print-alias-sets-alias-set-printer">
<h3><a class="toc-backref" href="#id30"><code class="docutils literal"><span class="pre">-print-alias-sets</span></code>: Alias Set Printer</a><a class="headerlink" href="#print-alias-sets-alias-set-printer" title="Permalink to this headline">¶</a></h3>
<p>Yet to be written.</p>
</div>
<div class="section" id="print-callgraph-print-a-call-graph">
<h3><a class="toc-backref" href="#id31"><code class="docutils literal"><span class="pre">-print-callgraph</span></code>: Print a call graph</a><a class="headerlink" href="#print-callgraph-print-a-call-graph" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal"><span class="pre">opt</span></code>, prints the call graph to standard error
in a human-readable form.</p>
</div>
<div class="section" id="print-callgraph-sccs-print-sccs-of-the-call-graph">
<h3><a class="toc-backref" href="#id32"><code class="docutils literal"><span class="pre">-print-callgraph-sccs</span></code>: Print SCCs of the Call Graph</a><a class="headerlink" href="#print-callgraph-sccs-print-sccs-of-the-call-graph" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal"><span class="pre">opt</span></code>, prints the SCCs of the call graph to
standard error in a human-readable form.</p>
</div>
<div class="section" id="print-cfg-sccs-print-sccs-of-each-function-cfg">
<h3><a class="toc-backref" href="#id33"><code class="docutils literal"><span class="pre">-print-cfg-sccs</span></code>: Print SCCs of each function CFG</a><a class="headerlink" href="#print-cfg-sccs-print-sccs-of-each-function-cfg" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal"><span class="pre">opt</span></code>, printsthe SCCs of each function CFG to
standard error in a human-readable fom.</p>
</div>
<div class="section" id="print-dom-info-dominator-info-printer">
<h3><a class="toc-backref" href="#id34"><code class="docutils literal"><span class="pre">-print-dom-info</span></code>: Dominator Info Printer</a><a class="headerlink" href="#print-dom-info-dominator-info-printer" title="Permalink to this headline">¶</a></h3>
<p>Dominator Info Printer.</p>
</div>
<div class="section" id="print-externalfnconstants-print-external-fn-callsites-passed-constants">
<h3><a class="toc-backref" href="#id35"><code class="docutils literal"><span class="pre">-print-externalfnconstants</span></code>: Print external fn callsites passed constants</a><a class="headerlink" href="#print-externalfnconstants-print-external-fn-callsites-passed-constants" title="Permalink to this headline">¶</a></h3>
<p>This pass, only available in <code class="docutils literal"><span class="pre">opt</span></code>, prints out call sites to external
functions that are called with constant arguments. This can be useful when
looking for standard library functions we should constant fold or handle in
alias analyses.</p>
</div>
<div class="section" id="print-function-print-function-to-stderr">
<h3><a class="toc-backref" href="#id36"><code class="docutils literal"><span class="pre">-print-function</span></code>: Print function to stderr</a><a class="headerlink" href="#print-function-print-function-to-stderr" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal"><span class="pre">PrintFunctionPass</span></code> class is designed to be pipelined with other
<code class="docutils literal"><span class="pre">FunctionPasses</span></code>, and prints out the functions of the module as they are
processed.</p>
</div>
<div class="section" id="print-module-print-module-to-stderr">
<h3><a class="toc-backref" href="#id37"><code class="docutils literal"><span class="pre">-print-module</span></code>: Print module to stderr</a><a class="headerlink" href="#print-module-print-module-to-stderr" title="Permalink to this headline">¶</a></h3>
<p>This pass simply prints out the entire module when it is executed.</p>
</div>
<div class="section" id="print-used-types-find-used-types">
<span id="passes-print-used-types"></span><h3><a class="toc-backref" href="#id38"><code class="docutils literal"><span class="pre">-print-used-types</span></code>: Find Used Types</a><a class="headerlink" href="#print-used-types-find-used-types" title="Permalink to this headline">¶</a></h3>
<p>This pass is used to seek out all of the types in use by the program. Note
that this analysis explicitly does not include types only used by the symbol
table.</p>
</div>
<div class="section" id="regions-detect-single-entry-single-exit-regions">
<h3><a class="toc-backref" href="#id39"><code class="docutils literal"><span class="pre">-regions</span></code>: Detect single entry single exit regions</a><a class="headerlink" href="#regions-detect-single-entry-single-exit-regions" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal"><span class="pre">RegionInfo</span></code> pass detects single entry single exit regions in a function,
where a region is defined as any subgraph that is connected to the remaining
graph at only two spots. Furthermore, an hierarchical region tree is built.</p>
</div>
<div class="section" id="scalar-evolution-scalar-evolution-analysis">
<h3><a class="toc-backref" href="#id40"><code class="docutils literal"><span class="pre">-scalar-evolution</span></code>: Scalar Evolution Analysis</a><a class="headerlink" href="#scalar-evolution-scalar-evolution-analysis" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal"><span class="pre">ScalarEvolution</span></code> analysis can be used to analyze and catagorize scalar
expressions in loops. It specializes in recognizing general induction
variables, representing them with the abstract and opaque <code class="docutils literal"><span class="pre">SCEV</span></code> class.
Given this analysis, trip counts of loops and other important properties can be
obtained.</p>
<p>This analysis is primarily useful for induction variable substitution and
strength reduction.</p>
</div>
<div class="section" id="scev-aa-scalarevolution-based-alias-analysis">
<h3><a class="toc-backref" href="#id41"><code class="docutils literal"><span class="pre">-scev-aa</span></code>: ScalarEvolution-based Alias Analysis</a><a class="headerlink" href="#scev-aa-scalarevolution-based-alias-analysis" title="Permalink to this headline">¶</a></h3>
<p>Simple alias analysis implemented in terms of <code class="docutils literal"><span class="pre">ScalarEvolution</span></code> queries.</p>
<p>This differs from traditional loop dependence analysis in that it tests for
dependencies within a single iteration of a loop, rather than dependencies
between different iterations.</p>
<p><code class="docutils literal"><span class="pre">ScalarEvolution</span></code> has a more complete understanding of pointer arithmetic
than <code class="docutils literal"><span class="pre">BasicAliasAnalysis</span></code>’ collection of ad-hoc analyses.</p>
</div>
<div class="section" id="targetdata-target-data-layout">
<h3><a class="toc-backref" href="#id42"><code class="docutils literal"><span class="pre">-targetdata</span></code>: Target Data Layout</a><a class="headerlink" href="#targetdata-target-data-layout" title="Permalink to this headline">¶</a></h3>
<p>Provides other passes access to information on how the size and alignment
required by the target ABI for various data types.</p>
</div>
</div>
<div class="section" id="transform-passes">
<h2><a class="toc-backref" href="#id43">Transform Passes</a><a class="headerlink" href="#transform-passes" title="Permalink to this headline">¶</a></h2>
<p>This section describes the LLVM Transform Passes.</p>
<div class="section" id="adce-aggressive-dead-code-elimination">
<h3><a class="toc-backref" href="#id44"><code class="docutils literal"><span class="pre">-adce</span></code>: Aggressive Dead Code Elimination</a><a class="headerlink" href="#adce-aggressive-dead-code-elimination" title="Permalink to this headline">¶</a></h3>
<p>ADCE aggressively tries to eliminate code. This pass is similar to <a class="reference internal" href="#passes-dce"><span class="std std-ref">DCE</span></a> but it assumes that values are dead until proven otherwise. This
is similar to <a class="reference internal" href="#passes-sccp"><span class="std std-ref">SCCP</span></a>, except applied to the liveness of
values.</p>
</div>
<div class="section" id="always-inline-inliner-for-always-inline-functions">
<h3><a class="toc-backref" href="#id45"><code class="docutils literal"><span class="pre">-always-inline</span></code>: Inliner for <code class="docutils literal"><span class="pre">always_inline</span></code> functions</a><a class="headerlink" href="#always-inline-inliner-for-always-inline-functions" title="Permalink to this headline">¶</a></h3>
<p>A custom inliner that handles only functions that are marked as “always
inline”.</p>
</div>
<div class="section" id="argpromotion-promote-by-reference-arguments-to-scalars">
<h3><a class="toc-backref" href="#id46"><code class="docutils literal"><span class="pre">-argpromotion</span></code>: Promote ‘by reference’ arguments to scalars</a><a class="headerlink" href="#argpromotion-promote-by-reference-arguments-to-scalars" title="Permalink to this headline">¶</a></h3>
<p>This pass promotes “by reference” arguments to be “by value” arguments. In
practice, this means looking for internal functions that have pointer
arguments. If it can prove, through the use of alias analysis, that an
argument is <em>only</em> loaded, then it can pass the value into the function instead
of the address of the value. This can cause recursive simplification of code
and lead to the elimination of allocas (especially in C++ template code like
the STL).</p>
<p>This pass also handles aggregate arguments that are passed into a function,
scalarizing them if the elements of the aggregate are only loaded. Note that
it refuses to scalarize aggregates which would require passing in more than
three operands to the function, because passing thousands of operands for a
large array or structure is unprofitable!</p>
<p>Note that this transformation could also be done for arguments that are only
stored to (returning the value instead), but does not currently. This case
would be best handled when and if LLVM starts supporting multiple return values
from functions.</p>
</div>
<div class="section" id="bb-vectorize-basic-block-vectorization">
<h3><a class="toc-backref" href="#id47"><code class="docutils literal"><span class="pre">-bb-vectorize</span></code>: Basic-Block Vectorization</a><a class="headerlink" href="#bb-vectorize-basic-block-vectorization" title="Permalink to this headline">¶</a></h3>
<p>This pass combines instructions inside basic blocks to form vector
instructions. It iterates over each basic block, attempting to pair compatible
instructions, repeating this process until no additional pairs are selected for
vectorization. When the outputs of some pair of compatible instructions are
used as inputs by some other pair of compatible instructions, those pairs are
part of a potential vectorization chain. Instruction pairs are only fused into
vector instructions when they are part of a chain longer than some threshold
length. Moreover, the pass attempts to find the best possible chain for each
pair of compatible instructions. These heuristics are intended to prevent
vectorization in cases where it would not yield a performance increase of the
resulting code.</p>
</div>
<div class="section" id="block-placement-profile-guided-basic-block-placement">
<h3><a class="toc-backref" href="#id48"><code class="docutils literal"><span class="pre">-block-placement</span></code>: Profile Guided Basic Block Placement</a><a class="headerlink" href="#block-placement-profile-guided-basic-block-placement" title="Permalink to this headline">¶</a></h3>
<p>This pass is a very simple profile guided basic block placement algorithm. The
idea is to put frequently executed blocks together at the start of the function
and hopefully increase the number of fall-through conditional branches. If
there is no profile information for a particular function, this pass basically
orders blocks in depth-first order.</p>
</div>
<div class="section" id="break-crit-edges-break-critical-edges-in-cfg">
<h3><a class="toc-backref" href="#id49"><code class="docutils literal"><span class="pre">-break-crit-edges</span></code>: Break critical edges in CFG</a><a class="headerlink" href="#break-crit-edges-break-critical-edges-in-cfg" title="Permalink to this headline">¶</a></h3>
<p>Break all of the critical edges in the CFG by inserting a dummy basic block.
It may be “required” by passes that cannot deal with critical edges. This
transformation obviously invalidates the CFG, but can update forward dominator
(set, immediate dominators, tree, and frontier) information.</p>
</div>
<div class="section" id="codegenprepare-optimize-for-code-generation">
<h3><a class="toc-backref" href="#id50"><code class="docutils literal"><span class="pre">-codegenprepare</span></code>: Optimize for code generation</a><a class="headerlink" href="#codegenprepare-optimize-for-code-generation" title="Permalink to this headline">¶</a></h3>
<p>This pass munges the code in the input function to better prepare it for
SelectionDAG-based code generation. This works around limitations in its
basic-block-at-a-time approach. It should eventually be removed.</p>
</div>
<div class="section" id="constmerge-merge-duplicate-global-constants">
<h3><a class="toc-backref" href="#id51"><code class="docutils literal"><span class="pre">-constmerge</span></code>: Merge Duplicate Global Constants</a><a class="headerlink" href="#constmerge-merge-duplicate-global-constants" title="Permalink to this headline">¶</a></h3>
<p>Merges duplicate global constants together into a single constant that is
shared. This is useful because some passes (i.e., TraceValues) insert a lot of
string constants into the program, regardless of whether or not an existing
string is available.</p>
</div>
<div class="section" id="constprop-simple-constant-propagation">
<h3><a class="toc-backref" href="#id52"><code class="docutils literal"><span class="pre">-constprop</span></code>: Simple constant propagation</a><a class="headerlink" href="#constprop-simple-constant-propagation" title="Permalink to this headline">¶</a></h3>
<p>This pass implements constant propagation and merging. It looks for
instructions involving only constant operands and replaces them with a constant
value instead of an instruction. For example:</p>
<div class="highlight-llvm"><div class="highlight"><pre><span></span><span class="k">add</span> <span class="k">i32</span> <span class="m">1</span><span class="p">,</span> <span class="m">2</span>
</pre></div>
</div>
<p>becomes</p>
<div class="highlight-llvm"><div class="highlight"><pre><span></span><span class="k">i32</span> <span class="m">3</span>
</pre></div>
</div>
<p>NOTE: this pass has a habit of making definitions be dead. It is a good idea
to run a <a class="reference internal" href="#passes-die"><span class="std std-ref">Dead Instruction Elimination</span></a> pass sometime after
running this pass.</p>
</div>
<div class="section" id="dce-dead-code-elimination">
<span id="passes-dce"></span><h3><a class="toc-backref" href="#id53"><code class="docutils literal"><span class="pre">-dce</span></code>: Dead Code Elimination</a><a class="headerlink" href="#dce-dead-code-elimination" title="Permalink to this headline">¶</a></h3>
<p>Dead code elimination is similar to <a class="reference internal" href="#passes-die"><span class="std std-ref">dead instruction elimination</span></a>, but it rechecks instructions that were used by removed
instructions to see if they are newly dead.</p>
</div>
<div class="section" id="deadargelim-dead-argument-elimination">
<h3><a class="toc-backref" href="#id54"><code class="docutils literal"><span class="pre">-deadargelim</span></code>: Dead Argument Elimination</a><a class="headerlink" href="#deadargelim-dead-argument-elimination" title="Permalink to this headline">¶</a></h3>
<p>This pass deletes dead arguments from internal functions. Dead argument
elimination removes arguments which are directly dead, as well as arguments
only passed into function calls as dead arguments of other functions. This
pass also deletes dead arguments in a similar way.</p>
<p>This pass is often useful as a cleanup pass to run after aggressive
interprocedural passes, which add possibly-dead arguments.</p>
</div>
<div class="section" id="deadtypeelim-dead-type-elimination">
<h3><a class="toc-backref" href="#id55"><code class="docutils literal"><span class="pre">-deadtypeelim</span></code>: Dead Type Elimination</a><a class="headerlink" href="#deadtypeelim-dead-type-elimination" title="Permalink to this headline">¶</a></h3>
<p>This pass is used to cleanup the output of GCC. It eliminate names for types
that are unused in the entire translation unit, using the <a class="reference internal" href="#passes-print-used-types"><span class="std std-ref">find used types</span></a> pass.</p>
</div>
<div class="section" id="die-dead-instruction-elimination">
<span id="passes-die"></span><h3><a class="toc-backref" href="#id56"><code class="docutils literal"><span class="pre">-die</span></code>: Dead Instruction Elimination</a><a class="headerlink" href="#die-dead-instruction-elimination" title="Permalink to this headline">¶</a></h3>
<p>Dead instruction elimination performs a single pass over the function, removing
instructions that are obviously dead.</p>
</div>
<div class="section" id="dse-dead-store-elimination">
<h3><a class="toc-backref" href="#id57"><code class="docutils literal"><span class="pre">-dse</span></code>: Dead Store Elimination</a><a class="headerlink" href="#dse-dead-store-elimination" title="Permalink to this headline">¶</a></h3>
<p>A trivial dead store elimination that only considers basic-block local
redundant stores.</p>
</div>
<div class="section" id="functionattrs-deduce-function-attributes">
<span id="passes-functionattrs"></span><h3><a class="toc-backref" href="#id58"><code class="docutils literal"><span class="pre">-functionattrs</span></code>: Deduce function attributes</a><a class="headerlink" href="#functionattrs-deduce-function-attributes" title="Permalink to this headline">¶</a></h3>
<p>A simple interprocedural pass which walks the call-graph, looking for functions
which do not access or only read non-local memory, and marking them
<code class="docutils literal"><span class="pre">readnone</span></code>/<code class="docutils literal"><span class="pre">readonly</span></code>. In addition, it marks function arguments (of
pointer type) “<code class="docutils literal"><span class="pre">nocapture</span></code>” if a call to the function does not create any
copies of the pointer value that outlive the call. This more or less means
that the pointer is only dereferenced, and not returned from the function or
stored in a global. This pass is implemented as a bottom-up traversal of the
call-graph.</p>
</div>
<div class="section" id="globaldce-dead-global-elimination">
<h3><a class="toc-backref" href="#id59"><code class="docutils literal"><span class="pre">-globaldce</span></code>: Dead Global Elimination</a><a class="headerlink" href="#globaldce-dead-global-elimination" title="Permalink to this headline">¶</a></h3>
<p>This transform is designed to eliminate unreachable internal globals from the
program. It uses an aggressive algorithm, searching out globals that are known
to be alive. After it finds all of the globals which are needed, it deletes
whatever is left over. This allows it to delete recursive chunks of the
program which are unreachable.</p>
</div>
<div class="section" id="globalopt-global-variable-optimizer">
<h3><a class="toc-backref" href="#id60"><code class="docutils literal"><span class="pre">-globalopt</span></code>: Global Variable Optimizer</a><a class="headerlink" href="#globalopt-global-variable-optimizer" title="Permalink to this headline">¶</a></h3>
<p>This pass transforms simple global variables that never have their address
taken. If obviously true, it marks read/write globals as constant, deletes
variables only stored to, etc.</p>
</div>
<div class="section" id="gvn-global-value-numbering">
<h3><a class="toc-backref" href="#id61"><code class="docutils literal"><span class="pre">-gvn</span></code>: Global Value Numbering</a><a class="headerlink" href="#gvn-global-value-numbering" title="Permalink to this headline">¶</a></h3>
<p>This pass performs global value numbering to eliminate fully and partially
redundant instructions. It also performs redundant load elimination.</p>
</div>
<div class="section" id="indvars-canonicalize-induction-variables">
<span id="passes-indvars"></span><h3><a class="toc-backref" href="#id62"><code class="docutils literal"><span class="pre">-indvars</span></code>: Canonicalize Induction Variables</a><a class="headerlink" href="#indvars-canonicalize-induction-variables" title="Permalink to this headline">¶</a></h3>
<p>This transformation analyzes and transforms the induction variables (and
computations derived from them) into simpler forms suitable for subsequent
analysis and transformation.</p>
<p>This transformation makes the following changes to each loop with an
identifiable induction variable:</p>
<ul class="simple">
<li>All loops are transformed to have a <em>single</em> canonical induction variable
which starts at zero and steps by one.</li>
<li>The canonical induction variable is guaranteed to be the first PHI node in
the loop header block.</li>
<li>Any pointer arithmetic recurrences are raised to use array subscripts.</li>
</ul>
<p>If the trip count of a loop is computable, this pass also makes the following
changes:</p>
<ul>
<li><p class="first">The exit condition for the loop is canonicalized to compare the induction
value against the exit value. This turns loops like:</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="p">(</span><span class="n">i</span> <span class="o">=</span> <span class="mi">7</span><span class="p">;</span> <span class="n">i</span><span class="o">*</span><span class="n">i</span> <span class="o"><</span> <span class="mi">1000</span><span class="p">;</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span>
<span class="n">into</span>
</pre></div>
</div>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="p">(</span><span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">25</span><span class="p">;</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p class="first">Any use outside of the loop of an expression derived from the indvar is
changed to compute the derived value outside of the loop, eliminating the
dependence on the exit value of the induction variable. If the only purpose
of the loop is to compute the exit value of some derived expression, this
transformation will make the loop dead.</p>
</li>
</ul>
<p>This transformation should be followed by strength reduction after all of the
desired loop transformations have been performed. Additionally, on targets
where it is profitable, the loop could be transformed to count down to zero
(the “do loop” optimization).</p>
</div>
<div class="section" id="inline-function-integration-inlining">
<h3><a class="toc-backref" href="#id63"><code class="docutils literal"><span class="pre">-inline</span></code>: Function Integration/Inlining</a><a class="headerlink" href="#inline-function-integration-inlining" title="Permalink to this headline">¶</a></h3>
<p>Bottom-up inlining of functions into callees.</p>
</div>
<div class="section" id="instcombine-combine-redundant-instructions">
<span id="passes-instcombine"></span><h3><a class="toc-backref" href="#id64"><code class="docutils literal"><span class="pre">-instcombine</span></code>: Combine redundant instructions</a><a class="headerlink" href="#instcombine-combine-redundant-instructions" title="Permalink to this headline">¶</a></h3>
<p>Combine instructions to form fewer, simple instructions. This pass does not
modify the CFG. This pass is where algebraic simplification happens.</p>
<p>This pass combines things like:</p>
<div class="highlight-llvm"><div class="highlight"><pre><span></span><span class="nv">%Y</span> <span class="p">=</span> <span class="k">add</span> <span class="k">i32</span> <span class="nv">%X</span><span class="p">,</span> <span class="m">1</span>
<span class="nv">%Z</span> <span class="p">=</span> <span class="k">add</span> <span class="k">i32</span> <span class="nv">%Y</span><span class="p">,</span> <span class="m">1</span>
</pre></div>
</div>
<p>into:</p>
<div class="highlight-llvm"><div class="highlight"><pre><span></span><span class="nv">%Z</span> <span class="p">=</span> <span class="k">add</span> <span class="k">i32</span> <span class="nv">%X</span><span class="p">,</span> <span class="m">2</span>
</pre></div>
</div>
<p>This is a simple worklist driven algorithm.</p>
<p>This pass guarantees that the following canonicalizations are performed on the
program:</p>
<ol class="arabic simple">
<li>If a binary operator has a constant operand, it is moved to the right-hand
side.</li>
<li>Bitwise operators with constant operands are always grouped so that shifts
are performed first, then <code class="docutils literal"><span class="pre">or</span></code>s, then <code class="docutils literal"><span class="pre">and</span></code>s, then <code class="docutils literal"><span class="pre">xor</span></code>s.</li>
<li>Compare instructions are converted from <code class="docutils literal"><span class="pre"><</span></code>, <code class="docutils literal"><span class="pre">></span></code>, <code class="docutils literal"><span class="pre">≤</span></code>, or <code class="docutils literal"><span class="pre">≥</span></code> to
<code class="docutils literal"><span class="pre">=</span></code> or <code class="docutils literal"><span class="pre">≠</span></code> if possible.</li>
<li>All <code class="docutils literal"><span class="pre">cmp</span></code> instructions on boolean values are replaced with logical
operations.</li>
<li><code class="docutils literal"><span class="pre">add</span> <span class="pre">X,</span> <span class="pre">X</span></code> is represented as <code class="docutils literal"><span class="pre">mul</span> <span class="pre">X,</span> <span class="pre">2</span></code> ⇒ <code class="docutils literal"><span class="pre">shl</span> <span class="pre">X,</span> <span class="pre">1</span></code></li>
<li>Multiplies with a constant power-of-two argument are transformed into
shifts.</li>
<li>… etc.</li>
</ol>
<p>This pass can also simplify calls to specific well-known function calls (e.g.
runtime library functions). For example, a call <code class="docutils literal"><span class="pre">exit(3)</span></code> that occurs within
the <code class="docutils literal"><span class="pre">main()</span></code> function can be transformed into simply <code class="docutils literal"><span class="pre">return</span> <span class="pre">3</span></code>. Whether or
not library calls are simplified is controlled by the
<a class="reference internal" href="#passes-functionattrs"><span class="std std-ref">-functionattrs</span></a> pass and LLVM’s knowledge of
library calls on different targets.</p>
</div>
<div class="section" id="internalize-internalize-global-symbols">
<h3><a class="toc-backref" href="#id65"><code class="docutils literal"><span class="pre">-internalize</span></code>: Internalize Global Symbols</a><a class="headerlink" href="#internalize-internalize-global-symbols" title="Permalink to this headline">¶</a></h3>
<p>This pass loops over all of the functions in the input module, looking for a
main function. If a main function is found, all other functions and all global
variables with initializers are marked as internal.</p>
</div>
<div class="section" id="ipconstprop-interprocedural-constant-propagation">
<h3><a class="toc-backref" href="#id66"><code class="docutils literal"><span class="pre">-ipconstprop</span></code>: Interprocedural constant propagation</a><a class="headerlink" href="#ipconstprop-interprocedural-constant-propagation" title="Permalink to this headline">¶</a></h3>
<p>This pass implements an <em>extremely</em> simple interprocedural constant propagation
pass. It could certainly be improved in many different ways, like using a
worklist. This pass makes arguments dead, but does not remove them. The
existing dead argument elimination pass should be run after this to clean up
the mess.</p>
</div>
<div class="section" id="ipsccp-interprocedural-sparse-conditional-constant-propagation">
<h3><a class="toc-backref" href="#id67"><code class="docutils literal"><span class="pre">-ipsccp</span></code>: Interprocedural Sparse Conditional Constant Propagation</a><a class="headerlink" href="#ipsccp-interprocedural-sparse-conditional-constant-propagation" title="Permalink to this headline">¶</a></h3>
<p>An interprocedural variant of <a class="reference internal" href="#passes-sccp"><span class="std std-ref">Sparse Conditional Constant Propagation</span></a>.</p>
</div>
<div class="section" id="jump-threading-jump-threading">
<h3><a class="toc-backref" href="#id68"><code class="docutils literal"><span class="pre">-jump-threading</span></code>: Jump Threading</a><a class="headerlink" href="#jump-threading-jump-threading" title="Permalink to this headline">¶</a></h3>
<p>Jump threading tries to find distinct threads of control flow running through a
basic block. This pass looks at blocks that have multiple predecessors and
multiple successors. If one or more of the predecessors of the block can be
proven to always cause a jump to one of the successors, we forward the edge
from the predecessor to the successor by duplicating the contents of this
block.</p>
<p>An example of when this can occur is code like this:</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="p">()</span> <span class="p">{</span> <span class="p">...</span>
<span class="n">X</span> <span class="o">=</span> <span class="mi">4</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="n">X</span> <span class="o"><</span> <span class="mi">3</span><span class="p">)</span> <span class="p">{</span>
</pre></div>
</div>
<p>In this case, the unconditional branch at the end of the first if can be
revectored to the false side of the second if.</p>
</div>
<div class="section" id="lcssa-loop-closed-ssa-form-pass">
<h3><a class="toc-backref" href="#id69"><code class="docutils literal"><span class="pre">-lcssa</span></code>: Loop-Closed SSA Form Pass</a><a class="headerlink" href="#lcssa-loop-closed-ssa-form-pass" title="Permalink to this headline">¶</a></h3>
<p>This pass transforms loops by placing phi nodes at the end of the loops for all
values that are live across the loop boundary. For example, it turns the left
into the right code:</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="p">(...)</span> <span class="k">for</span> <span class="p">(...)</span>
<span class="k">if</span> <span class="p">(</span><span class="n">c</span><span class="p">)</span> <span class="k">if</span> <span class="p">(</span><span class="n">c</span><span class="p">)</span>
<span class="n">X1</span> <span class="o">=</span> <span class="p">...</span> <span class="n">X1</span> <span class="o">=</span> <span class="p">...</span>
<span class="k">else</span> <span class="k">else</span>
<span class="n">X2</span> <span class="o">=</span> <span class="p">...</span> <span class="n">X2</span> <span class="o">=</span> <span class="p">...</span>
<span class="n">X3</span> <span class="o">=</span> <span class="n">phi</span><span class="p">(</span><span class="n">X1</span><span class="p">,</span> <span class="n">X2</span><span class="p">)</span> <span class="n">X3</span> <span class="o">=</span> <span class="n">phi</span><span class="p">(</span><span class="n">X1</span><span class="p">,</span> <span class="n">X2</span><span class="p">)</span>
<span class="p">...</span> <span class="o">=</span> <span class="n">X3</span> <span class="o">+</span> <span class="mi">4</span> <span class="n">X4</span> <span class="o">=</span> <span class="n">phi</span><span class="p">(</span><span class="n">X3</span><span class="p">)</span>
<span class="p">...</span> <span class="o">=</span> <span class="n">X4</span> <span class="o">+</span> <span class="mi">4</span>
</pre></div>
</div>
<p>This is still valid LLVM; the extra phi nodes are purely redundant, and will be
trivially eliminated by <code class="docutils literal"><span class="pre">InstCombine</span></code>. The major benefit of this
transformation is that it makes many other loop optimizations, such as
<code class="docutils literal"><span class="pre">LoopUnswitch</span></code>ing, simpler.</p>
</div>
<div class="section" id="licm-loop-invariant-code-motion">
<span id="passes-licm"></span><h3><a class="toc-backref" href="#id70"><code class="docutils literal"><span class="pre">-licm</span></code>: Loop Invariant Code Motion</a><a class="headerlink" href="#licm-loop-invariant-code-motion" title="Permalink to this headline">¶</a></h3>
<p>This pass performs loop invariant code motion, attempting to remove as much
code from the body of a loop as possible. It does this by either hoisting code
into the preheader block, or by sinking code to the exit blocks if it is safe.
This pass also promotes must-aliased memory locations in the loop to live in
registers, thus hoisting and sinking “invariant” loads and stores.</p>
<p>This pass uses alias analysis for two purposes:</p>
<ol class="arabic">
<li><p class="first">Moving loop invariant loads and calls out of loops. If we can determine
that a load or call inside of a loop never aliases anything stored to, we
can hoist it or sink it like any other instruction.</p>
</li>
<li><p class="first">Scalar Promotion of Memory. If there is a store instruction inside of the
loop, we try to move the store to happen AFTER the loop instead of inside of
the loop. This can only happen if a few conditions are true:</p>
<ol class="arabic simple">
<li>The pointer stored through is loop invariant.</li>
<li>There are no stores or loads in the loop which <em>may</em> alias the pointer.
There are no calls in the loop which mod/ref the pointer.</li>
</ol>
<p>If these conditions are true, we can promote the loads and stores in the
loop of the pointer to use a temporary alloca’d variable. We then use the
<a class="reference internal" href="#passes-mem2reg"><span class="std std-ref">mem2reg</span></a> functionality to construct the appropriate
SSA form for the variable.</p>
</li>
</ol>
</div>
<div class="section" id="loop-deletion-delete-dead-loops">
<h3><a class="toc-backref" href="#id71"><code class="docutils literal"><span class="pre">-loop-deletion</span></code>: Delete dead loops</a><a class="headerlink" href="#loop-deletion-delete-dead-loops" title="Permalink to this headline">¶</a></h3>
<p>This file implements the Dead Loop Deletion Pass. This pass is responsible for
eliminating loops with non-infinite computable trip counts that have no side
effects or volatile instructions, and do not contribute to the computation of
the function’s return value.</p>
</div>
<div class="section" id="loop-extract-extract-loops-into-new-functions">
<span id="passes-loop-extract"></span><h3><a class="toc-backref" href="#id72"><code class="docutils literal"><span class="pre">-loop-extract</span></code>: Extract loops into new functions</a><a class="headerlink" href="#loop-extract-extract-loops-into-new-functions" title="Permalink to this headline">¶</a></h3>
<p>A pass wrapper around the <code class="docutils literal"><span class="pre">ExtractLoop()</span></code> scalar transformation to extract
each top-level loop into its own new function. If the loop is the <em>only</em> loop
in a given function, it is not touched. This is a pass most useful for
debugging via bugpoint.</p>
</div>
<div class="section" id="loop-extract-single-extract-at-most-one-loop-into-a-new-function">
<h3><a class="toc-backref" href="#id73"><code class="docutils literal"><span class="pre">-loop-extract-single</span></code>: Extract at most one loop into a new function</a><a class="headerlink" href="#loop-extract-single-extract-at-most-one-loop-into-a-new-function" title="Permalink to this headline">¶</a></h3>
<p>Similar to <a class="reference internal" href="#passes-loop-extract"><span class="std std-ref">Extract loops into new functions</span></a>, this
pass extracts one natural loop from the program into a function if it can.
This is used by <strong class="program">bugpoint</strong>.</p>
</div>
<div class="section" id="loop-reduce-loop-strength-reduction">
<h3><a class="toc-backref" href="#id74"><code class="docutils literal"><span class="pre">-loop-reduce</span></code>: Loop Strength Reduction</a><a class="headerlink" href="#loop-reduce-loop-strength-reduction" title="Permalink to this headline">¶</a></h3>
<p>This pass performs a strength reduction on array references inside loops that
have as one or more of their components the loop induction variable. This is
accomplished by creating a new value to hold the initial value of the array
access for the first iteration, and then creating a new GEP instruction in the
loop to increment the value by the appropriate amount.</p>
</div>
<div class="section" id="loop-rotate-rotate-loops">
<h3><a class="toc-backref" href="#id75"><code class="docutils literal"><span class="pre">-loop-rotate</span></code>: Rotate Loops</a><a class="headerlink" href="#loop-rotate-rotate-loops" title="Permalink to this headline">¶</a></h3>
<p>A simple loop rotation transformation.</p>
</div>
<div class="section" id="loop-simplify-canonicalize-natural-loops">
<h3><a class="toc-backref" href="#id76"><code class="docutils literal"><span class="pre">-loop-simplify</span></code>: Canonicalize natural loops</a><a class="headerlink" href="#loop-simplify-canonicalize-natural-loops" title="Permalink to this headline">¶</a></h3>
<p>This pass performs several transformations to transform natural loops into a
simpler form, which makes subsequent analyses and transformations simpler and
more effective.</p>
<p>Loop pre-header insertion guarantees that there is a single, non-critical entry
edge from outside of the loop to the loop header. This simplifies a number of
analyses and transformations, such as <a class="reference internal" href="#passes-licm"><span class="std std-ref">LICM</span></a>.</p>
<p>Loop exit-block insertion guarantees that all exit blocks from the loop (blocks
which are outside of the loop that have predecessors inside of the loop) only
have predecessors from inside of the loop (and are thus dominated by the loop
header). This simplifies transformations such as store-sinking that are built
into LICM.</p>
<p>This pass also guarantees that loops will have exactly one backedge.</p>
<p>Note that the <a class="reference internal" href="#passes-simplifycfg"><span class="std std-ref">simplifycfg</span></a> pass will clean up blocks
which are split out but end up being unnecessary, so usage of this pass should
not pessimize generated code.</p>
<p>This pass obviously modifies the CFG, but updates loop information and
dominator information.</p>
</div>
<div class="section" id="loop-unroll-unroll-loops">
<h3><a class="toc-backref" href="#id77"><code class="docutils literal"><span class="pre">-loop-unroll</span></code>: Unroll loops</a><a class="headerlink" href="#loop-unroll-unroll-loops" title="Permalink to this headline">¶</a></h3>
<p>This pass implements a simple loop unroller. It works best when loops have
been canonicalized by the <a class="reference internal" href="#passes-indvars"><span class="std std-ref">indvars</span></a> pass, allowing it to
determine the trip counts of loops easily.</p>
</div>
<div class="section" id="loop-unswitch-unswitch-loops">
<h3><a class="toc-backref" href="#id78"><code class="docutils literal"><span class="pre">-loop-unswitch</span></code>: Unswitch loops</a><a class="headerlink" href="#loop-unswitch-unswitch-loops" title="Permalink to this headline">¶</a></h3>
<p>This pass transforms loops that contain branches on loop-invariant conditions
to have multiple loops. For example, it turns the left into the right code:</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="p">(...)</span> <span class="k">if</span> <span class="p">(</span><span class="n">lic</span><span class="p">)</span>
<span class="n">A</span> <span class="k">for</span> <span class="p">(...)</span>
<span class="k">if</span> <span class="p">(</span><span class="n">lic</span><span class="p">)</span> <span class="n">A</span><span class="p">;</span> <span class="n">B</span><span class="p">;</span> <span class="n">C</span>
<span class="n">B</span> <span class="k">else</span>
<span class="n">C</span> <span class="nf">for</span> <span class="p">(...)</span>
<span class="n">A</span><span class="p">;</span> <span class="n">C</span>
</pre></div>
</div>
<p>This can increase the size of the code exponentially (doubling it every time a
loop is unswitched) so we only unswitch if the resultant code will be smaller
than a threshold.</p>
<p>This pass expects <a class="reference internal" href="#passes-licm"><span class="std std-ref">LICM</span></a> to be run before it to hoist
invariant conditions out of the loop, to make the unswitching opportunity
obvious.</p>
</div>
<div class="section" id="loweratomic-lower-atomic-intrinsics-to-non-atomic-form">
<h3><a class="toc-backref" href="#id79"><code class="docutils literal"><span class="pre">-loweratomic</span></code>: Lower atomic intrinsics to non-atomic form</a><a class="headerlink" href="#loweratomic-lower-atomic-intrinsics-to-non-atomic-form" title="Permalink to this headline">¶</a></h3>
<p>This pass lowers atomic intrinsics to non-atomic form for use in a known
non-preemptible environment.</p>
<p>The pass does not verify that the environment is non-preemptible (in general
this would require knowledge of the entire call graph of the program including
any libraries which may not be available in bitcode form); it simply lowers
every atomic intrinsic.</p>
</div>
<div class="section" id="lowerinvoke-lower-invokes-to-calls-for-unwindless-code-generators">
<h3><a class="toc-backref" href="#id80"><code class="docutils literal"><span class="pre">-lowerinvoke</span></code>: Lower invokes to calls, for unwindless code generators</a><a class="headerlink" href="#lowerinvoke-lower-invokes-to-calls-for-unwindless-code-generators" title="Permalink to this headline">¶</a></h3>
<p>This transformation is designed for use by code generators which do not yet
support stack unwinding. This pass converts <code class="docutils literal"><span class="pre">invoke</span></code> instructions to
<code class="docutils literal"><span class="pre">call</span></code> instructions, so that any exception-handling <code class="docutils literal"><span class="pre">landingpad</span></code> blocks
become dead code (which can be removed by running the <code class="docutils literal"><span class="pre">-simplifycfg</span></code> pass
afterwards).</p>
</div>
<div class="section" id="lowerswitch-lower-switchinsts-to-branches">
<h3><a class="toc-backref" href="#id81"><code class="docutils literal"><span class="pre">-lowerswitch</span></code>: Lower <code class="docutils literal"><span class="pre">SwitchInst</span></code>s to branches</a><a class="headerlink" href="#lowerswitch-lower-switchinsts-to-branches" title="Permalink to this headline">¶</a></h3>
<p>Rewrites switch instructions with a sequence of branches, which allows targets
to get away with not implementing the switch instruction until it is
convenient.</p>
</div>
<div class="section" id="mem2reg-promote-memory-to-register">
<span id="passes-mem2reg"></span><h3><a class="toc-backref" href="#id82"><code class="docutils literal"><span class="pre">-mem2reg</span></code>: Promote Memory to Register</a><a class="headerlink" href="#mem2reg-promote-memory-to-register" title="Permalink to this headline">¶</a></h3>
<p>This file promotes memory references to be register references. It promotes
alloca instructions which only have loads and stores as uses. An <code class="docutils literal"><span class="pre">alloca</span></code> is
transformed by using dominator frontiers to place phi nodes, then traversing
the function in depth-first order to rewrite loads and stores as appropriate.
This is just the standard SSA construction algorithm to construct “pruned” SSA
form.</p>
</div>
<div class="section" id="memcpyopt-memcpy-optimization">
<h3><a class="toc-backref" href="#id83"><code class="docutils literal"><span class="pre">-memcpyopt</span></code>: MemCpy Optimization</a><a class="headerlink" href="#memcpyopt-memcpy-optimization" title="Permalink to this headline">¶</a></h3>
<p>This pass performs various transformations related to eliminating <code class="docutils literal"><span class="pre">memcpy</span></code>
calls, or transforming sets of stores into <code class="docutils literal"><span class="pre">memset</span></code>s.</p>
</div>
<div class="section" id="mergefunc-merge-functions">
<h3><a class="toc-backref" href="#id84"><code class="docutils literal"><span class="pre">-mergefunc</span></code>: Merge Functions</a><a class="headerlink" href="#mergefunc-merge-functions" title="Permalink to this headline">¶</a></h3>
<p>This pass looks for equivalent functions that are mergable and folds them.</p>
<p>Total-ordering is introduced among the functions set: we define comparison
that answers for every two functions which of them is greater. It allows to
arrange functions into the binary tree.</p>
<p>For every new function we check for equivalent in tree.</p>
<p>If equivalent exists we fold such functions. If both functions are overridable,
we move the functionality into a new internal function and leave two
overridable thunks to it.</p>
<p>If there is no equivalent, then we add this function to tree.</p>
<p>Lookup routine has O(log(n)) complexity, while whole merging process has
complexity of O(n*log(n)).</p>
<p>Read
<a class="reference internal" href="MergeFunctions.html"><span class="doc">this</span></a>
article for more details.</p>
</div>
<div class="section" id="mergereturn-unify-function-exit-nodes">
<h3><a class="toc-backref" href="#id85"><code class="docutils literal"><span class="pre">-mergereturn</span></code>: Unify function exit nodes</a><a class="headerlink" href="#mergereturn-unify-function-exit-nodes" title="Permalink to this headline">¶</a></h3>
<p>Ensure that functions have at most one <code class="docutils literal"><span class="pre">ret</span></code> instruction in them.
Additionally, it keeps track of which node is the new exit node of the CFG.</p>
</div>
<div class="section" id="partial-inliner-partial-inliner">
<h3><a class="toc-backref" href="#id86"><code class="docutils literal"><span class="pre">-partial-inliner</span></code>: Partial Inliner</a><a class="headerlink" href="#partial-inliner-partial-inliner" title="Permalink to this headline">¶</a></h3>
<p>This pass performs partial inlining, typically by inlining an <code class="docutils literal"><span class="pre">if</span></code> statement
that surrounds the body of the function.</p>
</div>
<div class="section" id="prune-eh-remove-unused-exception-handling-info">
<h3><a class="toc-backref" href="#id87"><code class="docutils literal"><span class="pre">-prune-eh</span></code>: Remove unused exception handling info</a><a class="headerlink" href="#prune-eh-remove-unused-exception-handling-info" title="Permalink to this headline">¶</a></h3>
<p>This file implements a simple interprocedural pass which walks the call-graph,
turning invoke instructions into call instructions if and only if the callee
cannot throw an exception. It implements this as a bottom-up traversal of the
call-graph.</p>
</div>
<div class="section" id="reassociate-reassociate-expressions">
<h3><a class="toc-backref" href="#id88"><code class="docutils literal"><span class="pre">-reassociate</span></code>: Reassociate expressions</a><a class="headerlink" href="#reassociate-reassociate-expressions" title="Permalink to this headline">¶</a></h3>
<p>This pass reassociates commutative expressions in an order that is designed to
promote better constant propagation, GCSE, <a class="reference internal" href="#passes-licm"><span class="std std-ref">LICM</span></a>, PRE, etc.</p>
<p>For example: 4 + (x + 5) ⇒ x + (4 + 5)</p>
<p>In the implementation of this algorithm, constants are assigned rank = 0,
function arguments are rank = 1, and other values are assigned ranks
corresponding to the reverse post order traversal of current function (starting
at 2), which effectively gives values in deep loops higher rank than values not
in loops.</p>
</div>
<div class="section" id="reg2mem-demote-all-values-to-stack-slots">
<h3><a class="toc-backref" href="#id89"><code class="docutils literal"><span class="pre">-reg2mem</span></code>: Demote all values to stack slots</a><a class="headerlink" href="#reg2mem-demote-all-values-to-stack-slots" title="Permalink to this headline">¶</a></h3>
<p>This file demotes all registers to memory references. It is intended to be the
inverse of <a class="reference internal" href="#passes-mem2reg"><span class="std std-ref">mem2reg</span></a>. By converting to <code class="docutils literal"><span class="pre">load</span></code>
instructions, the only values live across basic blocks are <code class="docutils literal"><span class="pre">alloca</span></code>
instructions and <code class="docutils literal"><span class="pre">load</span></code> instructions before <code class="docutils literal"><span class="pre">phi</span></code> nodes. It is intended
that this should make CFG hacking much easier. To make later hacking easier,
the entry block is split into two, such that all introduced <code class="docutils literal"><span class="pre">alloca</span></code>
instructions (and nothing else) are in the entry block.</p>
</div>
<div class="section" id="sroa-scalar-replacement-of-aggregates">
<h3><a class="toc-backref" href="#id90"><code class="docutils literal"><span class="pre">-sroa</span></code>: Scalar Replacement of Aggregates</a><a class="headerlink" href="#sroa-scalar-replacement-of-aggregates" title="Permalink to this headline">¶</a></h3>
<p>The well-known scalar replacement of aggregates transformation. This transform
breaks up <code class="docutils literal"><span class="pre">alloca</span></code> instructions of aggregate type (structure or array) into
individual <code class="docutils literal"><span class="pre">alloca</span></code> instructions for each member if possible. Then, if
possible, it transforms the individual <code class="docutils literal"><span class="pre">alloca</span></code> instructions into nice clean
scalar SSA form.</p>
</div>
<div class="section" id="sccp-sparse-conditional-constant-propagation">
<span id="passes-sccp"></span><h3><a class="toc-backref" href="#id91"><code class="docutils literal"><span class="pre">-sccp</span></code>: Sparse Conditional Constant Propagation</a><a class="headerlink" href="#sccp-sparse-conditional-constant-propagation" title="Permalink to this headline">¶</a></h3>
<p>Sparse conditional constant propagation and merging, which can be summarized
as:</p>
<ul class="simple">
<li>Assumes values are constant unless proven otherwise</li>
<li>Assumes BasicBlocks are dead unless proven otherwise</li>
<li>Proves values to be constant, and replaces them with constants</li>
<li>Proves conditional branches to be unconditional</li>
</ul>
<p>Note that this pass has a habit of making definitions be dead. It is a good
idea to run a <a class="reference internal" href="#passes-dce"><span class="std std-ref">DCE</span></a> pass sometime after running this pass.</p>
</div>
<div class="section" id="simplifycfg-simplify-the-cfg">
<span id="passes-simplifycfg"></span><h3><a class="toc-backref" href="#id92"><code class="docutils literal"><span class="pre">-simplifycfg</span></code>: Simplify the CFG</a><a class="headerlink" href="#simplifycfg-simplify-the-cfg" title="Permalink to this headline">¶</a></h3>
<p>Performs dead code elimination and basic block merging. Specifically:</p>
<ul class="simple">
<li>Removes basic blocks with no predecessors.</li>
<li>Merges a basic block into its predecessor if there is only one and the
predecessor only has one successor.</li>
<li>Eliminates PHI nodes for basic blocks with a single predecessor.</li>
<li>Eliminates a basic block that only contains an unconditional branch.</li>
</ul>
</div>
<div class="section" id="sink-code-sinking">
<h3><a class="toc-backref" href="#id93"><code class="docutils literal"><span class="pre">-sink</span></code>: Code sinking</a><a class="headerlink" href="#sink-code-sinking" title="Permalink to this headline">¶</a></h3>
<p>This pass moves instructions into successor blocks, when possible, so that they
aren’t executed on paths where their results aren’t needed.</p>
</div>
<div class="section" id="strip-strip-all-symbols-from-a-module">
<h3><a class="toc-backref" href="#id94"><code class="docutils literal"><span class="pre">-strip</span></code>: Strip all symbols from a module</a><a class="headerlink" href="#strip-strip-all-symbols-from-a-module" title="Permalink to this headline">¶</a></h3>
<p>Performs code stripping. This transformation can delete:</p>
<ul class="simple">
<li>names for virtual registers</li>
<li>symbols for internal globals and functions</li>
<li>debug information</li>
</ul>
<p>Note that this transformation makes code much less readable, so it should only
be used in situations where the strip utility would be used, such as reducing
code size or making it harder to reverse engineer code.</p>
</div>
<div class="section" id="strip-dead-debug-info-strip-debug-info-for-unused-symbols">
<h3><a class="toc-backref" href="#id95"><code class="docutils literal"><span class="pre">-strip-dead-debug-info</span></code>: Strip debug info for unused symbols</a><a class="headerlink" href="#strip-dead-debug-info-strip-debug-info-for-unused-symbols" title="Permalink to this headline">¶</a></h3>
<p>performs code stripping. this transformation can delete:</p>
<ul class="simple">
<li>names for virtual registers</li>
<li>symbols for internal globals and functions</li>
<li>debug information</li>
</ul>
<p>note that this transformation makes code much less readable, so it should only
be used in situations where the strip utility would be used, such as reducing
code size or making it harder to reverse engineer code.</p>
</div>
<div class="section" id="strip-dead-prototypes-strip-unused-function-prototypes">
<h3><a class="toc-backref" href="#id96"><code class="docutils literal"><span class="pre">-strip-dead-prototypes</span></code>: Strip Unused Function Prototypes</a><a class="headerlink" href="#strip-dead-prototypes-strip-unused-function-prototypes" title="Permalink to this headline">¶</a></h3>
<p>This pass loops over all of the functions in the input module, looking for dead
declarations and removes them. Dead declarations are declarations of functions
for which no implementation is available (i.e., declarations for unused library
functions).</p>
</div>
<div class="section" id="strip-debug-declare-strip-all-llvm-dbg-declare-intrinsics">
<h3><a class="toc-backref" href="#id97"><code class="docutils literal"><span class="pre">-strip-debug-declare</span></code>: Strip all <code class="docutils literal"><span class="pre">llvm.dbg.declare</span></code> intrinsics</a><a class="headerlink" href="#strip-debug-declare-strip-all-llvm-dbg-declare-intrinsics" title="Permalink to this headline">¶</a></h3>
<p>This pass implements code stripping. Specifically, it can delete:</p>
<ol class="arabic simple">
<li>names for virtual registers</li>
<li>symbols for internal globals and functions</li>
<li>debug information</li>
</ol>
<p>Note that this transformation makes code much less readable, so it should only
be used in situations where the ‘strip’ utility would be used, such as reducing
code size or making it harder to reverse engineer code.</p>
</div>
<div class="section" id="strip-nondebug-strip-all-symbols-except-dbg-symbols-from-a-module">
<h3><a class="toc-backref" href="#id98"><code class="docutils literal"><span class="pre">-strip-nondebug</span></code>: Strip all symbols, except dbg symbols, from a module</a><a class="headerlink" href="#strip-nondebug-strip-all-symbols-except-dbg-symbols-from-a-module" title="Permalink to this headline">¶</a></h3>
<p>This pass implements code stripping. Specifically, it can delete:</p>
<ol class="arabic simple">
<li>names for virtual registers</li>
<li>symbols for internal globals and functions</li>
<li>debug information</li>
</ol>
<p>Note that this transformation makes code much less readable, so it should only
be used in situations where the ‘strip’ utility would be used, such as reducing
code size or making it harder to reverse engineer code.</p>
</div>
<div class="section" id="tailcallelim-tail-call-elimination">
<h3><a class="toc-backref" href="#id99"><code class="docutils literal"><span class="pre">-tailcallelim</span></code>: Tail Call Elimination</a><a class="headerlink" href="#tailcallelim-tail-call-elimination" title="Permalink to this headline">¶</a></h3>
<p>This file transforms calls of the current function (self recursion) followed by
a return instruction with a branch to the entry of the function, creating a
loop. This pass also implements the following extensions to the basic
algorithm:</p>
<ol class="arabic simple">
<li>Trivial instructions between the call and return do not prevent the
transformation from taking place, though currently the analysis cannot
support moving any really useful instructions (only dead ones).</li>
<li>This pass transforms functions that are prevented from being tail recursive
by an associative expression to use an accumulator variable, thus compiling
the typical naive factorial or fib implementation into efficient code.</li>
<li>TRE is performed if the function returns void, if the return returns the
result returned by the call, or if the function returns a run-time constant
on all exits from the function. It is possible, though unlikely, that the
return returns something else (like constant 0), and can still be TRE’d. It
can be TRE’d if <em>all other</em> return instructions in the function return the
exact same value.</li>
<li>If it can prove that callees do not access theier caller stack frame, they
are marked as eligible for tail call elimination (by the code generator).</li>
</ol>
</div>
</div>
<div class="section" id="utility-passes">
<h2><a class="toc-backref" href="#id100">Utility Passes</a><a class="headerlink" href="#utility-passes" title="Permalink to this headline">¶</a></h2>
<p>This section describes the LLVM Utility Passes.</p>
<div class="section" id="deadarghax0r-dead-argument-hacking-bugpoint-use-only-do-not-use">
<h3><a class="toc-backref" href="#id101"><code class="docutils literal"><span class="pre">-deadarghaX0r</span></code>: Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)</a><a class="headerlink" href="#deadarghax0r-dead-argument-hacking-bugpoint-use-only-do-not-use" title="Permalink to this headline">¶</a></h3>
<p>Same as dead argument elimination, but deletes arguments to functions which are
external. This is only for use by <a class="reference internal" href="Bugpoint.html"><span class="doc">bugpoint</span></a>.</p>
</div>
<div class="section" id="extract-blocks-extract-basic-blocks-from-module-for-bugpoint-use">
<h3><a class="toc-backref" href="#id102"><code class="docutils literal"><span class="pre">-extract-blocks</span></code>: Extract Basic Blocks From Module (for bugpoint use)</a><a class="headerlink" href="#extract-blocks-extract-basic-blocks-from-module-for-bugpoint-use" title="Permalink to this headline">¶</a></h3>
<p>This pass is used by bugpoint to extract all blocks from the module into their
own functions.</p>
</div>
<div class="section" id="instnamer-assign-names-to-anonymous-instructions">
<h3><a class="toc-backref" href="#id103"><code class="docutils literal"><span class="pre">-instnamer</span></code>: Assign names to anonymous instructions</a><a class="headerlink" href="#instnamer-assign-names-to-anonymous-instructions" title="Permalink to this headline">¶</a></h3>
<p>This is a little utility pass that gives instructions names, this is mostly
useful when diffing the effect of an optimization because deleting an unnamed
instruction can change all other instruction numbering, making the diff very
noisy.</p>
</div>
<div class="section" id="verify-module-verifier">
<span id="passes-verify"></span><h3><a class="toc-backref" href="#id104"><code class="docutils literal"><span class="pre">-verify</span></code>: Module Verifier</a><a class="headerlink" href="#verify-module-verifier" title="Permalink to this headline">¶</a></h3>
<p>Verifies an LLVM IR code. This is useful to run after an optimization which is
undergoing testing. Note that llvm-as verifies its input before emitting
bitcode, and also that malformed bitcode is likely to make LLVM crash. All
language front-ends are therefore encouraged to verify their output before
performing optimizing transformations.</p>
<ol class="arabic simple">
<li>Both of a binary operator’s parameters are of the same type.</li>
<li>Verify that the indices of mem access instructions match other operands.</li>
<li>Verify that arithmetic and other things are only performed on first-class
types. Verify that shifts and logicals only happen on integrals f.e.</li>
<li>All of the constants in a switch statement are of the correct type.</li>
<li>The code is in valid SSA form.</li>
<li>It is illegal to put a label into any other type (like a structure) or to
return one.</li>
<li>Only phi nodes can be self referential: <code class="docutils literal"><span class="pre">%x</span> <span class="pre">=</span> <span class="pre">add</span> <span class="pre">i32</span> <span class="pre">%x</span></code>, <code class="docutils literal"><span class="pre">%x</span></code> is
invalid.</li>
<li>PHI nodes must have an entry for each predecessor, with no extras.</li>
<li>PHI nodes must be the first thing in a basic block, all grouped together.</li>
<li>PHI nodes must have at least one entry.</li>
<li>All basic blocks should only end with terminator insts, not contain them.</li>
<li>The entry node to a function must not have predecessors.</li>
<li>All Instructions must be embedded into a basic block.</li>
<li>Functions cannot take a void-typed parameter.</li>
<li>Verify that a function’s argument list agrees with its declared type.</li>
<li>It is illegal to specify a name for a void value.</li>
<li>It is illegal to have an internal global value with no initializer.</li>
<li>It is illegal to have a <code class="docutils literal"><span class="pre">ret</span></code> instruction that returns a value that does
not agree with the function return value type.</li>
<li>Function call argument types match the function prototype.</li>
<li>All other things that are tested by asserts spread about the code.</li>
</ol>
<p>Note that this does not provide full security verification (like Java), but
instead just tries to ensure that code is well-formed.</p>
</div>
<div class="section" id="view-cfg-view-cfg-of-function">
<h3><a class="toc-backref" href="#id105"><code class="docutils literal"><span class="pre">-view-cfg</span></code>: View CFG of function</a><a class="headerlink" href="#view-cfg-view-cfg-of-function" title="Permalink to this headline">¶</a></h3>
<p>Displays the control flow graph using the GraphViz tool.</p>
</div>
<div class="section" id="view-cfg-only-view-cfg-of-function-with-no-function-bodies">
<h3><a class="toc-backref" href="#id106"><code class="docutils literal"><span class="pre">-view-cfg-only</span></code>: View CFG of function (with no function bodies)</a><a class="headerlink" href="#view-cfg-only-view-cfg-of-function-with-no-function-bodies" title="Permalink to this headline">¶</a></h3>
<p>Displays the control flow graph using the GraphViz tool, but omitting function
bodies.</p>
</div>
<div class="section" id="view-dom-view-dominance-tree-of-function">
<h3><a class="toc-backref" href="#id107"><code class="docutils literal"><span class="pre">-view-dom</span></code>: View dominance tree of function</a><a class="headerlink" href="#view-dom-view-dominance-tree-of-function" title="Permalink to this headline">¶</a></h3>
<p>Displays the dominator tree using the GraphViz tool.</p>
</div>
<div class="section" id="view-dom-only-view-dominance-tree-of-function-with-no-function-bodies">
<h3><a class="toc-backref" href="#id108"><code class="docutils literal"><span class="pre">-view-dom-only</span></code>: View dominance tree of function (with no function bodies)</a><a class="headerlink" href="#view-dom-only-view-dominance-tree-of-function-with-no-function-bodies" title="Permalink to this headline">¶</a></h3>
<p>Displays the dominator tree using the GraphViz tool, but omitting function
bodies.</p>
</div>
<div class="section" id="view-postdom-view-postdominance-tree-of-function">
<h3><a class="toc-backref" href="#id109"><code class="docutils literal"><span class="pre">-view-postdom</span></code>: View postdominance tree of function</a><a class="headerlink" href="#view-postdom-view-postdominance-tree-of-function" title="Permalink to this headline">¶</a></h3>
<p>Displays the post dominator tree using the GraphViz tool.</p>
</div>
<div class="section" id="view-postdom-only-view-postdominance-tree-of-function-with-no-function-bodies">
<h3><a class="toc-backref" href="#id110"><code class="docutils literal"><span class="pre">-view-postdom-only</span></code>: View postdominance tree of function (with no function bodies)</a><a class="headerlink" href="#view-postdom-only-view-postdominance-tree-of-function-with-no-function-bodies" title="Permalink to this headline">¶</a></h3>
<p>Displays the post dominator tree using the GraphViz tool, but omitting function
bodies.</p>
</div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="YamlIO.html" title="YAML I/O"
>next</a> |</li>
<li class="right" >
<a href="ReleaseNotes.html" title="LLVM 4.0.0 Release Notes"
>previous</a> |</li>
<li><a href="http://llvm.org/">LLVM Home</a> | </li>
<li><a href="index.html">Documentation</a>»</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2003-2018, LLVM Project.
Last updated on 2018-02-13.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.7.
</div>
</body>
</html>
|