| 1 | //===- PromoteMemToReg.h - Promote Allocas to Scalars -----------*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file exposes an interface to promote alloca instructions to SSA |
| 10 | // registers, by using the SSA construction algorithm. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_TRANSFORMS_UTILS_PROMOTEMEMTOREG_H |
| 15 | #define LLVM_TRANSFORMS_UTILS_PROMOTEMEMTOREG_H |
| 16 | |
| 17 | #include "llvm/Support/Compiler.h" |
| 18 | |
| 19 | namespace llvm { |
| 20 | |
| 21 | template <typename T> class ArrayRef; |
| 22 | class AllocaInst; |
| 23 | class DominatorTree; |
| 24 | class AssumptionCache; |
| 25 | |
| 26 | /// Return true if this alloca is legal for promotion. |
| 27 | /// |
| 28 | /// This is true if there are only loads, stores, and lifetime markers |
| 29 | /// (transitively) using this alloca. This also enforces that there is only |
| 30 | /// ever one layer of bitcasts or GEPs between the alloca and the lifetime |
| 31 | /// markers. |
| 32 | LLVM_ABI bool isAllocaPromotable(const AllocaInst *AI); |
| 33 | |
| 34 | /// Promote the specified list of alloca instructions into scalar |
| 35 | /// registers, inserting PHI nodes as appropriate. |
| 36 | /// |
| 37 | /// This function makes use of DominanceFrontier information. This function |
| 38 | /// does not modify the CFG of the function at all. All allocas must be from |
| 39 | /// the same function. |
| 40 | /// |
| 41 | LLVM_ABI void PromoteMemToReg(ArrayRef<AllocaInst *> Allocas, DominatorTree &DT, |
| 42 | AssumptionCache *AC = nullptr); |
| 43 | |
| 44 | } // End llvm namespace |
| 45 | |
| 46 | #endif |
| 47 | |