[flang-commits] [flang] [flang][debug] Add support for common blocks. (PR #112398)
Abid Qadeer via flang-commits
flang-commits at lists.llvm.org
Thu Oct 17 06:31:21 PDT 2024
================
@@ -90,6 +105,67 @@ bool debugInfoIsAlreadySet(mlir::Location loc) {
} // namespace
+bool AddDebugInfoPass::createCommonBlockGlobal(
+ fir::cg::XDeclareOp declOp, const std::string &name,
+ mlir::LLVM::DIFileAttr fileAttr, mlir::LLVM::DIScopeAttr scopeAttr,
+ fir::DebugTypeGenerator &typeGen, mlir::SymbolTable *symbolTable) {
+ mlir::MLIRContext *context = &getContext();
+ mlir::OpBuilder builder(context);
+ std::optional<std::int64_t> optint;
+ auto op = declOp.getMemref().getDefiningOp();
+
+ if (auto conOp = mlir::dyn_cast_if_present<fir::ConvertOp>(op))
+ op = conOp.getValue().getDefiningOp();
+
+ if (auto cordOp = mlir::dyn_cast_if_present<fir::CoordinateOp>(op)) {
+ optint = fir::getIntIfConstant(cordOp.getOperand(1));
+ if (!optint)
+ return false;
+ op = cordOp.getRef().getDefiningOp();
+ if (auto conOp2 = mlir::dyn_cast_if_present<fir::ConvertOp>(op))
+ op = conOp2.getValue().getDefiningOp();
+
+ if (auto addrOfOp = mlir::dyn_cast_if_present<fir::AddrOfOp>(op)) {
+ auto sym = addrOfOp.getSymbol();
+ if (auto global =
+ symbolTable->lookup<fir::GlobalOp>(sym.getRootReference())) {
+
+ unsigned line = getLineFromLoc(global.getLoc());
+ std::string commonName(sym.getRootReference().str());
----------------
abidh wrote:
Thanks for the suggestion. I have used llvm::StringRef now.
https://github.com/llvm/llvm-project/pull/112398
More information about the flang-commits
mailing list