IRGen: add an option -min-valid-pointer-value to override the target's LeastValidPointerValue

The LeastValidPointerValue is hard-coded in the runtime.
Therefore this option is only available in embedded swift - which doesn't have a runtime.

rdar://151755654
This commit is contained in:
Erik Eckstein
2025-06-03 09:27:19 +02:00
parent 4fb4945ab9
commit c02bc2d421
6 changed files with 48 additions and 0 deletions

View File

@@ -3506,6 +3506,21 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
Opts.DebugInfoForProfiling |= Args.hasArg(OPT_debug_info_for_profiling);
if (const Arg *A = Args.getLastArg(OPT_min_valid_pointer_value)) {
// The LeastValidPointerValue is hard-coded in the runtime. Therefore it
// can only safely customized in embedded swift - which doesn't have a runtime.
if (!LangOpts.hasFeature(Feature::Embedded)) {
Diags.diagnose(SourceLoc(), diag::min_ptr_value_without_embedded);
return true;
}
if (StringRef(A->getValue()).getAsInteger(0, Opts.CustomLeastValidPointerValue)) {
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
A->getAsString(Args), A->getValue());
return true;
}
}
Opts.PrintInlineTree |= Args.hasArg(OPT_print_llvm_inline_tree);
// Always producing all outputs when caching is enabled.
Opts.AlwaysCompile |= Args.hasArg(OPT_always_compile_output_files) ||