mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-27 15:41:46 +00:00
[clang][LTO] Add flag to run verifier after every pass
Helps with debugging issues caught by the verifier. Plumbed through both normal clang compile and ThinLTO. Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D153468
This commit is contained in:
parent
3ea8f25265
commit
da7f212f4a
@ -322,6 +322,8 @@ CODEGENOPT(UseRegisterSizedBitfieldAccess , 1, 0)
|
||||
|
||||
CODEGENOPT(VerifyModule , 1, 1) ///< Control whether the module should be run
|
||||
///< through the LLVM Verifier.
|
||||
CODEGENOPT(VerifyEach , 1, 1) ///< Control whether the LLVM verifier
|
||||
///< should run after every pass.
|
||||
|
||||
CODEGENOPT(StackRealignment , 1, 0) ///< Control whether to force stack
|
||||
///< realignment.
|
||||
|
@ -5738,6 +5738,9 @@ def as_secure_log_file : Separate<["-"], "as-secure-log-file">,
|
||||
|
||||
let Flags = [CC1Option, NoDriverOption] in {
|
||||
|
||||
def llvm_verify_each : Flag<["-"], "llvm-verify-each">,
|
||||
HelpText<"Run the LLVM verifier after every LLVM pass">,
|
||||
MarshallingInfoFlag<CodeGenOpts<"VerifyEach">>;
|
||||
def disable_llvm_verifier : Flag<["-"], "disable-llvm-verifier">,
|
||||
HelpText<"Don't run the LLVM IR verifier pass">,
|
||||
MarshallingInfoNegativeFlag<CodeGenOpts<"VerifyModule">>;
|
||||
|
@ -839,7 +839,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
|
||||
StandardInstrumentations SI(
|
||||
TheModule->getContext(),
|
||||
(CodeGenOpts.DebugPassManager || DebugPassStructure),
|
||||
/*VerifyEach*/ false, PrintPassOpts);
|
||||
CodeGenOpts.VerifyEach, PrintPassOpts);
|
||||
SI.registerCallbacks(PIC, &MAM);
|
||||
PassBuilder PB(TM.get(), PTO, PGOOpt, &PIC);
|
||||
|
||||
@ -1192,6 +1192,7 @@ static void runThinLTOBackend(
|
||||
|
||||
Conf.ProfileRemapping = std::move(ProfileRemapping);
|
||||
Conf.DebugPassManager = CGOpts.DebugPassManager;
|
||||
Conf.VerifyEach = CGOpts.VerifyEach;
|
||||
Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness;
|
||||
Conf.RemarksFilename = CGOpts.OptRecordFile;
|
||||
Conf.RemarksPasses = CGOpts.OptRecordPasses;
|
||||
|
19
clang/test/CodeGen/verify-each.c
Normal file
19
clang/test/CodeGen/verify-each.c
Normal file
@ -0,0 +1,19 @@
|
||||
// Test to ensure -llvm-verify-each works.
|
||||
// REQUIRES: x86-registered-target
|
||||
|
||||
// RUN: %clang_cc1 -O2 -o /dev/null -triple x86_64-unknown-linux-gnu -emit-llvm-bc %s -fdebug-pass-manager 2>&1 | FileCheck %s --check-prefix=NO
|
||||
// NO-NOT: Verifying
|
||||
|
||||
// RUN: %clang_cc1 -O2 -o /dev/null -triple x86_64-unknown-linux-gnu -emit-llvm-bc %s -fdebug-pass-manager -llvm-verify-each 2>&1 | FileCheck %s
|
||||
|
||||
// RUN: %clang_cc1 -O2 -o %t.o -flto=thin -triple x86_64-unknown-linux-gnu -emit-llvm-bc %s -fdebug-pass-manager -llvm-verify-each 2>&1 | FileCheck %s
|
||||
// RUN: llvm-lto -thinlto -o %t %t.o
|
||||
|
||||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O2 -o /dev/null -x ir %t.o -fthinlto-index=%t.thinlto.bc -fdebug-pass-manager -llvm-verify-each 2>&1 | FileCheck %s
|
||||
|
||||
// CHECK: Verifying function foo
|
||||
// CHECK: Running pass: InstCombinePass
|
||||
// CHECK: Verifying function foo
|
||||
|
||||
void foo(void) {
|
||||
}
|
@ -57,6 +57,7 @@ struct Config {
|
||||
CodeGenOpt::Level CGOptLevel = CodeGenOpt::Default;
|
||||
CodeGenFileType CGFileType = CGFT_ObjectFile;
|
||||
unsigned OptLevel = 2;
|
||||
bool VerifyEach = false;
|
||||
bool DisableVerify = false;
|
||||
|
||||
/// Use the standard optimization pipeline.
|
||||
|
@ -259,7 +259,8 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM,
|
||||
ModuleAnalysisManager MAM;
|
||||
|
||||
PassInstrumentationCallbacks PIC;
|
||||
StandardInstrumentations SI(Mod.getContext(), Conf.DebugPassManager);
|
||||
StandardInstrumentations SI(Mod.getContext(), Conf.DebugPassManager,
|
||||
Conf.VerifyEach);
|
||||
SI.registerCallbacks(PIC, &MAM);
|
||||
PassBuilder PB(TM, Conf.PTO, PGOOpt, &PIC);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user