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 | |
Vedant Kumar | 77f4d4d | 2018-06-03 22:50:22 +0000 | [diff] [blame^] | 90 | // Inserting debug values into EH pads can break IR invariants. |
| 91 | if (BB.isEHPad()) |
| 92 | continue; |
| 93 | |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 94 | // Attach debug values. |
| 95 | for (Instruction &I : BB) { |
| 96 | // Skip void-valued instructions. |
| 97 | if (I.getType()->isVoidTy()) |
| 98 | continue; |
| 99 | |
| 100 | // Skip the terminator instruction and any just-inserted intrinsics. |
| 101 | if (isa<TerminatorInst>(&I) || isa<DbgValueInst>(&I)) |
| 102 | break; |
| 103 | |
Vedant Kumar | 77f4d4d | 2018-06-03 22:50:22 +0000 | [diff] [blame^] | 104 | // Don't insert instructions after a musttail call. |
| 105 | if (auto *Call = dyn_cast<CallInst>(&I)) |
| 106 | if (Call->isMustTailCall()) |
| 107 | break; |
| 108 | |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 109 | std::string Name = utostr(NextVar++); |
| 110 | const DILocation *Loc = I.getDebugLoc().get(); |
| 111 | auto LocalVar = DIB.createAutoVariable(SP, Name, File, Loc->getLine(), |
| 112 | getCachedDIType(I.getType()), |
| 113 | /*AlwaysPreserve=*/true); |
| 114 | DIB.insertDbgValueIntrinsic(&I, LocalVar, DIB.createExpression(), Loc, |
| 115 | BB.getTerminator()); |
| 116 | } |
| 117 | } |
| 118 | DIB.finalizeSubprogram(SP); |
| 119 | } |
| 120 | DIB.finalize(); |
| 121 | |
| 122 | // Track the number of distinct lines and variables. |
| 123 | NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.debugify"); |
| 124 | auto *IntTy = Type::getInt32Ty(Ctx); |
| 125 | auto addDebugifyOperand = [&](unsigned N) { |
| 126 | NMD->addOperand(MDNode::get( |
| 127 | Ctx, ValueAsMetadata::getConstant(ConstantInt::get(IntTy, N)))); |
| 128 | }; |
| 129 | addDebugifyOperand(NextLine - 1); // Original number of lines. |
| 130 | addDebugifyOperand(NextVar - 1); // Original number of variables. |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 131 | assert(NMD->getNumOperands() == 2 && |
| 132 | "llvm.debugify should have exactly 2 operands!"); |
Vedant Kumar | 4872535e | 2018-05-24 23:00:23 +0000 | [diff] [blame] | 133 | |
| 134 | // Claim that this synthetic debug info is valid. |
| 135 | StringRef DIVersionKey = "Debug Info Version"; |
| 136 | if (!M.getModuleFlag(DIVersionKey)) |
| 137 | M.addModuleFlag(Module::Warning, DIVersionKey, DEBUG_METADATA_VERSION); |
| 138 | |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 139 | return true; |
| 140 | } |
| 141 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 142 | bool checkDebugifyMetadata(Module &M, |
| 143 | iterator_range<Module::iterator> Functions, |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 144 | StringRef NameOfWrappedPass, |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 145 | StringRef Banner, |
| 146 | bool Strip) { |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 147 | // Skip modules without debugify metadata. |
| 148 | NamedMDNode *NMD = M.getNamedMetadata("llvm.debugify"); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 149 | if (!NMD) { |
| 150 | errs() << Banner << "Skipping module without debugify metadata\n"; |
| 151 | return false; |
| 152 | } |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 153 | |
| 154 | auto getDebugifyOperand = [&](unsigned Idx) -> unsigned { |
| 155 | return mdconst::extract<ConstantInt>(NMD->getOperand(Idx)->getOperand(0)) |
| 156 | ->getZExtValue(); |
| 157 | }; |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 158 | assert(NMD->getNumOperands() == 2 && |
| 159 | "llvm.debugify should have exactly 2 operands!"); |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 160 | unsigned OriginalNumLines = getDebugifyOperand(0); |
| 161 | unsigned OriginalNumVars = getDebugifyOperand(1); |
| 162 | bool HasErrors = false; |
| 163 | |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 164 | BitVector MissingLines{OriginalNumLines, true}; |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 165 | BitVector MissingVars{OriginalNumVars, true}; |
| 166 | for (Function &F : Functions) { |
Vedant Kumar | 17d8bba | 2018-02-15 21:28:38 +0000 | [diff] [blame] | 167 | if (isFunctionSkipped(F)) |
| 168 | continue; |
| 169 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 170 | // Find missing lines. |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 171 | for (Instruction &I : instructions(F)) { |
| 172 | if (isa<DbgValueInst>(&I)) |
| 173 | continue; |
| 174 | |
| 175 | auto DL = I.getDebugLoc(); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 176 | if (DL && DL.getLine() != 0) { |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 177 | MissingLines.reset(DL.getLine() - 1); |
| 178 | continue; |
| 179 | } |
| 180 | |
Anastasis Grammenos | d6c6678 | 2018-05-17 18:19:58 +0000 | [diff] [blame] | 181 | errs() << "ERROR: Instruction with empty DebugLoc in function "; |
| 182 | errs() << F.getName() << " --"; |
| 183 | I.print(errs()); |
| 184 | errs() << "\n"; |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 185 | HasErrors = true; |
| 186 | } |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 187 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 188 | // Find missing variables. |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 189 | for (Instruction &I : instructions(F)) { |
| 190 | auto *DVI = dyn_cast<DbgValueInst>(&I); |
| 191 | if (!DVI) |
| 192 | continue; |
| 193 | |
| 194 | unsigned Var = ~0U; |
| 195 | (void)to_integer(DVI->getVariable()->getName(), Var, 10); |
| 196 | assert(Var <= OriginalNumVars && "Unexpected name for DILocalVariable"); |
| 197 | MissingVars.reset(Var - 1); |
| 198 | } |
| 199 | } |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 200 | |
| 201 | // Print the results. |
| 202 | for (unsigned Idx : MissingLines.set_bits()) |
Anastasis Grammenos | d6c6678 | 2018-05-17 18:19:58 +0000 | [diff] [blame] | 203 | errs() << "WARNING: Missing line " << Idx + 1 << "\n"; |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 204 | |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 205 | for (unsigned Idx : MissingVars.set_bits()) |
Anastasis Grammenos | d6c6678 | 2018-05-17 18:19:58 +0000 | [diff] [blame] | 206 | errs() << "ERROR: Missing variable " << Idx + 1 << "\n"; |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 207 | HasErrors |= MissingVars.count() > 0; |
| 208 | |
Vedant Kumar | b70e356 | 2018-05-24 23:00:22 +0000 | [diff] [blame] | 209 | errs() << Banner; |
| 210 | if (!NameOfWrappedPass.empty()) |
| 211 | errs() << " [" << NameOfWrappedPass << "]"; |
| 212 | errs() << ": " << (HasErrors ? "FAIL" : "PASS") << '\n'; |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 213 | if (HasErrors) { |
Anastasis Grammenos | d6c6678 | 2018-05-17 18:19:58 +0000 | [diff] [blame] | 214 | errs() << "Module IR Dump\n"; |
| 215 | M.print(errs(), nullptr, false); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | // Strip the Debugify Metadata if required. |
| 219 | if (Strip) { |
| 220 | StripDebugInfo(M); |
| 221 | M.eraseNamedMetadata(NMD); |
| 222 | return true; |
| 223 | } |
| 224 | |
| 225 | return false; |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 226 | } |
| 227 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 228 | /// ModulePass for attaching synthetic debug info to everything, used with the |
| 229 | /// legacy module pass manager. |
| 230 | struct DebugifyModulePass : public ModulePass { |
| 231 | bool runOnModule(Module &M) override { |
| 232 | return applyDebugifyMetadata(M, M.functions(), "ModuleDebugify: "); |
| 233 | } |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 234 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 235 | DebugifyModulePass() : ModulePass(ID) {} |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 236 | |
| 237 | void getAnalysisUsage(AnalysisUsage &AU) const override { |
| 238 | AU.setPreservesAll(); |
| 239 | } |
| 240 | |
| 241 | static char ID; // Pass identification. |
| 242 | }; |
| 243 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 244 | /// FunctionPass for attaching synthetic debug info to instructions within a |
| 245 | /// single function, used with the legacy module pass manager. |
| 246 | struct DebugifyFunctionPass : public FunctionPass { |
| 247 | bool runOnFunction(Function &F) override { |
| 248 | Module &M = *F.getParent(); |
| 249 | auto FuncIt = F.getIterator(); |
| 250 | return applyDebugifyMetadata(M, make_range(FuncIt, std::next(FuncIt)), |
| 251 | "FunctionDebugify: "); |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 252 | } |
| 253 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 254 | DebugifyFunctionPass() : FunctionPass(ID) {} |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 255 | |
| 256 | void getAnalysisUsage(AnalysisUsage &AU) const override { |
| 257 | AU.setPreservesAll(); |
| 258 | } |
| 259 | |
| 260 | static char ID; // Pass identification. |
| 261 | }; |
| 262 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 263 | /// ModulePass for checking debug info inserted by -debugify, used with the |
| 264 | /// legacy module pass manager. |
| 265 | struct CheckDebugifyModulePass : public ModulePass { |
| 266 | bool runOnModule(Module &M) override { |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 267 | return checkDebugifyMetadata(M, M.functions(), NameOfWrappedPass, |
| 268 | "CheckModuleDebugify", Strip); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 269 | } |
| 270 | |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 271 | CheckDebugifyModulePass(bool Strip = false, StringRef NameOfWrappedPass = "") |
| 272 | : ModulePass(ID), Strip(Strip), NameOfWrappedPass(NameOfWrappedPass) {} |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 273 | |
| 274 | static char ID; // Pass identification. |
| 275 | |
| 276 | private: |
| 277 | bool Strip; |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 278 | StringRef NameOfWrappedPass; |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 279 | }; |
| 280 | |
| 281 | /// FunctionPass for checking debug info inserted by -debugify-function, used |
| 282 | /// with the legacy module pass manager. |
| 283 | struct CheckDebugifyFunctionPass : public FunctionPass { |
| 284 | bool runOnFunction(Function &F) override { |
| 285 | Module &M = *F.getParent(); |
| 286 | auto FuncIt = F.getIterator(); |
| 287 | return checkDebugifyMetadata(M, make_range(FuncIt, std::next(FuncIt)), |
Vedant Kumar | 4872535e | 2018-05-24 23:00:23 +0000 | [diff] [blame] | 288 | NameOfWrappedPass, "CheckFunctionDebugify", |
| 289 | Strip); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 290 | } |
| 291 | |
Vedant Kumar | 4872535e | 2018-05-24 23:00:23 +0000 | [diff] [blame] | 292 | CheckDebugifyFunctionPass(bool Strip = false, |
| 293 | StringRef NameOfWrappedPass = "") |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 294 | : FunctionPass(ID), Strip(Strip), NameOfWrappedPass(NameOfWrappedPass) {} |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 295 | |
| 296 | void getAnalysisUsage(AnalysisUsage &AU) const override { |
| 297 | AU.setPreservesAll(); |
| 298 | } |
| 299 | |
| 300 | static char ID; // Pass identification. |
| 301 | |
| 302 | private: |
| 303 | bool Strip; |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 304 | StringRef NameOfWrappedPass; |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 305 | }; |
| 306 | |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 307 | } // end anonymous namespace |
| 308 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 309 | ModulePass *createDebugifyModulePass() { |
| 310 | return new DebugifyModulePass(); |
| 311 | } |
| 312 | |
| 313 | FunctionPass *createDebugifyFunctionPass() { |
| 314 | return new DebugifyFunctionPass(); |
| 315 | } |
Vedant Kumar | 92f7a62 | 2018-01-23 20:43:50 +0000 | [diff] [blame] | 316 | |
Vedant Kumar | 775c7af | 2018-02-15 21:14:36 +0000 | [diff] [blame] | 317 | PreservedAnalyses NewPMDebugifyPass::run(Module &M, ModuleAnalysisManager &) { |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 318 | applyDebugifyMetadata(M, M.functions(), "ModuleDebugify: "); |
Vedant Kumar | 775c7af | 2018-02-15 21:14:36 +0000 | [diff] [blame] | 319 | return PreservedAnalyses::all(); |
| 320 | } |
| 321 | |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 322 | ModulePass *createCheckDebugifyModulePass(bool Strip, StringRef NameOfWrappedPass) { |
| 323 | return new CheckDebugifyModulePass(Strip, NameOfWrappedPass); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 324 | } |
| 325 | |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 326 | FunctionPass *createCheckDebugifyFunctionPass(bool Strip, StringRef NameOfWrappedPass) { |
| 327 | return new CheckDebugifyFunctionPass(Strip, NameOfWrappedPass); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 328 | } |
Vedant Kumar | 92f7a62 | 2018-01-23 20:43:50 +0000 | [diff] [blame] | 329 | |
Vedant Kumar | 775c7af | 2018-02-15 21:14:36 +0000 | [diff] [blame] | 330 | PreservedAnalyses NewPMCheckDebugifyPass::run(Module &M, |
| 331 | ModuleAnalysisManager &) { |
Anastasis Grammenos | b4344c6 | 2018-05-15 23:38:05 +0000 | [diff] [blame] | 332 | checkDebugifyMetadata(M, M.functions(), "", "CheckModuleDebugify", false); |
Vedant Kumar | 775c7af | 2018-02-15 21:14:36 +0000 | [diff] [blame] | 333 | return PreservedAnalyses::all(); |
| 334 | } |
| 335 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 336 | char DebugifyModulePass::ID = 0; |
| 337 | static RegisterPass<DebugifyModulePass> DM("debugify", |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 338 | "Attach debug info to everything"); |
| 339 | |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 340 | char CheckDebugifyModulePass::ID = 0; |
| 341 | static RegisterPass<CheckDebugifyModulePass> CDM("check-debugify", |
Vedant Kumar | 195dfd1 | 2017-12-08 21:57:28 +0000 | [diff] [blame] | 342 | "Check debug info from -debugify"); |
Vedant Kumar | 595ba1d | 2018-05-15 00:29:27 +0000 | [diff] [blame] | 343 | |
| 344 | char DebugifyFunctionPass::ID = 0; |
| 345 | static RegisterPass<DebugifyFunctionPass> DF("debugify-function", |
| 346 | "Attach debug info to a function"); |
| 347 | |
| 348 | char CheckDebugifyFunctionPass::ID = 0; |
| 349 | static RegisterPass<CheckDebugifyFunctionPass> CDF("check-debugify-function", |
| 350 | "Check debug info from -debugify-function"); |