https://github.com/kaviya2510 created 
https://github.com/llvm/llvm-project/pull/188022

Added support for option "-fdebug-info-for-profiling" in llvm-flang compiler.

- When the option `-fdebug-info-for-profiling` option is passed, the compiler 
sets the `DebugInfoForProfiling` flag and triggers the `AddDiscriminatorsPass`. 
This pass inserts additional debug metadata, specifically discriminator values 
into the IR to improve the profiling precision.
- Additionally `-add-debug-info` pass has been updated to emit an extra field, 
`debugInfoForProfiling: true` inside the generated DICompileUnit metadata node.

>From af1b47537ca490f898a166f1b3958bb224e048ec Mon Sep 17 00:00:00 2001
From: Kaviya Rajendiran <[email protected]>
Date: Mon, 23 Mar 2026 17:19:28 +0530
Subject: [PATCH] [LLVM-Flang] Add support for -fdebug-info-for-profiling
 option

---
 clang/include/clang/Options/Options.td        |  4 +--
 clang/lib/Driver/ToolChains/Flang.cpp         |  5 +++
 .../include/flang/Frontend/CodeGenOptions.def |  1 +
 .../flang/Optimizer/Passes/Pipelines.h        |  4 +--
 .../flang/Optimizer/Transforms/Passes.td      |  3 ++
 flang/include/flang/Tools/CrossToolHelpers.h  |  2 ++
 flang/lib/Frontend/CompilerInvocation.cpp     |  3 ++
 flang/lib/Frontend/FrontendActions.cpp        | 24 ++++++++-----
 flang/lib/Optimizer/Passes/Pipelines.cpp      | 14 +++++---
 .../lib/Optimizer/Transforms/AddDebugInfo.cpp |  2 +-
 .../test/Driver/fdebug-info-for-profiling.f90 | 36 +++++++++++++++++++
 llvm/include/llvm/IR/DebugInfoMetadata.h      |  1 +
 mlir/include/mlir-c/Dialect/LLVM.h            |  4 +--
 .../mlir/Dialect/LLVMIR/LLVMAttrDefs.td       |  4 ++-
 .../Dialect/LLVMIR/LLVMDialectBytecode.td     |  4 ++-
 mlir/lib/CAPI/Dialect/LLVM.cpp                |  7 ++--
 mlir/lib/Target/LLVMIR/DebugImporter.cpp      |  3 +-
 mlir/lib/Target/LLVMIR/DebugTranslation.cpp   |  2 +-
 mlir/test/CAPI/llvm.c                         |  2 +-
 19 files changed, 96 insertions(+), 29 deletions(-)
 create mode 100644 flang/test/Driver/fdebug-info-for-profiling.f90

diff --git a/clang/include/clang/Options/Options.td 
b/clang/include/clang/Options/Options.td
index 8b0c701521728..44f795e36b105 100644
--- a/clang/include/clang/Options/Options.td
+++ b/clang/include/clang/Options/Options.td
@@ -1820,9 +1820,9 @@ def ffile_compilation_dir_EQ : Joined<["-"], 
"ffile-compilation-dir=">, Group<f_
     HelpText<"The compilation directory to embed in the debug info and 
coverage mapping.">;
 defm debug_info_for_profiling : BoolFOption<"debug-info-for-profiling",
   CodeGenOpts<"DebugInfoForProfiling">, DefaultFalse,
-  PosFlag<SetTrue, [], [ClangOption, CC1Option],
+  PosFlag<SetTrue, [], [ClangOption, CC1Option, FlangOption, FC1Option],
           "Emit extra debug info to make sample profile more accurate">,
-  NegFlag<SetFalse>>;
+  NegFlag<SetFalse, [], [ClangOption, FlangOption]>>;
 def fprofile_generate_cold_function_coverage : Flag<["-"], 
"fprofile-generate-cold-function-coverage">,
     Group<f_Group>, Visibility<[ClangOption, CLOption]>,
     HelpText<"Generate instrumented code to collect coverage info for cold 
functions into default.profraw file (overridden by '=' form of option or 
LLVM_PROFILE_FILE env var)">;
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index d56a8c4448469..0b45a8dc8498c 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -193,6 +193,11 @@ void Flang::addDebugOptions(const llvm::opt::ArgList 
&Args, const JobAction &JA,
       CmdArgs.push_back(SplitDWARFOut);
     }
   }
