[PATCH] D113352: [clang] Run LLVM Verifier in modes without CodeGen too
Itay Bookstein via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 6 15:35:08 PDT 2021
ibookstein updated this revision to Diff 385298.
ibookstein added a comment.
clang-format
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113352/new/
https://reviews.llvm.org/D113352
Files:
clang/lib/CodeGen/BackendUtil.cpp
Index: clang/lib/CodeGen/BackendUtil.cpp
===================================================================
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -487,6 +487,11 @@
}
}
+static bool actionRequiresCodeGen(BackendAction Action) {
+ return Action != Backend_EmitNothing && Action != Backend_EmitBC &&
+ Action != Backend_EmitLL;
+}
+
static bool initTargetOptions(DiagnosticsEngine &Diags,
llvm::TargetOptions &Options,
const CodeGenOptions &CodeGenOpts,
@@ -977,9 +982,7 @@
setCommandLineOpts(CodeGenOpts);
- bool UsesCodeGen = (Action != Backend_EmitNothing &&
- Action != Backend_EmitBC &&
- Action != Backend_EmitLL);
+ bool UsesCodeGen = actionRequiresCodeGen(Action);
CreateTargetMachine(UsesCodeGen);
if (UsesCodeGen && !TM)
@@ -1006,6 +1009,10 @@
CreatePasses(PerModulePasses, PerFunctionPasses);
+ if (!UsesCodeGen && CodeGenOpts.VerifyModule)
+ // Add it here so that it runs prior to the BC/LL emission pass
+ PerModulePasses.add(createVerifierPass());
+
legacy::PassManager CodeGenPasses;
CodeGenPasses.add(
createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
@@ -1425,6 +1432,11 @@
MPM.addPass(ModuleMemProfilerPass());
}
}
+
+ if (!actionRequiresCodeGen(Action) && CodeGenOpts.VerifyModule)
+ // Add it here so that it runs prior to the BC/LL emission pass
+ MPM.addPass(VerifierPass());
+
switch (Action) {
case Backend_EmitBC:
if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
@@ -1514,8 +1526,7 @@
TimeRegion Region(CodeGenOpts.TimePasses ? &CodeGenerationTime : nullptr);
setCommandLineOpts(CodeGenOpts);
- bool RequiresCodeGen = (Action != Backend_EmitNothing &&
- Action != Backend_EmitBC && Action != Backend_EmitLL);
+ bool RequiresCodeGen = actionRequiresCodeGen(Action);
CreateTargetMachine(RequiresCodeGen);
if (RequiresCodeGen && !TM)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113352.385298.patch
Type: text/x-patch
Size: 2070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211106/8e4b88c7/attachment.bin>
More information about the cfe-commits
mailing list