@@ -1841,10 +1841,6 @@ void CompilerInvocationBase::GenerateCodeGenArgs(const CodeGenOptions &Opts,
18411841 serializeSanitizerKinds (Opts.SanitizeAnnotateDebugInfo ))
18421842 GenerateArg (Consumer, OPT_fsanitize_annotate_debug_info_EQ, Sanitizer);
18431843
1844- if (Opts.AllocTokenMax )
1845- GenerateArg (Consumer, OPT_falloc_token_max_EQ,
1846- std::to_string (*Opts.AllocTokenMax ));
1847-
18481844 if (!Opts.EmitVersionIdentMetadata )
18491845 GenerateArg (Consumer, OPT_Qn);
18501846
@@ -2358,15 +2354,6 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
23582354 }
23592355 }
23602356
2361- if (const auto *Arg = Args.getLastArg (options::OPT_falloc_token_max_EQ)) {
2362- StringRef S = Arg->getValue ();
2363- uint64_t Value = 0 ;
2364- if (S.getAsInteger (0 , Value))
2365- Diags.Report (diag::err_drv_invalid_value) << Arg->getAsString (Args) << S;
2366- else
2367- Opts.AllocTokenMax = Value;
2368- }
2369-
23702357 Opts.EmitVersionIdentMetadata = Args.hasFlag (OPT_Qy, OPT_Qn, true );
23712358
23722359 if (!LangOpts->CUDAIsDevice )
@@ -4037,6 +4024,29 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
40374024
40384025 if (!Opts.RandstructSeed .empty ())
40394026 GenerateArg (Consumer, OPT_frandomize_layout_seed_EQ, Opts.RandstructSeed );
4027+
4028+ if (Opts.AllocTokenMax )
4029+ GenerateArg (Consumer, OPT_falloc_token_max_EQ,
4030+ std::to_string (*Opts.AllocTokenMax ));
4031+
4032+ if (Opts.AllocTokenMode ) {
4033+ StringRef S;
4034+ switch (*Opts.AllocTokenMode ) {
4035+ case llvm::AllocTokenMode::Increment:
4036+ S = " increment" ;
4037+ break ;
4038+ case llvm::AllocTokenMode::Random:
4039+ S = " random" ;
4040+ break ;
4041+ case llvm::AllocTokenMode::TypeHash:
4042+ S = " typehash" ;
4043+ break ;
4044+ case llvm::AllocTokenMode::TypeHashPointerSplit:
4045+ S = " typehashpointersplit" ;
4046+ break ;
4047+ }
4048+ GenerateArg (Consumer, OPT_falloc_token_mode_EQ, S);
4049+ }
40404050}
40414051
40424052bool CompilerInvocation::ParseLangArgs (LangOptions &Opts, ArgList &Args,
@@ -4673,6 +4683,23 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
46734683 if (const Arg *A = Args.getLastArg (OPT_frandomize_layout_seed_EQ))
46744684 Opts.RandstructSeed = A->getValue (0 );
46754685
4686+ if (const auto *Arg = Args.getLastArg (options::OPT_falloc_token_max_EQ)) {
4687+ StringRef S = Arg->getValue ();
4688+ uint64_t Value = 0 ;
4689+ if (S.getAsInteger (0 , Value))
4690+ Diags.Report (diag::err_drv_invalid_value) << Arg->getAsString (Args) << S;
4691+ else
4692+ Opts.AllocTokenMax = Value;
4693+ }
4694+
4695+ if (const auto *Arg = Args.getLastArg (options::OPT_falloc_token_mode_EQ)) {
4696+ StringRef S = Arg->getValue ();
4697+ if (auto Mode = getAllocTokenModeFromString (S))
4698+ Opts.AllocTokenMode = Mode;
4699+ else
4700+ Diags.Report (diag::err_drv_invalid_value) << Arg->getAsString (Args) << S;
4701+ }
4702+
46764703 // Validate options for HLSL
46774704 if (Opts.HLSL ) {
46784705 // TODO: Revisit restricting SPIR-V to logical once we've figured out how to
0 commit comments