+  if (Args.hasFlag(options::OPT_fdebug_info_for_profiling,
+                   options::OPT_fno_debug_info_for_profiling, false) &&
+      checkDebugInfoOption(
+          Args.getLastArg(options::OPT_fdebug_info_for_profiling), Args, D, 
TC))
+    CmdArgs.push_back("-fdebug-info-for-profiling");
 }
 
 void Flang::addCodegenOptions(const ArgList &Args,
diff --git a/flang/include/flang/Frontend/CodeGenOptions.def 
b/flang/include/flang/Frontend/CodeGenOptions.def
index c877e3320b264..38f1a85b998dc 100644
--- a/flang/include/flang/Frontend/CodeGenOptions.def
+++ b/flang/include/flang/Frontend/CodeGenOptions.def
@@ -51,6 +51,7 @@ CODEGENOPT(LoopVersioning, 1, 0) ///< Enable loop versioning.
 CODEGENOPT(UnrollLoops, 1, 0) ///< Enable loop unrolling
 CODEGENOPT(AliasAnalysis, 1, 0) ///< Enable alias analysis pass
 CODEGENOPT(DwarfVersion, 3, 0) ///< Dwarf version
+CODEGENOPT(DebugInfoForProfiling, 1, 0)  ///< Emit extra debug info to make 
sample profile more accurate.
 
 CODEGENOPT(Underscoring, 1, 1)
 ENUM_CODEGENOPT(FPMaxminBehavior, Fortran::common::FPMaxminBehavior, 2, 
Fortran::common::FPMaxminBehavior::Legacy)
diff --git a/flang/include/flang/Optimizer/Passes/Pipelines.h 
b/flang/include/flang/Optimizer/Passes/Pipelines.h
index 6c2a1e3c3c074..cf8e8fba7d171 100644
--- a/flang/include/flang/Optimizer/Passes/Pipelines.h
+++ b/flang/include/flang/Optimizer/Passes/Pipelines.h
@@ -104,8 +104,8 @@ void 
addCompilerGeneratedNamesConversionPass(mlir::PassManager &pm);
 void addDebugInfoPass(mlir::PassManager &pm,
                       llvm::codegenoptions::DebugInfoKind debugLevel,
                       llvm::OptimizationLevel optLevel,
-                      llvm::StringRef inputFilename, int32_t dwarfVersion,
-                      llvm::StringRef splitDwarfFile,
+                      bool debugInfoForProfiling, llvm::StringRef 
inputFilename,
+                      int32_t dwarfVersion, llvm::StringRef splitDwarfFile,
                       llvm::StringRef dwarfDebugFlags);
 
 /// Create FIRToLLVMPassOptions from pipeline configuration.
diff --git a/flang/include/flang/Optimizer/Transforms/Passes.td 
b/flang/include/flang/Optimizer/Transforms/Passes.td
index 38c5fc8db911c..82d89c4df42c3 100644
--- a/flang/include/flang/Optimizer/Transforms/Passes.td
+++ b/flang/include/flang/Optimizer/Transforms/Passes.td
@@ -250,6 +250,9 @@ def AddDebugInfo : Pass<"add-debug-info", "mlir::ModuleOp"> 
{
     Option<"isOptimized", "is-optimized",
            "bool", /*default=*/"false",
            "is optimized.">,
+    Option<"debugInfoForProfiling", "debug-info-for-profiling", "bool",
+           /*default=*/"false",
+            "Emit extra debug info to make sample profile more accurate">,
     Option<"inputFilename", "file-name",
            "std::string",
            /*default=*/"std::string{}",
diff --git a/flang/include/flang/Tools/CrossToolHelpers.h 
b/flang/include/flang/Tools/CrossToolHelpers.h
index db4a93846850a..d4bdc3bbd30a7 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -106,6 +106,7 @@ struct MLIRToLLVMPassPipelineConfig : public 
FlangEPCallBacks {
         ApproxFuncFPMath && mathOpts.getFPContractEnabled();
     Reciprocals = opts.Reciprocals;
     PreferVectorWidth = opts.PreferVectorWidth;
+    DebugInfoForProfiling = opts.DebugInfoForProfiling;
     if (opts.InstrumentFunctions) {
       InstrumentFunctionEntry = "__cyg_profile_func_enter";
       InstrumentFunctionExit = "__cyg_profile_func_exit";
@@ -139,6 +140,7 @@ struct MLIRToLLVMPassPipelineConfig : public 
FlangEPCallBacks {
                                       ///< functions.
   bool NSWOnLoopVarInc = true; ///< Add nsw flag to loop variable increments.
   bool EnableOpenMP = false; ///< Enable OpenMP lowering.
+  bool DebugInfoForProfiling = false; /// Enable extra debugging info
   bool EnableOpenMPSimd = false; ///< Enable OpenMP simd-only mode.
   bool SkipConvertComplexPow = false; ///< Do not run complex pow conversion.
   std::string InstrumentFunctionEntry =
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index 36791201825ce..8d99fc9d4403e 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -170,6 +170,9 @@ static bool 
parseDebugArgs(Fortran::frontend::CodeGenOptions &opts,
           args.getLastArg(clang::options::OPT_dwarf_debug_flags))
     opts.DwarfDebugFlags = arg->getValue();
 
+  opts.DebugInfoForProfiling =
+      args.hasArg(clang::options::OPT_fdebug_info_for_profiling);
+
   return true;
 }
 
diff --git a/flang/lib/Frontend/FrontendActions.cpp 
b/flang/lib/Frontend/FrontendActions.cpp
index e74c913cfa137..7d85b26f718af 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -968,14 +968,14 @@ void 
CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream &os) {
 
   if (opts.hasProfileIRInstr()) {
     // -fprofile-generate.
-    pgoOpt = llvm::PGOOptions(opts.InstrProfileOutput.empty()
-                                  ? llvm::driver::getDefaultProfileGenName()
-                                  : opts.InstrProfileOutput,
-                              "", "", opts.MemoryProfileUsePath,
-                              llvm::PGOOptions::IRInstr,
-                              llvm::PGOOptions::NoCSAction,
-                              llvm::PGOOptions::ColdFuncOpt::Default, false,
-                              /*PseudoProbeForProfiling=*/false, false);
+    pgoOpt = llvm::PGOOptions(
+        opts.InstrProfileOutput.empty()
+            ? llvm::driver::getDefaultProfileGenName()
+            : opts.InstrProfileOutput,
+        "", "", opts.MemoryProfileUsePath, llvm::PGOOptions::IRInstr,
+        llvm::PGOOptions::NoCSAction, llvm::PGOOptions::ColdFuncOpt::Default,
+        opts.DebugInfoForProfiling,
+        /*PseudoProbeForProfiling=*/false, false);
   } else if (opts.hasProfileIRUse()) {
     // -fprofile-use.
     auto CSAction = opts.hasProfileCSIRUse() ? llvm::PGOOptions::CSIRUse
@@ -983,7 +983,13 @@ void 
CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream &os) {
     pgoOpt = llvm::PGOOptions(
         opts.ProfileInstrumentUsePath, "", opts.ProfileRemappingFile,
         opts.MemoryProfileUsePath, llvm::PGOOptions::IRUse, CSAction,
-        llvm::PGOOptions::ColdFuncOpt::Default, false);
+        llvm::PGOOptions::ColdFuncOpt::Default, opts.DebugInfoForProfiling);
+  } else if (opts.DebugInfoForProfiling) {
+    // -fdebug-info-for-profiling
+    pgoOpt = llvm::PGOOptions("", "", "", /*MemoryProfile=*/"",
+                              llvm::PGOOptions::NoAction,
+                              llvm::PGOOptions::NoCSAction,
+                              llvm::PGOOptions::ColdFuncOpt::Default, true);
   }
 
   llvm::StandardInstrumentations si(llvmModule->getContext(),
diff --git a/flang/lib/Optimizer/Passes/Pipelines.cpp 
b/flang/lib/Optimizer/Passes/Pipelines.cpp
index e9cd5da56083e..631496a2cea20 100644
--- a/flang/lib/Optimizer/Passes/Pipelines.cpp
+++ b/flang/lib/Optimizer/Passes/Pipelines.cpp
@@ -96,13 +96,14 @@ getEmissionKind(llvm::codegenoptions::DebugInfoKind kind) {
 void addDebugInfoPass(mlir::PassManager &pm,
                       llvm::codegenoptions::DebugInfoKind debugLevel,
                       llvm::OptimizationLevel optLevel,
-                      llvm::StringRef inputFilename, int32_t dwarfVersion,
-                      llvm::StringRef splitDwarfFile,
+                      bool debugInfoForProfiling, llvm::StringRef 
inputFilename,
+                      int32_t dwarfVersion, llvm::StringRef splitDwarfFile,
                       llvm::StringRef dwarfDebugFlags) {
   fir::AddDebugInfoOptions options;
   options.debugLevel = getEmissionKind(debugLevel);
   options.isOptimized = optLevel != llvm::OptimizationLevel::O0;
   options.inputFilename = inputFilename;
+  options.debugInfoForProfiling = debugInfoForProfiling;
   options.dwarfVersion = dwarfVersion;
   options.splitDwarfFile = splitDwarfFile;
   options.dwarfDebugFlags = dwarfDebugFlags;
@@ -372,12 +373,14 @@ void createOpenMPFIRPassPipeline(mlir::PassManager &pm,
 void createDebugPasses(mlir::PassManager &pm,
                        llvm::codegenoptions::DebugInfoKind debugLevel,
                        llvm::OptimizationLevel OptLevel,
+                       bool debugInfoForProfiling,
                        llvm::StringRef inputFilename, int32_t dwarfVersion,
                        llvm::StringRef splitDwarfFile,
                        llvm::StringRef dwarfDebugFlags) {
   if (debugLevel != llvm::codegenoptions::NoDebugInfo)
-    addDebugInfoPass(pm, debugLevel, OptLevel, inputFilename, dwarfVersion,
-                     splitDwarfFile, dwarfDebugFlags);
+    addDebugInfoPass(pm, debugLevel, OptLevel, debugInfoForProfiling,
+                     inputFilename, dwarfVersion, splitDwarfFile,
+                     dwarfDebugFlags);
 }
 
 void createDefaultFIRCodeGenPassPipeline(mlir::PassManager &pm,
@@ -395,7 +398,8 @@ void createDefaultFIRCodeGenPassPipeline(mlir::PassManager 
&pm,
   fir::addCodeGenRewritePass(
       pm, (config.DebugInfo != llvm::codegenoptions::NoDebugInfo));
   fir::addExternalNameConversionPass(pm, config.Underscoring);
-  fir::createDebugPasses(pm, config.DebugInfo, config.OptLevel, inputFilename,
+  fir::createDebugPasses(pm, config.DebugInfo, config.OptLevel,
+                         config.DebugInfoForProfiling, inputFilename,
                          config.DwarfVersion, config.SplitDwarfFile,
                          config.DwarfDebugFlags);
   fir::addTargetRewritePass(pm);
diff --git a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp 
b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
index c42f5a29ecd62..389581c376a6d 100644
--- a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
+++ b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
@@ -936,7 +936,7 @@ void AddDebugInfoPass::runOnOperation() {
   mlir::LLVM::DICompileUnitAttr cuAttr = mlir::LLVM::DICompileUnitAttr::get(
       mlir::DistinctAttr::create(mlir::UnitAttr::get(context)),
       llvm::dwarf::getLanguage("DW_LANG_Fortran95"), fileAttr, producer,
-      isOptimized, debugLevel,
+      isOptimized, debugLevel, debugInfoForProfiling,
       /*nameTableKind=*/mlir::LLVM::DINameTableKind::Default,
       splitDwarfFile.empty() ? mlir::StringAttr()
                              : mlir::StringAttr::get(context, splitDwarfFile));
diff --git a/flang/test/Driver/fdebug-info-for-profiling.f90 
b/flang/test/Driver/fdebug-info-for-profiling.f90
new file mode 100644
index 0000000000000..2e72e2b569164
--- /dev/null
+++ b/flang/test/Driver/fdebug-info-for-profiling.f90
@@ -0,0 +1,36 @@
+! Test to check the option "-fdebug-info-for-profiling".
+
+!RUN: %flang -### -S -fdebug-info-for-profiling %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DEBUG-INFO
+!RUN: %flang -### -S -fdebug-info-for-profiling -fno-debug-info-for-profiling 
-fdebug-info-for-profiling %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DEBUG-INFO
+! RUN: %flang -S -emit-llvm -fdebug-info-for-profiling -g -o - %s | FileCheck 
%s
+
+! CHECK-DEBUG-INFO: "-fdebug-info-for-profiling"
+
+! CHECK: !DICompileUnit({{.*}}debugInfoForProfiling: true{{.*}})
+! CHECK: !DILexicalBlockFile(
+! CHECK: discriminator:
+
+program test
+   implicit none
+   integer :: i, sum
+   sum = 0
+   do i = 1, 20
+      if (mod(i, 2) == 0) then
+         sum = sum + compute(i)
+      else
+         sum = sum + compute(i)*2
+      end if
+   end do
+
+contains
+   integer function compute(x)
+      implicit none
+      integer, intent(in) :: x
+      if (x < 10) then
+         compute = x*x
+      else
+         compute = x + 5
+      end if
+   end function compute
+
+end program test
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h 
b/llvm/include/llvm/IR/DebugInfoMetadata.h
index 3ce899db66217..e28b47d87d4e5 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -2118,6 +2118,7 @@ class DICompileUnit : public DIScope {
 
   DISourceLanguageName getSourceLanguage() const { return SourceLanguage; }
   bool isOptimized() const { return IsOptimized; }
+  bool isDebugInfoForProfiling() const { return DebugInfoForProfiling; }
   unsigned getRuntimeVersion() const { return RuntimeVersion; }
   DebugEmissionKind getEmissionKind() const {
     return (DebugEmissionKind)EmissionKind;
diff --git a/mlir/include/mlir-c/Dialect/LLVM.h 
b/mlir/include/mlir-c/Dialect/LLVM.h
index 2c167d23a7d9a..02ae71e41b8b7 100644
--- a/mlir/include/mlir-c/Dialect/LLVM.h
+++ b/mlir/include/mlir-c/Dialect/LLVM.h
@@ -366,8 +366,8 @@ typedef enum MlirLLVMDINameTableKind 
MlirLLVMDINameTableKind;
 MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDICompileUnitAttrGet(
     MlirContext ctx, MlirAttribute id, unsigned int sourceLanguage,
     MlirAttribute file, MlirAttribute producer, bool isOptimized,
-    MlirLLVMDIEmissionKind emissionKind, MlirLLVMDINameTableKind nameTableKind,
-    MlirAttribute splitDebugFilename);
+    MlirLLVMDIEmissionKind emissionKind, bool debugInfoForProfiling,
+    MlirLLVMDINameTableKind nameTableKind, MlirAttribute splitDebugFilename);
 
 MLIR_CAPI_EXPORTED MlirStringRef mlirLLVMDICompileUnitAttrGetName(void);
 
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
index 14a4f888bd51d..89bdbe96c01b9 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
@@ -425,6 +425,7 @@ def LLVM_DICompileUnitAttr : LLVM_Attr<"DICompileUnit", 
"di_compile_unit",
     OptionalParameter<"StringAttr">:$producer,
     "bool":$isOptimized,
     "DIEmissionKind":$emissionKind,
+    OptionalParameter<"bool">:$debugInfoForProfiling,
     OptionalParameter<"DINameTableKind">:$nameTableKind,
     OptionalParameter<"StringAttr">:$splitDebugFilename
   );
@@ -433,11 +434,12 @@ def LLVM_DICompileUnitAttr : LLVM_Attr<"DICompileUnit", 
"di_compile_unit",
       "DistinctAttr":$id, "unsigned":$sourceLanguage, "DIFileAttr":$file,
       "StringAttr":$producer, "bool":$isOptimized,
       "DIEmissionKind":$emissionKind,
+      CArg<"bool", "false">:$debugInfoForProfiling,
       CArg<"DINameTableKind", "DINameTableKind::Default">:$nameTableKind,
       CArg<"StringAttr", "{}">:$splitDebugFilename
     ), [{
       return $_get(id.getContext(), id, sourceLanguage, file, producer,
-                   isOptimized, emissionKind, nameTableKind, 
splitDebugFilename);
+                   isOptimized, emissionKind, debugInfoForProfiling, 
nameTableKind, splitDebugFilename);
     }]>
   ];
   let assemblyFormat = "`<` struct(params) `>`";
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialectBytecode.td 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialectBytecode.td
index 659c535c1b671..9ab725af71495 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialectBytecode.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialectBytecode.td
@@ -136,9 +136,11 @@ def DICompileUnitAttr : DialectAttribute<(attr
   Bool:$isOptimized,
   EnumClassFlag<"DIEmissionKind", "getEmissionKind()">:$_rawEmissionKind,
   LocalVar<"DIEmissionKind", "(DIEmissionKind)_rawEmissionKind">:$emissionKind,
+  Bool:$debugInfoForProfiling,
   EnumClassFlag<"DINameTableKind", "getNameTableKind()">:$_rawNameTableKind,
   LocalVar<"DINameTableKind",
-           "(DINameTableKind)_rawNameTableKind">:$nameTableKind
+           "(DINameTableKind)_rawNameTableKind">:$nameTableKind,
+  OptionalAttribute<"StringAttr">:$splitDebugFilename
 )>;
 
 
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp
index 154ebbc51e961..c1f60fb2753f3 100644
--- a/mlir/lib/CAPI/Dialect/LLVM.cpp
+++ b/mlir/lib/CAPI/Dialect/LLVM.cpp
@@ -345,12 +345,13 @@ MlirStringRef mlirLLVMDIFileAttrGetName(void) { return 
wrap(DIFileAttr::name); }
 MlirAttribute mlirLLVMDICompileUnitAttrGet(
     MlirContext ctx, MlirAttribute id, unsigned int sourceLanguage,
     MlirAttribute file, MlirAttribute producer, bool isOptimized,
-    MlirLLVMDIEmissionKind emissionKind, MlirLLVMDINameTableKind nameTableKind,
-    MlirAttribute splitDebugFilename) {
+    MlirLLVMDIEmissionKind emissionKind, bool debugInfoForProfiling,
+    MlirLLVMDINameTableKind nameTableKind, MlirAttribute splitDebugFilename) {
   return wrap(DICompileUnitAttr::get(
       unwrap(ctx), cast<DistinctAttr>(unwrap(id)), sourceLanguage,
       cast<DIFileAttr>(unwrap(file)), cast<StringAttr>(unwrap(producer)),
-      isOptimized, DIEmissionKind(emissionKind), 
DINameTableKind(nameTableKind),
+      isOptimized, DIEmissionKind(emissionKind), debugInfoForProfiling,
+      DINameTableKind(nameTableKind),
       cast<StringAttr>(unwrap(splitDebugFilename))));
 }
 
diff --git a/mlir/lib/Target/LLVMIR/DebugImporter.cpp 
b/mlir/lib/Target/LLVMIR/DebugImporter.cpp
index 37140e3a949c7..c099865bdd16e 100644
--- a/mlir/lib/Target/LLVMIR/DebugImporter.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugImporter.cpp
@@ -61,7 +61,8 @@ DICompileUnitAttr 
DebugImporter::translateImpl(llvm::DICompileUnit *node) {
       context, getOrCreateDistinctID(node),
       node->getSourceLanguage().getUnversionedName(),
       translate(node->getFile()), getStringAttrOrNull(node->getRawProducer()),
-      node->isOptimized(), emissionKind.value(), nameTableKind.value(),
+      node->isOptimized(), emissionKind.value(),
+      node->isDebugInfoForProfiling(), nameTableKind.value(),
       getStringAttrOrNull(node->getRawSplitDebugFilename()));
 }
 
diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp 
b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
index 08eee68c195db..588998b6f6c73 100644
--- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
@@ -130,7 +130,7 @@ llvm::DICompileUnit 
*DebugTranslation::translateImpl(DICompileUnitAttr attr) {
                                    : "",
       static_cast<llvm::DICompileUnit::DebugEmissionKind>(
           attr.getEmissionKind()),
-      0, true, false,
+      0, true, attr.getDebugInfoForProfiling(),
       static_cast<llvm::DICompileUnit::DebugNameTableKind>(
           attr.getNameTableKind()));
 }
diff --git a/mlir/test/CAPI/llvm.c b/mlir/test/CAPI/llvm.c
index 32f6b8c8d8a33..0e9c1ce0d7ccd 100644
--- a/mlir/test/CAPI/llvm.c
+++ b/mlir/test/CAPI/llvm.c
@@ -278,7 +278,7 @@ static void testDebugInfoAttributes(MlirContext ctx) {
 
   MlirAttribute compile_unit = mlirLLVMDICompileUnitAttrGet(
       ctx, id, LLVMDWARFSourceLanguageC99, file, foo, false,
-      MlirLLVMDIEmissionKindFull, MlirLLVMDINameTableKindDefault, bar);
+      MlirLLVMDIEmissionKindFull, false, MlirLLVMDINameTableKindDefault, bar);
 
   // CHECK: #llvm.di_compile_unit<{{.*}}>
   mlirAttributeDump(compile_unit);

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to