diff options
author | Ahmed Bougacha <ahmed.bougacha@gmail.com> | 2016-11-16 22:24:56 +0000 |
---|---|---|
committer | Ahmed Bougacha <ahmed.bougacha@gmail.com> | 2016-11-16 22:24:56 +0000 |
commit | 456dce8a84c97b56b10f0e7143c36bee4ac85fe4 (patch) | |
tree | 0b1f1f79ab2ea26ea0d7306e5559ad8fcfc40c3a /llvm/lib/CodeGen/MachineModuleInfo.cpp | |
parent | 2b4c127531410e1c32d9480bb2daa7d53b87c16c (diff) | |
download | llvm-456dce8a84c97b56b10f0e7143c36bee4ac85fe4.zip llvm-456dce8a84c97b56b10f0e7143c36bee4ac85fe4.tar.gz llvm-456dce8a84c97b56b10f0e7143c36bee4ac85fe4.tar.bz2 |
[CodeGen] Pull MMI helpers from FunctionLoweringInfo to MMI. NFC.
They're not SelectionDAG- or FunctionLoweringInfo-specific. They
are, however, specific to building MMI from IR.
We could make them members, but it's nice having MMI be a "simple" data
structure and this logic kept separate.
This also lets us reuse them from GlobalISel.
llvm-svn: 287167
Diffstat (limited to 'llvm/lib/CodeGen/MachineModuleInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineModuleInfo.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp index 1f4630f..8efa07a 100644 --- a/llvm/lib/CodeGen/MachineModuleInfo.cpp +++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -9,6 +9,7 @@ #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/ADT/PointerUnion.h" +#include "llvm/ADT/PostOrderIterator.h" #include "llvm/ADT/TinyPtrVector.h" #include "llvm/Analysis/EHPersonalities.h" #include "llvm/Analysis/ValueTracking.h" @@ -19,6 +20,7 @@ #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/GlobalVariable.h" +#include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" #include "llvm/MC/MCObjectFileInfo.h" #include "llvm/MC/MCSymbol.h" @@ -485,3 +487,52 @@ FunctionPass *createFreeMachineFunctionPass() { return new FreeMachineFunction(); } } // end namespace llvm + +//===- MMI building helpers -----------------------------------------------===// + +void llvm::ComputeUsesVAFloatArgument(const CallInst &I, + MachineModuleInfo *MMI) { + FunctionType *FT = + cast<FunctionType>(I.getCalledValue()->getType()->getContainedType(0)); + if (FT->isVarArg() && !MMI->usesVAFloatArgument()) { + for (unsigned i = 0, e = I.getNumArgOperands(); i != e; ++i) { + Type *T = I.getArgOperand(i)->getType(); + for (auto i : post_order(T)) { + if (i->isFloatingPointTy()) { + MMI->setUsesVAFloatArgument(true); + return; + } + } + } + } +} + +void llvm::AddLandingPadInfo(const LandingPadInst &I, MachineModuleInfo &MMI, + MachineBasicBlock *MBB) { + if (const auto *PF = dyn_cast<Function>( + I.getParent()->getParent()->getPersonalityFn()->stripPointerCasts())) + MMI.addPersonality(PF); + + if (I.isCleanup()) + MMI.addCleanup(MBB); + + // FIXME: New EH - Add the clauses in reverse order. This isn't 100% correct, + // but we need to do it this way because of how the DWARF EH emitter + // processes the clauses. + for (unsigned i = I.getNumClauses(); i != 0; --i) { + Value *Val = I.getClause(i - 1); + if (I.isCatch(i - 1)) { + MMI.addCatchTypeInfo(MBB, + dyn_cast<GlobalValue>(Val->stripPointerCasts())); + } else { + // Add filters in a list. + Constant *CVal = cast<Constant>(Val); + SmallVector<const GlobalValue *, 4> FilterList; + for (User::op_iterator II = CVal->op_begin(), IE = CVal->op_end(); + II != IE; ++II) + FilterList.push_back(cast<GlobalValue>((*II)->stripPointerCasts())); + + MMI.addFilterTypeInfo(MBB, FilterList); + } + } +} |