[flang-commits] [flang] [flang] Initial debug info support for local variables. (PR #90905)
Abid Qadeer via flang-commits
flang-commits at lists.llvm.org
Fri May 3 09:49:53 PDT 2024
================
@@ -45,13 +46,44 @@ namespace fir {
namespace {
class AddDebugInfoPass : public fir::impl::AddDebugInfoBase<AddDebugInfoPass> {
+ void handleDeclareOp(fir::cg::XDeclareOp declOp,
+ mlir::LLVM::DIFileAttr fileAttr,
+ mlir::LLVM::DIScopeAttr scopeAttr,
+ fir::DebugTypeGenerator &typeGen, uint32_t &argNo);
+
public:
AddDebugInfoPass(fir::AddDebugInfoOptions options) : Base(options) {}
void runOnOperation() override;
};
+static uint32_t getLineFromLoc(mlir::Location loc) {
+ uint32_t line = 1;
+ if (auto fileLoc = mlir::dyn_cast<mlir::FileLineColLoc>(loc))
+ line = fileLoc.getLine();
+ return line;
+}
+
} // namespace
+void AddDebugInfoPass::handleDeclareOp(fir::cg::XDeclareOp declOp,
+ mlir::LLVM::DIFileAttr fileAttr,
+ mlir::LLVM::DIScopeAttr scopeAttr,
+ fir::DebugTypeGenerator &typeGen,
+ uint32_t &argNo) {
+ mlir::MLIRContext *context = &getContext();
+ mlir::OpBuilder builder(context);
+
+ bool isLocal = (declOp.getMemref().getDefiningOp() != nullptr);
+ auto tyAttr = typeGen.convertType(fir::unwrapRefType(declOp.getType()),
+ fileAttr, scopeAttr, declOp.getLoc());
+ auto result = fir::NameUniquer::deconstruct(declOp.getUniqName());
----------------
abidh wrote:
Thanks for the suggestion. Done now.
https://github.com/llvm/llvm-project/pull/90905
More information about the flang-commits
mailing list