Skip to content

Commit 39f58de

Browse files
Merge pull request #80033 from nate-chandler/verify-each-flag
[IRGen] Add flags to control LLVM verify-each.
2 parents e08d69e + dd8c715 commit 39f58de

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ class IRGenOptions {
292292
/// well-formed?
293293
unsigned Verify : 1;
294294

295+
/// Whether to verify after every optimizer change.
296+
unsigned VerifyEach : 1;
297+
295298
OptimizationMode OptMode;
296299

297300
/// Which sanitizer is turned on.
@@ -597,7 +600,7 @@ class IRGenOptions {
597600

598601
IRGenOptions()
599602
: OutputKind(IRGenOutputKind::LLVMAssemblyAfterOptimization),
600-
Verify(true), OptMode(OptimizationMode::NotSet),
603+
Verify(true), VerifyEach(false), OptMode(OptimizationMode::NotSet),
601604
Sanitizers(OptionSet<SanitizerKind>()),
602605
SanitizersWithRecoveryInstrumentation(OptionSet<SanitizerKind>()),
603606
SanitizeAddressUseODRIndicator(false), SanitizerUseStableABI(false),

include/swift/Option/FrontendOptions.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,12 @@ def disable_swift_specific_llvm_optzns : Flag<["-"], "disable-swift-specific-llv
596596
def disable_llvm_verify : Flag<["-"], "disable-llvm-verify">,
597597
HelpText<"Don't run the LLVM IR verifier.">;
598598

599+
def enable_llvm_verify_each : Flag<["-"], "enable-llvm-verify-each">,
600+
HelpText<"Run the LLVM IR verifier after every pass.">;
601+
602+
def disable_llvm_verify_each : Flag<["-"], "disable-llvm-verify-each">,
603+
HelpText<"Don't run the LLVM IR verifier after every pass.">;
604+
599605
def disable_llvm_value_names : Flag<["-"], "disable-llvm-value-names">,
600606
HelpText<"Don't add names to local values in LLVM IR">;
601607

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3331,6 +3331,9 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
33313331
if (Args.hasArg(OPT_disable_llvm_verify))
33323332
Opts.Verify = false;
33333333

3334+
Opts.VerifyEach = Args.hasFlag(OPT_enable_llvm_verify_each,
3335+
OPT_disable_llvm_verify_each, Opts.VerifyEach);
3336+
33343337
Opts.EmitStackPromotionChecks |= Args.hasArg(OPT_stack_promotion_checks);
33353338
if (const Arg *A = Args.getLastArg(OPT_stack_promotion_limit)) {
33363339
unsigned limit;

lib/IRGen/IRGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void swift::performLLVMOptimizations(const IRGenOptions &Opts,
294294
PrintPassOpts.Indent = DebugPassStructure;
295295
PrintPassOpts.SkipAnalyses = DebugPassStructure;
296296
StandardInstrumentations SI(Module->getContext(), DebugPassStructure,
297-
/*VerifyEach*/ false, PrintPassOpts);
297+
Opts.VerifyEach, PrintPassOpts);
298298
SI.registerCallbacks(PIC, &MAM);
299299

300300
PassBuilder PB(TargetMachine, PTO, PGOOpt, &PIC);

0 commit comments

Comments
 (0)