//===-- CodeGenCommonISel.cpp ---------------------------------------------===// // // 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 // //===----------------------------------------------------------------------===// // // This file defines common utilies that are shared between SelectionDAG and // GlobalISel frameworks. // //===----------------------------------------------------------------------===// #include "llvm/CodeGen/CodeGenCommonISel.h" #include "llvm/Analysis/BranchProbabilityInfo.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/TargetInstrInfo.h" #include "llvm/CodeGen/TargetOpcodes.h" #include "llvm/IR/DebugInfoMetadata.h" #define DEBUG_TYPE … usingnamespacellvm; /// Add a successor MBB to ParentMBB< creating a new MachineBB for BB if SuccMBB /// is 0. MachineBasicBlock * StackProtectorDescriptor::addSuccessorMBB( const BasicBlock *BB, MachineBasicBlock *ParentMBB, bool IsLikely, MachineBasicBlock *SuccMBB) { … } /// Given that the input MI is before a partial terminator sequence TSeq, return /// true if M + TSeq also a partial terminator sequence. /// /// A Terminator sequence is a sequence of MachineInstrs which at this point in /// lowering copy vregs into physical registers, which are then passed into /// terminator instructors so we can satisfy ABI constraints. A partial /// terminator sequence is an improper subset of a terminator sequence (i.e. it /// may be the whole terminator sequence). static bool MIIsInTerminatorSequence(const MachineInstr &MI) { … } /// Find the split point at which to splice the end of BB into its success stack /// protector check machine basic block. /// /// On many platforms, due to ABI constraints, terminators, even before register /// allocation, use physical registers. This creates an issue for us since /// physical registers at this point can not travel across basic /// blocks. Luckily, selectiondag always moves physical registers into vregs /// when they enter functions and moves them through a sequence of copies back /// into the physical registers right before the terminator creating a /// ``Terminator Sequence''. This function is searching for the beginning of the /// terminator sequence so that we can ensure that we splice off not just the /// terminator, but additionally the copies that move the vregs into the /// physical registers. MachineBasicBlock::iterator llvm::findSplitPointForStackProtector(MachineBasicBlock *BB, const TargetInstrInfo &TII) { … } FPClassTest llvm::invertFPClassTestIfSimpler(FPClassTest Test, bool UseFCmp) { … } static MachineOperand *getSalvageOpsForCopy(const MachineRegisterInfo &MRI, MachineInstr &Copy) { … } static MachineOperand *getSalvageOpsForTrunc(const MachineRegisterInfo &MRI, MachineInstr &Trunc, SmallVectorImpl<uint64_t> &Ops) { … } static MachineOperand *salvageDebugInfoImpl(const MachineRegisterInfo &MRI, MachineInstr &MI, SmallVectorImpl<uint64_t> &Ops) { … } void llvm::salvageDebugInfoForDbgValue(const MachineRegisterInfo &MRI, MachineInstr &MI, ArrayRef<MachineOperand *> DbgUsers) { … }