OLD | NEW |
1 //===-- PNaClABISimplify.cpp - Lists PNaCl ABI simplification passes ------===// | 1 //===-- PNaClABISimplify.cpp - Lists PNaCl ABI simplification passes ------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file implements the meta-passes "-pnacl-abi-simplify-preopt" | 10 // This file implements the meta-passes "-pnacl-abi-simplify-preopt" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 void llvm::PNaClABISimplifyAddPreOptPasses(PassManager &PM) { | 24 void llvm::PNaClABISimplifyAddPreOptPasses(PassManager &PM) { |
25 // Internalize all symbols in the module except _start, which is the only | 25 // Internalize all symbols in the module except _start, which is the only |
26 // symbol a stable PNaCl pexe is allowed to export. | 26 // symbol a stable PNaCl pexe is allowed to export. |
27 const char *SymbolsToPreserve[] = { "_start" }; | 27 const char *SymbolsToPreserve[] = { "_start" }; |
28 PM.add(createInternalizePass(SymbolsToPreserve)); | 28 PM.add(createInternalizePass(SymbolsToPreserve)); |
29 | 29 |
30 // LowerExpect converts Intrinsic::expect into branch weights, | 30 // LowerExpect converts Intrinsic::expect into branch weights, |
31 // which can then be removed after BlockPlacement. | 31 // which can then be removed after BlockPlacement. |
32 PM.add(createLowerExpectIntrinsicPass()); | 32 PM.add(createLowerExpectIntrinsicPass()); |
33 // Rewrite unsupported intrinsics and inline assembly directives to | 33 // Rewrite unsupported intrinsics to simpler and portable constructs. |
34 // simpler and portable constructs. | |
35 PM.add(createRewriteLLVMIntrinsicsPass()); | 34 PM.add(createRewriteLLVMIntrinsicsPass()); |
36 PM.add(createRewriteAsmDirectivesPass()); | |
37 // LowerInvoke prevents use of C++ exception handling, which is not | 35 // LowerInvoke prevents use of C++ exception handling, which is not |
38 // yet supported in the PNaCl ABI. | 36 // yet supported in the PNaCl ABI. |
39 PM.add(createLowerInvokePass()); | 37 PM.add(createLowerInvokePass()); |
40 // Remove landingpad blocks made unreachable by LowerInvoke. | 38 // Remove landingpad blocks made unreachable by LowerInvoke. |
41 PM.add(createCFGSimplificationPass()); | 39 PM.add(createCFGSimplificationPass()); |
42 | 40 |
43 // Expand out some uses of struct types. | 41 // Expand out some uses of struct types. |
44 PM.add(createExpandArithWithOverflowPass()); | 42 PM.add(createExpandArithWithOverflowPass()); |
45 // ExpandStructRegs must be run after ExpandArithWithOverflow to | 43 // ExpandStructRegs must be run after ExpandArithWithOverflow to |
46 // expand out the insertvalue instructions that | 44 // expand out the insertvalue instructions that |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // because they might reintroduce ConstantExprs. | 89 // because they might reintroduce ConstantExprs. |
92 PM.add(createExpandConstantExprPass()); | 90 PM.add(createExpandConstantExprPass()); |
93 // PromoteIntegersPass does not handle constexprs and creates GEPs, | 91 // PromoteIntegersPass does not handle constexprs and creates GEPs, |
94 // so it goes between those passes. | 92 // so it goes between those passes. |
95 PM.add(createPromoteIntegersPass()); | 93 PM.add(createPromoteIntegersPass()); |
96 // ExpandGetElementPtr must follow ExpandConstantExpr to expand the | 94 // ExpandGetElementPtr must follow ExpandConstantExpr to expand the |
97 // getelementptr instructions it creates. | 95 // getelementptr instructions it creates. |
98 PM.add(createExpandGetElementPtrPass()); | 96 PM.add(createExpandGetElementPtrPass()); |
99 // Rewrite atomic and volatile instructions with intrinsic calls. | 97 // Rewrite atomic and volatile instructions with intrinsic calls. |
100 PM.add(createRewriteAtomicsPass()); | 98 PM.add(createRewriteAtomicsPass()); |
| 99 // Remove ``asm("":::"memory")``. This must occur after rewriting |
| 100 // atomics: a ``fence seq_cst`` surrounded by ``asm("":::"memory")`` |
| 101 // has special meaning and is translated differently. |
| 102 PM.add(createRemoveAsmMemoryPass()); |
101 // ReplacePtrsWithInts assumes that getelementptr instructions and | 103 // ReplacePtrsWithInts assumes that getelementptr instructions and |
102 // ConstantExprs have already been expanded out. | 104 // ConstantExprs have already been expanded out. |
103 PM.add(createReplacePtrsWithIntsPass()); | 105 PM.add(createReplacePtrsWithIntsPass()); |
104 | 106 |
105 // We place StripAttributes after optimization passes because many | 107 // We place StripAttributes after optimization passes because many |
106 // analyses add attributes to reflect their results. | 108 // analyses add attributes to reflect their results. |
107 // StripAttributes must come after ExpandByVal and | 109 // StripAttributes must come after ExpandByVal and |
108 // ExpandSmallArguments. | 110 // ExpandSmallArguments. |
109 PM.add(createStripAttributesPass()); | 111 PM.add(createStripAttributesPass()); |
110 | 112 |
111 // Strip dead prototytes to appease the intrinsic ABI checks. | 113 // Strip dead prototytes to appease the intrinsic ABI checks. |
112 // ExpandVarArgs leaves around vararg intrinsics, and | 114 // ExpandVarArgs leaves around vararg intrinsics, and |
113 // ReplacePtrsWithInts leaves the lifetime.start/end intrinsics. | 115 // ReplacePtrsWithInts leaves the lifetime.start/end intrinsics. |
114 PM.add(createStripDeadPrototypesPass()); | 116 PM.add(createStripDeadPrototypesPass()); |
115 } | 117 } |
OLD | NEW |