[llvm-branch-commits] [llvm-branch] r109970 - in /llvm/branches/wendling/eh: include/llvm/CodeGen/MachineModuleInfo.h lib/CodeGen/MachineModuleInfo.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Bill Wendling
isanbard at gmail.com
Sun Aug 1 02:25:46 PDT 2010
Author: void
Date: Sun Aug 1 04:25:46 2010
New Revision: 109970
URL: http://llvm.org/viewvc/llvm-project?rev=109970&view=rev
Log:
Some revamping of how MMI stores EH information. Filters and personalities are
for the whole function.
Modified:
llvm/branches/wendling/eh/include/llvm/CodeGen/MachineModuleInfo.h
llvm/branches/wendling/eh/lib/CodeGen/MachineModuleInfo.cpp
llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/FastISel.cpp
llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Modified: llvm/branches/wendling/eh/include/llvm/CodeGen/MachineModuleInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/wendling/eh/include/llvm/CodeGen/MachineModuleInfo.h?rev=109970&r1=109969&r2=109970&view=diff
==============================================================================
--- llvm/branches/wendling/eh/include/llvm/CodeGen/MachineModuleInfo.h (original)
+++ llvm/branches/wendling/eh/include/llvm/CodeGen/MachineModuleInfo.h Sun Aug 1 04:25:46 2010
@@ -52,6 +52,7 @@
class Constant;
class GlobalVariable;
class MDNode;
+class MMIAddrLabelMap;
class MachineBasicBlock;
class MachineFunction;
class Module;
@@ -88,8 +89,6 @@
: LandingPadBlock(MBB), LandingPadLabel(0), Personality(0) {}
};
-class MMIAddrLabelMap;
-
//===----------------------------------------------------------------------===//
/// MachineModuleInfo - This class contains meta information specific to a
/// module. Queries can be made by different debugging and exception handling
@@ -144,7 +143,6 @@
/// llvm.compiler.used.
SmallPtrSet<const Function *, 32> UsedFunctions;
-
/// AddrLabelSymbols - This map keeps track of which symbol is being used for
/// the specified basic block's address of label.
MMIAddrLabelMap *AddrLabelSymbols;
@@ -152,10 +150,23 @@
bool CallsEHReturn;
bool CallsUnwindInit;
- /// FilterMap - Map of filter IDs for a function.
- typedef SmallPtrSet<const Value*, 2> FilterListTy;
- typedef DenseMap<const MachineFunction*, FilterListTy> FilterMapTy;
- FilterMapTy FilterMap;
+ struct LandingPadStuff { // Rename.
+ /// FilterSet - A set of filter IDs for a function.
+ SmallPtrSet<const GlobalVariable*, 2> FilterSet;
+
+ /// PersonalityFn - PersonalityFunction associated with the machine
+ /// function.
+ /// FIXME: Could have more than one personality function per function.
+ const Value *PersonalityFnMap;
+
+ void clear() {
+ FilterSet.clear();
+ PersonalityFnMap = 0;
+ }
+ };
+
+ // FIXME: Do we need a map here?
+ LandingPadStuff LandingPadInformation;
/// DbgInfoAvailable - True if debugging information is available
/// in this module.
@@ -240,12 +251,10 @@
//===- EH ---------------------------------------------------------------===//
-
private:
/// getOrCreateLandingPadInfo - Find or create an LandingPadInfo for the
/// specified MachineBasicBlock.
LandingPadInfo &getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad);
-
public:
/// addInvoke - Provide the begin and end labels of an invoke style call and
/// associate it with a try landing pad block.
@@ -255,12 +264,18 @@
/// addLandingPad - Add a new panding pad. Returns the label ID for the
/// landing pad entry.
MCSymbol *addLandingPad(MachineBasicBlock *LandingPad);
-
+
/// addPersonality - Provide the personality function for the exception
/// information.
- void addPersonality(MachineBasicBlock *LandingPad,
- const Function *Personality);
-
+ void addPersonality(const Value *PersFn) {
+ // FIXME: This assert only holds if we have one personality function per
+ // function.
+ assert((LandingPadInformation.PersonalityFnMap == 0 ||
+ LandingPadInformation.PersonalityFnMap == PersFn) &&
+ "Trying to reset the personality fn with a different personality?!");
+ LandingPadInformation.PersonalityFnMap = PersFn;
+ }
+
/// getPersonalityIndex - Get index of the current personality function inside
/// Personalitites array
unsigned getPersonalityIndex() const;
@@ -284,8 +299,8 @@
/// addFilterTypeInfo - Provide the filter typeinfo for a machine function.
///
- void addFilterTypeInfo(const MachineFunction *MF, const Value *V) {
- FilterMap[MF].insert(V);
+ void addFilterTypeInfo(const GlobalVariable *GV) {
+ LandingPadInformation.FilterSet.insert(GV);
}
/// addCleanup - Add a cleanup action for a landing pad.
@@ -343,7 +358,11 @@
/// getPersonality - Return a personality function if available. The presence
/// of one is required to emit exception handling info.
- const Function *getPersonality() const;
+ const Value *getPersonality() const {
+ // FIXME: Until PR1414 is fixed, we're using 1 personality function per
+ // function
+ return LandingPadInformation.PersonalityFnMap;
+ }
/// setVariableDbgInfo - Collect information used to emit debugging
/// information of a variable.
Modified: llvm/branches/wendling/eh/lib/CodeGen/MachineModuleInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/wendling/eh/lib/CodeGen/MachineModuleInfo.cpp?rev=109970&r1=109969&r2=109970&view=diff
==============================================================================
--- llvm/branches/wendling/eh/lib/CodeGen/MachineModuleInfo.cpp (original)
+++ llvm/branches/wendling/eh/lib/CodeGen/MachineModuleInfo.cpp Sun Aug 1 04:25:46 2010
@@ -306,10 +306,10 @@
TypeInfos.clear();
FilterIds.clear();
FilterEnds.clear();
- FilterMap.clear();
- CallsEHReturn = 0;
- CallsUnwindInit = 0;
+ CallsEHReturn = false;
+ CallsUnwindInit = false;
VariableDbgInfo.clear();
+ LandingPadInformation.clear();
}
/// AnalyzeModule - Scan the module for global debug information.
@@ -370,7 +370,7 @@
//===- EH -----------------------------------------------------------------===//
-/// getOrCreateLandingPadInfo - Find or create an LandingPadInfo for the
+/// getOrCreateLandingPadInfo - Find or create a LandingPadInfo for the
/// specified MachineBasicBlock.
LandingPadInfo &MachineModuleInfo::
getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad) {
@@ -395,7 +395,6 @@
}
/// addLandingPad - Provide the label of a try LandingPad block.
-///
MCSymbol *MachineModuleInfo::addLandingPad(MachineBasicBlock *LandingPad) {
MCSymbol *LandingPadLabel = Context.CreateTempSymbol();
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
@@ -403,27 +402,7 @@
return LandingPadLabel;
}
-/// addPersonality - Provide the personality function for the exception
-/// information.
-void MachineModuleInfo::addPersonality(MachineBasicBlock *LandingPad,
- const Function *Personality) {
- LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
- LP.Personality = Personality;
-
- for (unsigned i = 0; i < Personalities.size(); ++i)
- if (Personalities[i] == Personality)
- return;
-
- // If this is the first personality we're adding go
- // ahead and add it at the beginning.
- if (Personalities[0] == NULL)
- Personalities[0] = Personality;
- else
- Personalities.push_back(Personality);
-}
-
/// addCatchTypeInfo - Provide the catch typeinfo for a landing pad.
-///
void MachineModuleInfo::addCatchTypeInfo(MachineBasicBlock *LandingPad,
std::vector<const GlobalVariable *> &TyInfo) {
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
@@ -432,7 +411,6 @@
}
/// addCleanup - Add a cleanup action for a landing pad.
-///
void MachineModuleInfo::addCleanup(MachineBasicBlock *LandingPad) {
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
LP.TypeIds.push_back(0);
@@ -524,13 +502,6 @@
return FilterID;
}
-/// getPersonality - Return the personality function for the current function.
-const Function *MachineModuleInfo::getPersonality() const {
- // FIXME: Until PR1414 will be fixed, we're using 1 personality function per
- // function
- return !LandingPads.empty() ? LandingPads[0].Personality : NULL;
-}
-
/// getPersonalityIndex - Return unique index for current personality
/// function. NULL/first personality function should always get zero index.
unsigned MachineModuleInfo::getPersonalityIndex() const {
Modified: llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=109970&r1=109969&r2=109970&view=diff
==============================================================================
--- llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/FastISel.cpp Sun Aug 1 04:25:46 2010
@@ -516,10 +516,10 @@
// Add the filter IDs to the machine function.
const IntrinsicInst *II = cast<IntrinsicInst>(I);
MachineModuleInfo &MMI = FuncInfo.MF->getMMI();
- for (unsigned i = 0, e = II->getNumArgOperands(); i != e; ++i)
- MMI.addFilterTypeInfo(FuncInfo.MF,
- II->getArgOperand(i)->stripPointerCasts());
-
+ for (unsigned i = 0, e = II->getNumArgOperands(); i != e; ++i) {
+ const Value *V = II->getArgOperand(i)->stripPointerCasts();
+ MMI.addFilterTypeInfo(cast<const GlobalVariable>(V));
+ }
return true;
}
@@ -542,49 +542,6 @@
}
break;
}
- case Intrinsic::eh_selector: {
- EVT VT = TLI.getValueType(I->getType());
- switch (TLI.getOperationAction(ISD::EHSELECTION, VT)) {
- default: break;
- case TargetLowering::Expand: {
- if (FuncInfo.MBB->isLandingPad())
- AddCatchInfo(*cast<CallInst>(I), &FuncInfo.MF->getMMI(), FuncInfo.MBB);
- else {
-#ifndef NDEBUG
- FuncInfo.CatchInfoLost.insert(cast<CallInst>(I));
-#endif
- // FIXME: Mark exception selector register as live in. Hack for PR1508.
- unsigned Reg = TLI.getExceptionSelectorRegister();
- if (Reg) FuncInfo.MBB->addLiveIn(Reg);
- }
-
- unsigned Reg = TLI.getExceptionSelectorRegister();
- EVT SrcVT = TLI.getPointerTy();
- const TargetRegisterClass *RC = TLI.getRegClassFor(SrcVT);
- unsigned ResultReg = createResultReg(RC);
- BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY),
- ResultReg).addReg(Reg);
-
- bool ResultRegIsKill = hasTrivialKill(I);
-
- // Cast the register to the type of the selector.
- if (SrcVT.bitsGT(MVT::i32))
- ResultReg = FastEmit_r(SrcVT.getSimpleVT(), MVT::i32, ISD::TRUNCATE,
- ResultReg, ResultRegIsKill);
- else if (SrcVT.bitsLT(MVT::i32))
- ResultReg = FastEmit_r(SrcVT.getSimpleVT(), MVT::i32,
- ISD::SIGN_EXTEND, ResultReg, ResultRegIsKill);
- if (ResultReg == 0)
- // Unhandled operand. Halt "fast" selection and bail.
- return false;
-
- UpdateValueMap(I, ResultReg);
-
- return true;
- }
- }
- break;
- }
}
// An arbitrary call. Bail.
Modified: llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp?rev=109970&r1=109969&r2=109970&view=diff
==============================================================================
--- llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (original)
+++ llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp Sun Aug 1 04:25:46 2010
@@ -121,11 +121,12 @@
(TySize > 8 && isa<ArrayType>(Ty) &&
cast<ArrayType>(Ty)->getElementType()->isIntegerTy(8)));
StaticAllocaMap[AI] =
- MF->getFrameInfo()->CreateStackObject(TySize, Align, false, MayNeedSP);
+ MF->getFrameInfo()->CreateStackObject(TySize, Align, false,MayNeedSP);
}
for (; BB != EB; ++BB)
- for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
+ for (BasicBlock::const_iterator
+ I = BB->begin(), E = BB->end(); I != E; ++I) {
// Mark values used outside their block as exported, by allocating
// a virtual register for them.
if (isUsedOutsideOfDefiningBlock(I))
@@ -188,41 +189,52 @@
SmallVector<EVT, 4> ValueVTs;
ComputeValueVTs(TLI, PN->getType(), ValueVTs);
+
for (unsigned vti = 0, vte = ValueVTs.size(); vti != vte; ++vti) {
EVT VT = ValueVTs[vti];
unsigned NumRegisters = TLI.getNumRegisters(Fn->getContext(), VT);
const TargetInstrInfo *TII = MF->getTarget().getInstrInfo();
+
for (unsigned i = 0; i != NumRegisters; ++i)
BuildMI(MBB, DL, TII->get(TargetOpcode::PHI), PHIReg + i);
+
PHIReg += NumRegisters;
}
}
- }
- // Mark landing pad blocks.
- for (BB = Fn->begin(); BB != EB; ++BB)
- if (const InvokeInst *Invoke = dyn_cast<InvokeInst>(BB->getTerminator()))
+ if (const InvokeInst *Invoke = dyn_cast<InvokeInst>(BB->getTerminator())) {
+ MachineModuleInfo &MMI = MF->getMMI();
+
+ // Add personality function.
+ MMI.addPersonality(Invoke->getPersonalityFn()->stripPointerCasts());
+
+ // Mark landing pad blocks.
for (unsigned I = 1, E = Invoke->getNumSuccessors(); I < E; ++I)
MBBMap[Invoke->getSuccessor(I)]->setIsLandingPad();
+ }
+ }
}
/// clear - Clear out all the function-specific state. This returns this
/// FunctionLoweringInfo to an empty state, ready to be used for a
/// different function.
void FunctionLoweringInfo::clear() {
+#if 0 ///EH-FIXME: Still valid?
assert(CatchInfoFound.size() == CatchInfoLost.size() &&
"Not all catch info was assigned to a landing pad!");
- MBBMap.clear();
- ValueMap.clear();
- StaticAllocaMap.clear();
#ifndef NDEBUG
- CatchInfoLost.clear();
CatchInfoFound.clear();
+ CatchInfoLost.clear();
#endif
- LiveOutRegInfo.clear();
+#endif
+
ArgDbgValues.clear();
+ LiveOutRegInfo.clear();
+ MBBMap.clear();
RegFixups.clear();
+ StaticAllocaMap.clear();
+ ValueMap.clear();
}
/// CreateReg - Allocate a single virtual register for the given type.
@@ -230,13 +242,12 @@
return RegInfo->createVirtualRegister(TLI.getRegClassFor(VT));
}
-/// CreateRegs - Allocate the appropriate number of virtual registers of
-/// the correctly promoted or expanded types. Assign these registers
-/// consecutive vreg numbers and return the first assigned number.
+/// CreateRegs - Allocate the appropriate number of virtual registers of the
+/// correctly promoted or expanded types. Assign these registers consecutive
+/// vreg numbers and return the first assigned number.
///
/// In the case that the given value has struct or array type, this function
/// will assign registers for each member or element.
-///
unsigned FunctionLoweringInfo::CreateRegs(const Type *Ty) {
SmallVector<EVT, 4> ValueVTs;
ComputeValueVTs(TLI, Ty, ValueVTs);
@@ -252,9 +263,11 @@
if (!FirstReg) FirstReg = R;
}
}
+
return FirstReg;
}
+#if 0///EH-FIXME:
/// AddCatchInfo - Extract the personality and type infos from an eh.selector
/// call, and add them to the specified machine basic block.
void llvm::AddCatchInfo(const CallInst &I, MachineModuleInfo *MMI,
@@ -264,7 +277,7 @@
assert(CE->getOpcode() == Instruction::BitCast &&
isa<Function>(CE->getOperand(0)) &&
"Personality should be a function");
- MMI->addPersonality(MBB, cast<Function>(CE->getOperand(0)));
+ MMI->addPersonality(MBB->getParent(), cast<Function>(CE->getOperand(0)));
// Gather all the type infos for this landing pad and pass them along to
// MachineModuleInfo.
@@ -315,3 +328,4 @@
#endif
}
}
+#endif
Modified: llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=109970&r1=109969&r2=109970&view=diff
==============================================================================
--- llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Sun Aug 1 04:25:46 2010
@@ -4125,8 +4125,10 @@
// Add the filter IDs to the machine function.
MachineFunction &MF = DAG.getMachineFunction();
MachineModuleInfo &MMI = MF.getMMI();
- for (unsigned i = 0, e = I.getNumArgOperands(); i != e; ++i)
- MMI.addFilterTypeInfo(&MF, I.getArgOperand(i)->stripPointerCasts());
+ for (unsigned i = 0, e = I.getNumArgOperands(); i != e; ++i) {
+ const Value *V = I.getArgOperand(i)->stripPointerCasts();
+ MMI.addFilterTypeInfo(cast<const GlobalVariable>(V));
+ }
return 0;
}
@@ -4143,41 +4145,6 @@
return 0;
}
-///EH-FIXME: Remove eh_selector and eh_typeid_for.
- case Intrinsic::eh_selector: {
- MachineBasicBlock *CallMBB = FuncInfo.MBB;
- MachineModuleInfo &MMI = DAG.getMachineFunction().getMMI();
- if (CallMBB->isLandingPad())
- AddCatchInfo(I, &MMI, CallMBB);
- else {
-#ifndef NDEBUG
- FuncInfo.CatchInfoLost.insert(&I);
-#endif
- // FIXME: Mark exception selector register as live in. Hack for PR1508.
- unsigned Reg = TLI.getExceptionSelectorRegister();
- if (Reg) FuncInfo.MBB->addLiveIn(Reg);
- }
-
- // Insert the EHSELECTION instruction.
- SDVTList VTs = DAG.getVTList(TLI.getPointerTy(), MVT::Other);
- SDValue Ops[2];
- Ops[0] = getValue(I.getArgOperand(0));
- Ops[1] = getRoot();
- SDValue Op = DAG.getNode(ISD::EHSELECTION, dl, VTs, Ops, 2);
- DAG.setRoot(Op.getValue(1));
- setValue(&I, DAG.getSExtOrTrunc(Op, dl, MVT::i32));
- return 0;
- }
-
- case Intrinsic::eh_typeid_for: {
- // Find the type id for the given typeinfo.
- GlobalVariable *GV = ExtractTypeInfo(I.getArgOperand(0));
- unsigned TypeID = DAG.getMachineFunction().getMMI().getTypeIDFor(GV);
- Res = DAG.getConstant(TypeID, MVT::i32);
- setValue(&I, Res);
- return 0;
- }
-
case Intrinsic::eh_return_i32:
case Intrinsic::eh_return_i64:
DAG.getMachineFunction().getMMI().setCallsEHReturn(true);
Modified: llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=109970&r1=109969&r2=109970&view=diff
==============================================================================
--- llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/branches/wendling/eh/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Aug 1 04:25:46 2010
@@ -667,6 +667,7 @@
Reg = TLI.getExceptionSelectorRegister();
if (Reg) FuncInfo->MBB->addLiveIn(Reg);
+#if 0 ///EH-FIXME:
// FIXME: Hack around an exception handling flaw (PR1508): the personality
// function and list of typeids logically belong to the invoke (or, if you
// like, the basic block containing the invoke), and need to be associated
@@ -691,6 +692,7 @@
// No catch info found - try to extract some from the successor.
CopyCatchInfo(Br->getSuccessor(0), LLVMBB, &MF->getMMI(), *FuncInfo);
}
+#endif
}
void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) {
More information about the llvm-branch-commits
mailing list