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