MLIR 22.0.0git
DIScopeForLLVMFuncOp.cpp File Reference
#include "mlir/Dialect/LLVMIR/Transforms/Passes.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/Support/Path.h"
#include "mlir/Dialect/LLVMIR/Transforms/Passes.h.inc"

Go to the source code of this file.

Namespaces

namespace  mlir
 Include the generated interface declarations.
namespace  mlir::LLVM

Macros

#define GEN_PASS_DEF_DISCOPEFORLLVMFUNCOPPASS

Functions

static FileLineColLoc extractFileLoc (Location loc)
 Attempt to extract a filename for the given loc.
static void addScopeToFunction (LLVM::LLVMFuncOp llvmFunc, LLVM::DICompileUnitAttr compileUnitAttr)
 Creates a DISubprogramAttr with the provided compile unit and attaches it to the function.
static Location getNestedLoc (Operation *op, LLVM::DIScopeAttr scopeAttr, Location calleeLoc)
static void setLexicalBlockFileAttr (Operation *op)
 Adds DILexicalBlockFileAttr for operations with CallSiteLoc and operations from different files than their containing function.

Macro Definition Documentation

◆ GEN_PASS_DEF_DISCOPEFORLLVMFUNCOPPASS

#define GEN_PASS_DEF_DISCOPEFORLLVMFUNCOPPASS

Definition at line 17 of file DIScopeForLLVMFuncOp.cpp.

Function Documentation

◆ addScopeToFunction()

void addScopeToFunction ( LLVM::LLVMFuncOp llvmFunc,
LLVM::DICompileUnitAttr compileUnitAttr )
static

Creates a DISubprogramAttr with the provided compile unit and attaches it to the function.

Does nothing when the function already has an attached subprogram.

Definition at line 46 of file DIScopeForLLVMFuncOp.cpp.

References mlir::DistinctAttr::create(), extractFileLoc(), and mlir::LocationAttr::findInstanceOf().

◆ extractFileLoc()

FileLineColLoc extractFileLoc ( Location loc)
static

Attempt to extract a filename for the given loc.

Definition at line 25 of file DIScopeForLLVMFuncOp.cpp.

References extractFileLoc().

Referenced by addScopeToFunction(), extractFileLoc(), getNestedLoc(), and setLexicalBlockFileAttr().

◆ getNestedLoc()

Location getNestedLoc ( Operation * op,
LLVM::DIScopeAttr scopeAttr,
Location calleeLoc )
static

◆ setLexicalBlockFileAttr()

void setLexicalBlockFileAttr ( Operation * op)
static

Adds DILexicalBlockFileAttr for operations with CallSiteLoc and operations from different files than their containing function.

Definition at line 114 of file DIScopeForLLVMFuncOp.cpp.

References extractFileLoc(), mlir::Operation::getContext(), mlir::FileLineColLoc::getFilename(), mlir::Operation::getLoc(), getNestedLoc(), mlir::Operation::getParentOfType(), and mlir::Operation::setLoc().