[Debugify] Set a DI version module flag for llc compatibility

Setting the "Debug Info Version" module flag makes it possible to pipe
synthetic debug info into llc, which is useful for testing backends.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333237 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Vedant Kumar
2018-05-24 23:00:23 +00:00
parent 951e605c7b
commit 646a736e7b
5 changed files with 34 additions and 31 deletions
+10 -2
View File
@@ -121,6 +121,12 @@ bool applyDebugifyMetadata(Module &M,
addDebugifyOperand(NextVar - 1); // Original number of variables.
assert(NMD->getNumOperands() == 2 &&
"llvm.debugify should have exactly 2 operands!");
// Claim that this synthetic debug info is valid.
StringRef DIVersionKey = "Debug Info Version";
if (!M.getModuleFlag(DIVersionKey))
M.addModuleFlag(Module::Warning, DIVersionKey, DEBUG_METADATA_VERSION);
return true;
}
@@ -270,10 +276,12 @@ struct CheckDebugifyFunctionPass : public FunctionPass {
Module &M = *F.getParent();
auto FuncIt = F.getIterator();
return checkDebugifyMetadata(M, make_range(FuncIt, std::next(FuncIt)),
NameOfWrappedPass, "CheckFunctionDebugify", Strip);
NameOfWrappedPass, "CheckFunctionDebugify",
Strip);
}
CheckDebugifyFunctionPass(bool Strip = false, StringRef NameOfWrappedPass = "")
CheckDebugifyFunctionPass(bool Strip = false,
StringRef NameOfWrappedPass = "")
: FunctionPass(ID), Strip(Strip), NameOfWrappedPass(NameOfWrappedPass) {}
void getAnalysisUsage(AnalysisUsage &AU) const override {