#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/Support/Dwarf.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Streams.h"
using namespace llvm;
using namespace llvm::dwarf;
MachineModuleInfo::MachineModuleInfo()
: ImmutablePass(&ID)
-, Lines()
, LabelIDList()
, FrameMoves()
, LandingPads()
/// AnalyzeModule - Scan the module for global debug information.
///
void MachineModuleInfo::AnalyzeModule(Module &M) {
- // Insert functions in the llvm.used array into UsedFunctions.
+ // Insert functions in the llvm.used array (but not llvm.compiler.used) into
+ // UsedFunctions.
GlobalVariable *GV = M.getGlobalVariable("llvm.used");
if (!GV || !GV->hasInitializer()) return;
ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer());
if (InitList == 0) return;
- for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
- if (ConstantExpr *CE = dyn_cast<ConstantExpr>(InitList->getOperand(i)))
- if (CE->getOpcode() == Instruction::BitCast)
- if (Function *F = dyn_cast<Function>(CE->getOperand(0)))
- UsedFunctions.insert(F);
- }
+ for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i)
+ if (Function *F =
+ dyn_cast<Function>(InitList->getOperand(i)->stripPointerCasts()))
+ UsedFunctions.insert(F);
}
//===-EH-------------------------------------------------------------------===//
}
// This should never happen
- assert(0 && "Personality function should be set!");
+ llvm_unreachable("Personality function should be set!");
return 0;
}
bool DebugLabelFolder::runOnMachineFunction(MachineFunction &MF) {
// Get machine module info.
- MachineModuleInfo *MMI = getAnalysisToUpdate<MachineModuleInfo>();
+ MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
if (!MMI) return false;
// Track if change is made.
// Iterate through instructions.
for (MachineBasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) {
// Is it a label.
- if (I->isDebugLabel()) {
+ if (I->isDebugLabel() && !MMI->isDbgLabelUsed(I->getOperand(0).getImm())){
// The label ID # is always operand #0, an immediate.
unsigned NextLabel = I->getOperand(0).getImm();