From 48ae02fe62cafd44c740e67cfae6e7277e61a973 Mon Sep 17 00:00:00 2001 From: Dale Johannesen Date: Wed, 16 Jan 2008 19:59:28 +0000 Subject: Do not mark EH tables no-dead-strip unless the associated function is so marked. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46088 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineModuleInfo.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/CodeGen/MachineModuleInfo.cpp') diff --git a/lib/CodeGen/MachineModuleInfo.cpp b/lib/CodeGen/MachineModuleInfo.cpp index f8796acaef..5e6d4cb496 100644 --- a/lib/CodeGen/MachineModuleInfo.cpp +++ b/lib/CodeGen/MachineModuleInfo.cpp @@ -1552,6 +1552,21 @@ bool MachineModuleInfo::Verify(Value *V) { /// void MachineModuleInfo::AnalyzeModule(Module &M) { SetupCompileUnits(M); + + // Insert functions in the llvm.used array into UsedFunctions. + GlobalVariable *GV = M.getGlobalVariable("llvm.used"); + if (!GV || !GV->hasInitializer()) return; + + // Should be an array of 'i8*'. + ConstantArray *InitList = dyn_cast(GV->getInitializer()); + if (InitList == 0) return; + + for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) { + if (ConstantExpr *CE = dyn_cast(InitList->getOperand(i))) + if (CE->getOpcode() == Instruction::BitCast) + if (Function *F = dyn_cast(CE->getOperand(0))) + UsedFunctions.insert(F); + } } /// needsFrameInfo - Returns true if we need to gather callee-saved register -- cgit v1.2.3-18-g5258