Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 1 | //===- Debugify.cpp - Attach synthetic debug info to everything -----------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// |
| 10 | /// \file This pass attaches synthetic debug info to everything. It can be used |
| 11 | /// to create targeted tests for debug info preservation. |
| 12 | /// |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Vedant Kumar | 775c7af | 2018-02-15 21:14:36 +0000 | [diff] [blame] | 15 | #include "PassPrinters.h" |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/BitVector.h" |
| 17 | #include "llvm/ADT/StringExtras.h" |
| 18 | #include "llvm/IR/BasicBlock.h" |
| 19 | #include "llvm/IR/Constants.h" |
| 20 | #include "llvm/IR/DIBuilder.h" |
| 21 | #include "llvm/IR/DebugInfo.h" |
| 22 | #include "llvm/IR/Function.h" |
| 23 | #include "llvm/IR/GlobalVariable.h" |
| 24 | #include "llvm/IR/InstIterator.h" |
| 25 | #include "llvm/IR/Instruction.h" |
| 26 | #include "llvm/IR/Instructions.h" |
| 27 | #include "llvm/IR/IntrinsicInst.h" |
| 28 | #include "llvm/IR/Module.h" |
| 29 | #include "llvm/IR/Type.h" |
| 30 | #include "llvm/Pass.h" |
| 31 | #include "llvm/Support/raw_ostream.h" |
| 32 | #include "llvm/Transforms/IPO.h" |
| 33 | |
| 34 | using namespace llvm; |
| 35 | |
| 36 | namespace { |
| 37 | |
Vedant Kumar | 17d8bba | 2018-02-15 21:28:38 +0000 | [diff] [blame] | 38 | bool isFunctionSkipped(Function &F) { |
| 39 | return F.isDeclaration() || !F.hasExactDefinition(); |
| 40 | } |
| 41 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 42 | bool applyDebugifyMetadata(Module &M, |
| 43 | iterator_range<Module::iterator> Functions, |
| 44 | StringRef Banner) { |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 45 | // Skip modules with debug info. |
| 46 | if (M.getNamedMetadata("llvm.dbg.cu")) { |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 47 | errs() << Banner << "Skipping module with debug info\n"; |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 48 | return false; |
| 49 | } |
| 50 | |
| 51 | DIBuilder DIB(M); |
| 52 | LLVMContext &Ctx = M.getContext(); |
| 53 | |
| 54 | // Get a DIType which corresponds to Ty. |
| 55 | DenseMap<uint64_t, DIType *> TypeCache; |
| 56 | auto getCachedDIType = [&](Type *Ty) -> DIType * { |
Vedant Kumar | 1f6f5f1 | 2018-01-06 00:37:01 +0000 | [diff] [blame] | 57 | uint64_t Size = |
| 58 | Ty->isSized() ? M.getDataLayout().getTypeAllocSizeInBits(Ty) : 0; |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 59 | DIType *&DTy = TypeCache[Size]; |
| 60 | if (!DTy) { |
| 61 | std::string Name = "ty" + utostr(Size); |
| 62 | DTy = DIB.createBasicType(Name, Size, dwarf::DW_ATE_unsigned); |
| 63 | } |
| 64 | return DTy; |
| 65 | }; |
| 66 | |
| 67 | unsigned NextLine = 1; |
| 68 | unsigned NextVar = 1; |
| 69 | auto File = DIB.createFile(M.getName(), "/"); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 70 | auto CU = DIB.createCompileUnit(dwarf::DW_LANG_C, File, |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 71 | "debugify", /*isOptimized=*/true, "", 0); |
| 72 | |
| 73 | // Visit each instruction. |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 74 | for (Function &F : Functions) { |
Vedant Kumar | 17d8bba | 2018-02-15 21:28:38 +0000 | [diff] [blame] | 75 | if (isFunctionSkipped(F)) |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 76 | continue; |
| 77 | |
| 78 | auto SPType = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None)); |
| 79 | bool IsLocalToUnit = F.hasPrivateLinkage() || F.hasInternalLinkage(); |
| 80 | auto SP = |
| 81 | DIB.createFunction(CU, F.getName(), F.getName(), File, NextLine, SPType, |
Vedant Kumar | 1627632 | 2018-02-13 18:15:27 +0000 | [diff] [blame] | 82 | IsLocalToUnit, /*isDefinition=*/true, NextLine, |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 83 | DINode::FlagZero, /*isOptimized=*/true); |
| 84 | F.setSubprogram(SP); |
| 85 | for (BasicBlock &BB : F) { |
| 86 | // Attach debug locations. |
| 87 | for (Instruction &I : BB) |
| 88 | I.setDebugLoc(DILocation::get(Ctx, NextLine++, 1, SP)); |
| 89 | |
| 90 | // Attach debug values. |
| 91 | for (Instruction &I : BB) { |
| 92 | // Skip void-valued instructions. |
| 93 | if (I.getType()->isVoidTy()) |
| 94 | continue; |
| 95 | |
| 96 | // Skip the terminator instruction and any just-inserted intrinsics. |
| 97 | if (isa<TerminatorInst>(&I) || isa<DbgValueInst>(&I)) |
| 98 | break; |
| 99 | |
| 100 | std::string Name = utostr(NextVar++); |
| 101 | const DILocation *Loc = I.getDebugLoc().get(); |
| 102 | auto LocalVar = DIB.createAutoVariable(SP, Name, File, Loc->getLine(), |
| 103 | getCachedDIType(I.getType()), |
| 104 | /*AlwaysPreserve=*/true); |
| 105 | DIB.insertDbgValueIntrinsic(&I, LocalVar, DIB.createExpression(), Loc, |
| 106 | BB.getTerminator()); |
| 107 | } |
| 108 | } |
| 109 | DIB.finalizeSubprogram(SP); |
| 110 | } |
| 111 | DIB.finalize(); |
| 112 | |
| 113 | // Track the number of distinct lines and variables. |
| 114 | NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.debugify"); |
| 115 | auto *IntTy = Type::getInt32Ty(Ctx); |
| 116 | auto addDebugifyOperand = [&](unsigned N) { |
| 117 | NMD->addOperand(MDNode::get( |
| 118 | Ctx, ValueAsMetadata::getConstant(ConstantInt::get(IntTy, N)))); |
| 119 | }; |
| 120 | addDebugifyOperand(NextLine - 1); // Original number of lines. |
| 121 | addDebugifyOperand(NextVar - 1); // Original number of variables. |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 122 | assert(NMD->getNumOperands() == 2 && |
| 123 | "llvm.debugify should have exactly 2 operands!"); |
Vedant Kumar | 4872535e | 2018-05-24 23:00:23 +0000 | [diff] [blame] | 124 | |
| 125 | // Claim that this synthetic debug info is valid. |
| 126 | StringRef DIVersionKey = "Debug Info Version"; |
| 127 | if (!M.getModuleFlag(DIVersionKey)) |
| 128 | M.addModuleFlag(Module::Warning, DIVersionKey, DEBUG_METADATA_VERSION); |
| 129 | |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 130 | return true; |
| 131 | } |
| 132 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 133 | bool checkDebugifyMetadata(Module &M, |
| 134 | iterator_range<Module::iterator> Functions, |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 135 | StringRef NameOfWrappedPass, |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 136 | StringRef Banner, |
| 137 | bool Strip) { |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 138 | // Skip modules without debugify metadata. |
| 139 | NamedMDNode *NMD = M.getNamedMetadata("llvm.debugify"); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 140 | if (!NMD) { |
| 141 | errs() << Banner << "Skipping module without debugify metadata\n"; |
| 142 | return false; |
| 143 | } |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 144 | |
| 145 | auto getDebugifyOperand = [&](unsigned Idx) -> unsigned { |
| 146 | return mdconst::extract<ConstantInt>(NMD->getOperand(Idx)->getOperand(0)) |
| 147 | ->getZExtValue(); |
| 148 | }; |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 149 | assert(NMD->getNumOperands() == 2 && |
| 150 | "llvm.debugify should have exactly 2 operands!"); |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 151 | unsigned OriginalNumLines = getDebugifyOperand(0); |
| 152 | unsigned OriginalNumVars = getDebugifyOperand(1); |
| 153 | bool HasErrors = false; |
| 154 | |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 155 | BitVector MissingLines{OriginalNumLines, true}; |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 156 | BitVector MissingVars{OriginalNumVars, true}; |
| 157 | for (Function &F : Functions) { |
Vedant Kumar | 17d8bba | 2018-02-15 21:28:38 +0000 | [diff] [blame] | 158 | if (isFunctionSkipped(F)) |
| 159 | continue; |
| 160 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 161 | // Find missing lines. |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 162 | for (Instruction &I : instructions(F)) { |
| 163 | if (isa<DbgValueInst>(&I)) |
| 164 | continue; |
| 165 | |
| 166 | auto DL = I.getDebugLoc(); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 167 | if (DL && DL.getLine() != 0) { |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 168 | MissingLines.reset(DL.getLine() - 1); |
| 169 | continue; |
| 170 | } |
| 171 | |
Anastasis Grammenos | d6c6678 | 2018-05-17 18:19:58 +0000 | [diff] [blame] | 172 | errs() << "ERROR: Instruction with empty DebugLoc in function "; |
| 173 | errs() << F.getName() << " --"; |
| 174 | I.print(errs()); |
| 175 | errs() << "\n"; |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 176 | HasErrors = true; |
| 177 | } |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 178 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 179 | // Find missing variables. |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 180 | for (Instruction &I : instructions(F)) { |
| 181 | auto *DVI = dyn_cast<DbgValueInst>(&I); |
| 182 | if (!DVI) |
| 183 | continue; |
| 184 | |
| 185 | unsigned Var = ~0U; |
| 186 | (void)to_integer(DVI->getVariable()->getName(), Var, 10); |
| 187 | assert(Var <= OriginalNumVars && "Unexpected name for DILocalVariable"); |
| 188 | MissingVars.reset(Var - 1); |
| 189 | } |
| 190 | } |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 191 | |
| 192 | // Print the results. |
| 193 | for (unsigned Idx : MissingLines.set_bits()) |
Anastasis Grammenos | d6c6678 | 2018-05-17 18:19:58 +0000 | [diff] [blame] | 194 | errs() << "WARNING: Missing line " << Idx + 1 << "\n"; |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 195 | |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 196 | for (unsigned Idx : MissingVars.set_bits()) |
Anastasis Grammenos | d6c6678 | 2018-05-17 18:19:58 +0000 | [diff] [blame] | 197 | errs() << "ERROR: Missing variable " << Idx + 1 << "\n"; |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 198 | HasErrors |= MissingVars.count() > 0; |
| 199 | |
Vedant Kumar | b70e356 | 2018-05-24 23:00:22 +0000 | [diff] [blame] | 200 | errs() << Banner; |
| 201 | if (!NameOfWrappedPass.empty()) |
| 202 | errs() << " [" << NameOfWrappedPass << "]"; |
| 203 | errs() << ": " << (HasErrors ? "FAIL" : "PASS") << '\n'; |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 204 | if (HasErrors) { |
Anastasis Grammenos | d6c6678 | 2018-05-17 18:19:58 +0000 | [diff] [blame] | 205 | errs() << "Module IR Dump\n"; |
| 206 | M.print(errs(), nullptr, false); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | // Strip the Debugify Metadata if required. |
| 210 | if (Strip) { |
| 211 | StripDebugInfo(M); |
| 212 | M.eraseNamedMetadata(NMD); |
| 213 | return true; |
| 214 | } |
| 215 | |
| 216 | return false; |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 217 | } |
| 218 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 219 | /// ModulePass for attaching synthetic debug info to everything, used with the |
| 220 | /// legacy module pass manager. |
| 221 | struct DebugifyModulePass : public ModulePass { |
| 222 | bool runOnModule(Module &M) override { |
| 223 | return applyDebugifyMetadata(M, M.functions(), "ModuleDebugify: "); |
| 224 | } |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 225 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 226 | DebugifyModulePass() : ModulePass(ID) {} |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 227 | |
| 228 | void getAnalysisUsage(AnalysisUsage &AU) const override { |
| 229 | AU.setPreservesAll(); |
| 230 | } |
| 231 | |
| 232 | static char ID; // Pass identification. |
| 233 | }; |
| 234 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 235 | /// FunctionPass for attaching synthetic debug info to instructions within a |
| 236 | /// single function, used with the legacy module pass manager. |
| 237 | struct DebugifyFunctionPass : public FunctionPass { |
| 238 | bool runOnFunction(Function &F) override { |
| 239 | Module &M = *F.getParent(); |
| 240 | auto FuncIt = F.getIterator(); |
| 241 | return applyDebugifyMetadata(M, make_range(FuncIt, std::next(FuncIt)), |
| 242 | "FunctionDebugify: "); |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 243 | } |
| 244 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 245 | DebugifyFunctionPass() : FunctionPass(ID) {} |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 246 | |
| 247 | void getAnalysisUsage(AnalysisUsage &AU) const override { |
| 248 | AU.setPreservesAll(); |
| 249 | } |
| 250 | |
| 251 | static char ID; // Pass identification. |
| 252 | }; |
| 253 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 254 | /// ModulePass for checking debug info inserted by -debugify, used with the |
| 255 | /// legacy module pass manager. |
| 256 | struct CheckDebugifyModulePass : public ModulePass { |
| 257 | bool runOnModule(Module &M) override { |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 258 | return checkDebugifyMetadata(M, M.functions(), NameOfWrappedPass, |
| 259 | "CheckModuleDebugify", Strip); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 260 | } |
| 261 | |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 262 | CheckDebugifyModulePass(bool Strip = false, StringRef NameOfWrappedPass = "") |
| 263 | : ModulePass(ID), Strip(Strip), NameOfWrappedPass(NameOfWrappedPass) {} |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 264 | |
| 265 | static char ID; // Pass identification. |
| 266 | |
| 267 | private: |
| 268 | bool Strip; |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 269 | StringRef NameOfWrappedPass; |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 270 | }; |
| 271 | |
| 272 | /// FunctionPass for checking debug info inserted by -debugify-function, used |
| 273 | /// with the legacy module pass manager. |
| 274 | struct CheckDebugifyFunctionPass : public FunctionPass { |
| 275 | bool runOnFunction(Function &F) override { |
| 276 | Module &M = *F.getParent(); |
| 277 | auto FuncIt = F.getIterator(); |
| 278 | return checkDebugifyMetadata(M, make_range(FuncIt, std::next(FuncIt)), |
Vedant Kumar | 4872535e | 2018-05-24 23:00:23 +0000 | [diff] [blame] | 279 | NameOfWrappedPass, "CheckFunctionDebugify", |
| 280 | Strip); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Vedant Kumar | 4872535e | 2018-05-24 23:00:23 +0000 | [diff] [blame] | 283 | CheckDebugifyFunctionPass(bool Strip = false, |
| 284 | StringRef NameOfWrappedPass = "") |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 285 | : FunctionPass(ID), Strip(Strip), NameOfWrappedPass(NameOfWrappedPass) {} |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 286 | |
| 287 | void getAnalysisUsage(AnalysisUsage &AU) const override { |
| 288 | AU.setPreservesAll(); |
| 289 | } |
| 290 | |
| 291 | static char ID; // Pass identification. |
| 292 | |
| 293 | private: |
| 294 | bool Strip; |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 295 | StringRef NameOfWrappedPass; |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 296 | }; |
| 297 | |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 298 | } // end anonymous namespace |
| 299 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 300 | ModulePass *createDebugifyModulePass() { |
| 301 | return new DebugifyModulePass(); |
| 302 | } |
| 303 | |
| 304 | FunctionPass *createDebugifyFunctionPass() { |
| 305 | return new DebugifyFunctionPass(); |
| 306 | } |
Vedant Kumar | 92f7a62 | 2018-01-23 20:43:50 +0000 | [diff] [blame] | 307 | |
Vedant Kumar | 775c7af | 2018-02-15 21:14:36 +0000 | [diff] [blame] | 308 | PreservedAnalyses NewPMDebugifyPass::run(Module &M, ModuleAnalysisManager &) { |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 309 | applyDebugifyMetadata(M, M.functions(), "ModuleDebugify: "); |
Vedant Kumar | 775c7af | 2018-02-15 21:14:36 +0000 | [diff] [blame] | 310 | return PreservedAnalyses::all(); |
| 311 | } |
| 312 | |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 313 | ModulePass *createCheckDebugifyModulePass(bool Strip, StringRef NameOfWrappedPass) { |
| 314 | return new CheckDebugifyModulePass(Strip, NameOfWrappedPass); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 315 | } |
| 316 | |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 317 | FunctionPass *createCheckDebugifyFunctionPass(bool Strip, StringRef NameOfWrappedPass) { |
| 318 | return new CheckDebugifyFunctionPass(Strip, NameOfWrappedPass); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 319 | } |
Vedant Kumar | 92f7a62 | 2018-01-23 20:43:50 +0000 | [diff] [blame] | 320 | |
Vedant Kumar | 775c7af | 2018-02-15 21:14:36 +0000 | [diff] [blame] | 321 | PreservedAnalyses NewPMCheckDebugifyPass::run(Module &M, |
| 322 | ModuleAnalysisManager &) { |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 323 | checkDebugifyMetadata(M, M.functions(), "", "CheckModuleDebugify", false); |
Vedant Kumar | 775c7af | 2018-02-15 21:14:36 +0000 | [diff] [blame] | 324 | return PreservedAnalyses::all(); |
| 325 | } |
| 326 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 327 | char DebugifyModulePass::ID = 0; |
| 328 | static RegisterPass<DebugifyModulePass> DM("debugify", |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 329 | "Attach debug info to everything"); |
| 330 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 331 | char CheckDebugifyModulePass::ID = 0; |
| 332 | static RegisterPass<CheckDebugifyModulePass> CDM("check-debugify", |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 333 | "Check debug info from -debugify"); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 334 | |
| 335 | char DebugifyFunctionPass::ID = 0; |
| 336 | static RegisterPass<DebugifyFunctionPass> DF("debugify-function", |
| 337 | "Attach debug info to a function"); |
| 338 | |
| 339 | char CheckDebugifyFunctionPass::ID = 0; |
| 340 | static RegisterPass<CheckDebugifyFunctionPass> CDF("check-debugify-function", |
| 341 | "Check debug info from -debugify-function"); |