//===- DemoteRegToStack.cpp - Move a virtual register to the stack --------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "llvm/ADT/DenseMap.h" #include "llvm/Analysis/CFG.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Function.h" #include "llvm/IR/Instructions.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Local.h" usingnamespacellvm; /// DemoteRegToStack - This function takes a virtual register computed by an /// Instruction and replaces it with a slot in the stack frame, allocated via /// alloca. This allows the CFG to be changed around without fear of /// invalidating the SSA information for the value. It returns the pointer to /// the alloca inserted to create a stack slot for I. AllocaInst *llvm::DemoteRegToStack(Instruction &I, bool VolatileLoads, std::optional<BasicBlock::iterator> AllocaPoint) { … } /// DemotePHIToStack - This function takes a virtual register computed by a PHI /// node and replaces it with a slot in the stack frame allocated via alloca. /// The PHI node is deleted. It returns the pointer to the alloca inserted. AllocaInst *llvm::DemotePHIToStack(PHINode *P, std::optional<BasicBlock::iterator> AllocaPoint) { … }