Index: lib/CodeGen/CGDebugInfo.cpp =================================================================== --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -3698,8 +3698,7 @@ const FunctionDecl *CalleeDecl) { auto &CGOpts = CGM.getCodeGenOpts(); if (!CGOpts.EnableDebugEntryValues || !CGM.getLangOpts().Optimize || - !CallOrInvoke || - CGM.getCodeGenOpts().getDebugInfo() < codegenoptions::LimitedDebugInfo) + !CallOrInvoke) return; auto *Func = CallOrInvoke->getCalledFunction(); Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -777,10 +777,16 @@ Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes); Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers); + auto isDebugEntryValueSupportedByArch = [](llvm::Triple::ArchType Arch) { + return Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64 || + Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::arm || + Arch == llvm::Triple::armeb; + }; + llvm::Triple T(TargetOpts.Triple); - llvm::Triple::ArchType Arch = T.getArch(); if (Opts.OptimizationLevel > 0 && - (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64)) + Opts.getDebugInfo() >= codegenoptions::LimitedDebugInfo && + isDebugEntryValueSupportedByArch(T.getArch())) Opts.EnableDebugEntryValues = Args.hasArg(OPT_femit_debug_entry_values); Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);