diff --git a/flang-legacy/17.0-4/llvm-legacy/clang/include/clang/Basic/CodeGenOptions.def b/flang-legacy/17.0-4/llvm-legacy/clang/include/clang/Basic/CodeGenOptions.def index d595e2783e..54341c15d2 100644 --- a/flang-legacy/17.0-4/llvm-legacy/clang/include/clang/Basic/CodeGenOptions.def +++ b/flang-legacy/17.0-4/llvm-legacy/clang/include/clang/Basic/CodeGenOptions.def @@ -34,8 +34,9 @@ CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no} CODEGENOPT(AsmVerbose , 1, 0) ///< -dA, -fverbose-asm. CODEGENOPT(Dwarf64 , 1, 0) ///< -gdwarf64. CODEGENOPT(Dwarf32 , 1, 1) ///< -gdwarf32. -CODEGENOPT(HeterogeneousDwarf, 1, 0) ///< Enable DWARF extensions for - ///< heterogeneous debugging. +/// Control DWARF extensions for heterogeneous debugging enablement and approach. +ENUM_CODEGENOPT(HeterogeneousDwarfMode, HeterogeneousDwarfOpts, 2, + HeterogeneousDwarfOpts::Disabled) CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments. CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) operator new CODEGENOPT(AssumeUniqueVTables , 1, 1) ///< Assume a class has only one vtable. diff --git a/flang-legacy/17.0-4/llvm-legacy/clang/include/clang/Basic/CodeGenOptions.h b/flang-legacy/17.0-4/llvm-legacy/clang/include/clang/Basic/CodeGenOptions.h index 14fc94fe27..3612844ff6 100644 --- a/flang-legacy/17.0-4/llvm-legacy/clang/include/clang/Basic/CodeGenOptions.h +++ b/flang-legacy/17.0-4/llvm-legacy/clang/include/clang/Basic/CodeGenOptions.h @@ -164,6 +164,21 @@ class CodeGenOptions : public CodeGenOptionsBase { Never, // No loop is assumed to be finite. }; + enum class HeterogeneousDwarfOpts { + Disabled, //< Do not emit any heterogeneous dwarf metadata. + DIExpr, //< Enable DIExpr-based metadata. + DIExpression, //< Enable DIExpression-based metadata. + }; + bool isHeterogeneousDwarfEnabled() const { + return getHeterogeneousDwarfMode() != HeterogeneousDwarfOpts::Disabled; + } + bool isHeterogeneousDwarfDIExpr() const { + return getHeterogeneousDwarfMode() == HeterogeneousDwarfOpts::DIExpr; + } + bool isHeterogeneousDwarfDIExpression() const { + return getHeterogeneousDwarfMode() == HeterogeneousDwarfOpts::DIExpression; + } + enum AssignmentTrackingOpts { Disabled, Enabled, diff --git a/flang-legacy/17.0-4/llvm-legacy/clang/include/clang/Driver/Options.td b/flang-legacy/17.0-4/llvm-legacy/clang/include/clang/Driver/Options.td index 1ee1e2797c..df0880c60a 100644 --- a/flang-legacy/17.0-4/llvm-legacy/clang/include/clang/Driver/Options.td +++ b/flang-legacy/17.0-4/llvm-legacy/clang/include/clang/Driver/Options.td @@ -3543,12 +3543,20 @@ def gdwarf64 : Flag<["-"], "gdwarf64">, Group, def gdwarf32 : Flag<["-"], "gdwarf32">, Group, Flags<[CC1Option, CC1AsOption]>, HelpText<"Enables DWARF32 format for ELF binaries, if debug information emission is enabled.">; -def gheterogeneous_dwarf : Flag<["-"], "gheterogeneous-dwarf">, +def gheterogeneous_dwarf_EQ : Joined<["-"], "gheterogeneous-dwarf=">, Group, Flags<[CC1Option]>, - HelpText<"Enable DWARF extensions for heterogeneous debugging">, - MarshallingInfoFlag>; + HelpText<"Control DWARF extensions for heterogeneous debugging">, + Values<"disabled,diexpr,diexpression">, + NormalizedValuesScope<"CodeGenOptions::HeterogeneousDwarfOpts">, + NormalizedValues<["Disabled","DIExpr","DIExpression"]>, + MarshallingInfoEnum, "Disabled">; +def gheterogeneous_dwarf : Flag<["-"], "gheterogeneous-dwarf">, Group, + HelpText<"Enable DIExpression-based DWARF extensions for heterogeneous debugging">, + Alias, AliasArgs<["diexpression"]>; def gno_heterogeneous_dwarf : Flag<["-"], "gno-heterogeneous-dwarf">, - Group, HelpText<"Disable DWARF extensions for heterogeneous debugging">; + Group, + HelpText<"Disable DWARF extensions for heterogeneous debugging">, + Alias, AliasArgs<["disabled"]>; def gcodeview : Flag<["-"], "gcodeview">, HelpText<"Generate CodeView debug information">, diff --git a/flang-legacy/17.0-4/llvm-legacy/clang/lib/CodeGen/CGDebugInfo.cpp b/flang-legacy/17.0-4/llvm-legacy/clang/lib/CodeGen/CGDebugInfo.cpp index 676441fe98..76704b5e87 100644 --- a/flang-legacy/17.0-4/llvm-legacy/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/flang-legacy/17.0-4/llvm-legacy/clang/lib/CodeGen/CGDebugInfo.cpp @@ -4624,8 +4624,11 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD, std::optional ArgNo, CGBuilderTy &Builder, const bool UsePointerValue) { + /* if (CGM.getCodeGenOpts().HeterogeneousDwarf) return EmitDef(VD, Storage, ArgNo, Builder, UsePointerValue); + */ + assert(false); assert(CGM.getCodeGenOpts().hasReducedDebugInfo()); assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); @@ -4812,8 +4815,11 @@ llvm::DILocalVariable *CGDebugInfo::EmitDef(const VarDecl *VD, const bool UsePointerValue) { assert(CGM.getCodeGenOpts().hasReducedDebugInfo() && "Call to EmitDef below ReducedDebugInfo"); + /* assert(CGM.getCodeGenOpts().HeterogeneousDwarf && "Call to EmitDef without HeterogeneousDwarf enabled"); + */ + assert(false); assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); if (VD->hasAttr()) return nullptr; @@ -5442,7 +5448,10 @@ CGDebugInfo::CollectAnonRecordDeclsForHeterogeneousDwarf( const RecordDecl *RD, llvm::DIFile *Unit, unsigned LineNo, StringRef LinkageName, llvm::dwarf::MemorySpace MS, llvm::GlobalVariable *Var, llvm::DIScope *DContext) { + /* assert(CGM.getCodeGenOpts().HeterogeneousDwarf); + */ + assert(false); llvm::DIGlobalVariable *GV = nullptr; @@ -5695,8 +5704,11 @@ std::string CGDebugInfo::GetName(const Decl *D, bool Qualified) const { void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var, const VarDecl *D) { + /* if (CGM.getCodeGenOpts().HeterogeneousDwarf) return EmitGlobalVariableForHeterogeneousDwarf(Var, D); + */ + assert(false); assert(CGM.getCodeGenOpts().hasReducedDebugInfo()); if (D->hasAttr()) @@ -5767,7 +5779,10 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var, void CGDebugInfo::EmitGlobalVariableForHeterogeneousDwarf( llvm::GlobalVariable *Var, const VarDecl *D) { assert(CGM.getCodeGenOpts().hasReducedDebugInfo()); + /* assert(CGM.getCodeGenOpts().HeterogeneousDwarf); + */ + assert(false); if (D->hasAttr()) return; @@ -5844,8 +5859,11 @@ void CGDebugInfo::EmitGlobalVariableForHeterogeneousDwarf( } void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) { + /* if (CGM.getCodeGenOpts().HeterogeneousDwarf) return EmitGlobalVariableForHeterogeneousDwarf(VD, Init); + */ + assert(false); assert(CGM.getCodeGenOpts().hasReducedDebugInfo()); if (VD->hasAttr()) @@ -6095,8 +6113,11 @@ void CGDebugInfo::EmitGlobalAlias(const llvm::GlobalValue *GV, void CGDebugInfo::AddStringLiteralDebugInfo(llvm::GlobalVariable *GV, const StringLiteral *S) { // FIXME: Implement for heterogeneous debug info + /* if (CGM.getCodeGenOpts().HeterogeneousDwarf) return; + */ + assert(false); SourceLocation Loc = S->getStrTokenLoc(0); PresumedLoc PLoc = CGM.getContext().getSourceManager().getPresumedLoc(Loc); diff --git a/flang-legacy/17.0-4/llvm-legacy/clang/lib/CodeGen/CodeGenModule.cpp b/flang-legacy/17.0-4/llvm-legacy/clang/lib/CodeGen/CodeGenModule.cpp index 55e628b430..d6ec2c9c52 100644 --- a/flang-legacy/17.0-4/llvm-legacy/clang/lib/CodeGen/CodeGenModule.cpp +++ b/flang-legacy/17.0-4/llvm-legacy/clang/lib/CodeGen/CodeGenModule.cpp @@ -960,12 +960,15 @@ void CodeGenModule::Release() { // We support a single version in the linked module. The LLVM // parser will drop debug info with a different version number // (and warn about it, too). + /* uint32_t DebugMetadataVersion = CodeGenOpts.HeterogeneousDwarf ? llvm::DEBUG_METADATA_VERSION_HETEROGENEOUS_DWARF : llvm::DEBUG_METADATA_VERSION; getModule().addModuleFlag(llvm::Module::Warning, "Debug Info Version", DebugMetadataVersion); + */ + assert(false); } // We need to record the widths of enums and wchar_t, so that we can generate diff --git a/flang-legacy/17.0-4/llvm-legacy/clang/lib/Driver/ToolChains/Clang.cpp b/flang-legacy/17.0-4/llvm-legacy/clang/lib/Driver/ToolChains/Clang.cpp index 1c5ee79cdd..2d4f343048 100644 --- a/flang-legacy/17.0-4/llvm-legacy/clang/lib/Driver/ToolChains/Clang.cpp +++ b/flang-legacy/17.0-4/llvm-legacy/clang/lib/Driver/ToolChains/Clang.cpp @@ -4551,9 +4551,31 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, bool EmitDwarfForAMDGCN = EmitDwarf && T.isAMDGCN(); if (EmitDwarfForAMDGCN) CmdArgs.append({"-mllvm", "-amdgpu-spill-cfi-saved-regs"}); - if (Args.hasFlag(options::OPT_gheterogeneous_dwarf, - options::OPT_gno_heterogeneous_dwarf, EmitDwarfForAMDGCN)) - CmdArgs.push_back("-gheterogeneous-dwarf"); + if (Arg *A = Args.getLastArg(options::OPT_gheterogeneous_dwarf_EQ)) { + A->render(Args, CmdArgs); + } else if (EmitDwarfForAMDGCN) { +#ifndef NDEBUG + // There doesn't seem to be a straightforward way to "render" an option + // acquired from the OptTable into a string we can append to CmdArgs. + // All of the logic is buried in "accept" which works directly in terms + // of an ArgList. + // + // Instead, assert that the static string we are adding to CmdArgs has + // the same shape as what a bare -gheterogeneous-dwarf would alias to + // if the user has provided it in ArgList. + const Option GHeterogeneousDwarf = + getDriverOptTable().getOption(options::OPT_gheterogeneous_dwarf); + const Option Aliased = GHeterogeneousDwarf.getAlias(); + assert(Aliased.isValid() && "gheterogeneous-dwarf must be an alias"); + assert(Aliased.getName() == "gheterogeneous-dwarf=" && + "gheterogeneous-dwarf must alias gheterogeneous-dwarf="); + assert(StringRef(GHeterogeneousDwarf.getAliasArgs()) == "diexpression" && + GHeterogeneousDwarf.getAliasArgs()[strlen("diexpression") + 1] == + '\0' && + "gheterogeneous-dwarf must alias gheterogeneous-dwarf=diexpression"); +#endif + CmdArgs.push_back("-gheterogeneous-dwarf=diexpression"); + } } static void ProcessVSRuntimeLibrary(const ArgList &Args,