X("machinemoduleinfo", "Module Information");
char MachineModuleInfo::ID = 0;
+// Out of line virtual method.
+MachineModuleInfoImpl::~MachineModuleInfoImpl() {}
+
//===----------------------------------------------------------------------===//
-
+
MachineModuleInfo::MachineModuleInfo()
: ImmutablePass(&ID)
-, LabelIDList()
-, FrameMoves()
-, LandingPads()
-, Personalities()
+, ObjFileMMI(0)
, CallsEHReturn(0)
, CallsUnwindInit(0)
-, DbgInfoAvailable(false)
-{
- // Always emit "no personality" info
+, DbgInfoAvailable(false) {
+ // Always emit some info, by default "no personality" info.
Personalities.push_back(NULL);
}
-MachineModuleInfo::~MachineModuleInfo() {
+MachineModuleInfo::~MachineModuleInfo() {
+ delete ObjFileMMI;
}
/// doInitialization - Initialize the state for a new module.
return false;
}
-/// BeginFunction - Begin gathering function meta information.
-///
-void MachineModuleInfo::BeginFunction(MachineFunction *MF) {
- // Coming soon.
-}
-
/// EndFunction - Discard function meta information.
///
void MachineModuleInfo::EndFunction() {
// Clean up frame info.
FrameMoves.clear();
-
+
// Clean up exception info.
LandingPads.clear();
TypeInfos.clear();
FilterEnds.clear();
CallsEHReturn = 0;
CallsUnwindInit = 0;
+ VariableDbgInfo.clear();
}
/// AnalyzeModule - Scan the module for global debug information.
if (LP.LandingPadBlock == LandingPad)
return LP;
}
-
+
LandingPads.push_back(LandingPadInfo(LandingPad));
return LandingPads[N];
}
unsigned MachineModuleInfo::addLandingPad(MachineBasicBlock *LandingPad) {
unsigned LandingPadLabel = NextLabelID();
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
- LP.LandingPadLabel = LandingPadLabel;
+ LP.LandingPadLabel = LandingPadLabel;
return LandingPadLabel;
}
for (unsigned i = 0; i < Personalities.size(); ++i)
if (Personalities[i] == Personality)
return;
-
- Personalities.push_back(Personality);
+
+ // 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.
}
}
-/// getTypeIDFor - Return the type id for the specified typeinfo. This is
+/// getTypeIDFor - Return the type id for the specified typeinfo. This is
/// function wide.
unsigned MachineModuleInfo::getTypeIDFor(GlobalVariable *TI) {
for (unsigned i = 0, N = TypeInfos.size(); i != N; ++i)
}
/// getPersonalityIndex - Return unique index for current personality
-/// function. NULL personality function should always get zero index.
+/// function. NULL/first personality function should always get zero index.
unsigned MachineModuleInfo::getPersonalityIndex() const {
const Function* Personality = NULL;
-
+
// Scan landing pads. If there is at least one non-NULL personality - use it.
for (unsigned i = 0; i != LandingPads.size(); ++i)
if (LandingPads[i].Personality) {
Personality = LandingPads[i].Personality;
break;
}
-
+
for (unsigned i = 0; i < Personalities.size(); ++i) {
if (Personalities[i] == Personality)
return i;
}
- // This should never happen
- llvm_unreachable("Personality function should be set!");
+ // This will happen if the current personality function is
+ // in the zero index.
return 0;
}
-//===----------------------------------------------------------------------===//
-/// DebugLabelFolding pass - This pass prunes out redundant labels. This allows
-/// a info consumer to determine if the range of two labels is empty, by seeing
-/// if the labels map to the same reduced label.
-
-namespace llvm {
-
-struct DebugLabelFolder : public MachineFunctionPass {
- static char ID;
- DebugLabelFolder() : MachineFunctionPass(&ID) {}
-
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesCFG();
- AU.addPreservedID(MachineLoopInfoID);
- AU.addPreservedID(MachineDominatorsID);
- MachineFunctionPass::getAnalysisUsage(AU);
- }
-
- virtual bool runOnMachineFunction(MachineFunction &MF);
- virtual const char *getPassName() const { return "Label Folder"; }
-};
-
-char DebugLabelFolder::ID = 0;
-
-bool DebugLabelFolder::runOnMachineFunction(MachineFunction &MF) {
- // Get machine module info.
- MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
- if (!MMI) return false;
-
- // Track if change is made.
- bool MadeChange = false;
- // No prior label to begin.
- unsigned PriorLabel = 0;
-
- // Iterate through basic blocks.
- for (MachineFunction::iterator BB = MF.begin(), E = MF.end();
- BB != E; ++BB) {
- // Iterate through instructions.
- for (MachineBasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) {
- // Is it a label.
- if (I->isDebugLabel() && !MMI->isDbgLabelUsed(I->getOperand(0).getImm())){
- // The label ID # is always operand #0, an immediate.
- unsigned NextLabel = I->getOperand(0).getImm();
-
- // If there was an immediate prior label.
- if (PriorLabel) {
- // Remap the current label to prior label.
- MMI->RemapLabel(NextLabel, PriorLabel);
- // Delete the current label.
- I = BB->erase(I);
- // Indicate a change has been made.
- MadeChange = true;
- continue;
- } else {
- // Start a new round.
- PriorLabel = NextLabel;
- }
- } else {
- // No consecutive labels.
- PriorLabel = 0;
- }
-
- ++I;
- }
- }
-
- return MadeChange;
-}
-
-FunctionPass *createDebugLabelFoldingPass() { return new DebugLabelFolder(); }
-
-}
-