[Mlir-commits] [mlir] [MLIR] Implement remark emitting policies in MLIR (PR #160526)

Bart Chrzaszcz llvmlistbot at llvm.org
Thu Sep 25 04:03:04 PDT 2025


bartchr808 wrote:

Here is the paste of what ubsan gives:

```
Details
/llvm-project/mlir/lib/IR/MLIRContext.cpp:435:24: runtime error: member access within null pointer of type 'mlir::MLIRContextImpl'
    #0 0x7f28446fb873 in mlir::MLIRContext::getLoadedDialects() /llvm-project/mlir/lib/IR/MLIRContext.cpp:435:24
    #1 0x7f284467b89c in mlir::detail::DialectInterfaceCollectionBase::DialectInterfaceCollectionBase(mlir::MLIRContext*, mlir::TypeID, llvm::StringRef) /llvm-project/mlir/lib/IR/Dialect.cpp:123:29
    #2 0x7f28445d9544 in DialectInterfaceCollection /llvm-project/mlir/include/mlir/IR/DialectInterface.h:163:9
    #3 0x7f28445d9544 in mlir::detail::AsmStateImpl::AsmStateImpl(mlir::MLIRContext*, mlir::OpPrintingFlags const&, llvm::DenseMap<mlir::Operation*, std::__u::pair<unsigned int, unsigned int>, llvm::DenseMapInfo<mlir::Operation*, void>, llvm::detail::DenseMapPair<mlir::Operation*, std::__u::pair<unsigned int, unsigned int>>>*) /llvm-project/mlir/lib/IR/AsmPrinter.cpp:1952:9
    #4 0x7f28445a8c54 in make_unique<mlir::detail::AsmStateImpl, mlir::MLIRContext *&, const mlir::OpPrintingFlags &, llvm::DenseMap<mlir::Operation *, std::__u::pair<unsigned int, unsigned int>, llvm::DenseMapInfo<mlir::Operation *, void>, llvm::detail::DenseMapPair<mlir::Operation *, std::__u::pair<unsigned int, unsigned int> > > *&, 0> third_party/crosstool/v18/stable/src/libcxx/include/__memory/unique_ptr.h:759:30
    #5 0x7f28445a8c54 in mlir::AsmState::AsmState(mlir::MLIRContext*, mlir::OpPrintingFlags const&, llvm::DenseMap<mlir::Operation*, std::__u::pair<unsigned int, unsigned int>, llvm::DenseMapInfo<mlir::Operation*, void>, llvm::detail::DenseMapPair<mlir::Operation*, std::__u::pair<unsigned int, unsigned int>>>*, mlir::FallbackAsmResourceMap*) /llvm-project/mlir/lib/IR/AsmPrinter.cpp:2090:12
    #6 0x7f28445b20c9 in mlir::Attribute::print(llvm::raw_ostream&, bool) const /llvm-project/mlir/lib/IR/AsmPrinter.cpp:3940:12
    #7 0x7f284473138a in operator<< /llvm-project/mlir/include/mlir/IR/Attributes.h:151:8
    #8 0x7f284473138a in mlir::remark::detail::Remark::print(llvm::raw_ostream&, bool) const /llvm-project/mlir/lib/IR/Remarks.cpp:86:10
    #9 0x7f286f0221fa in (anonymous namespace)::MyCustomStreamer::streamOptimizationRemark(mlir::remark::detail::Remark const&) /llvm-project/mlir/unittests/IR/RemarkTest.cpp:262:12
    #10 0x7f2844732b77 in mlir::remark::detail::RemarkEngine::reportImpl(mlir::remark::detail::Remark const&) /llvm-project/mlir/lib/IR/Remarks.cpp:236:21
    #11 0x7f2844738c26 in operator() /llvm-project/mlir/lib/IR/Remarks.cpp:316:53
    #12 0x7f2844738c26 in void llvm::detail::UniqueFunctionBase<void, mlir::remark::detail::Remark const&>::CallImpl<mlir::remark::detail::RemarkEngine::initialize(std::__u::unique_ptr<mlir::remark::detail::MLIRRemarkStreamerBase, std::__u::default_delete<mlir::remark::detail::MLIRRemarkStreamerBase>>, std::__u::unique_ptr<mlir::remark::detail::RemarkEmittingPolicyBase, std::__u::default_delete<mlir::remark::detail::RemarkEmittingPolicyBase>>, std::__u::basic_string<char, std::__u::char_traits<char>, std::__u::allocator<char>>*)::$_0>(void*, mlir::remark::detail::Remark const&) /llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:214:12
    #13 0x7f2844733a29 in operator() /llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:366:12
    #14 0x7f2844733a29 in mlir::remark::RemarkEmittingPolicyFinal::finalize() /llvm-project/mlir/include/mlir/IR/Remarks.h:520:7
    #15 0x7f2844732cc3 in mlir::remark::detail::RemarkEngine::~RemarkEngine() /llvm-project/mlir/lib/IR/Remarks.cpp:250:27
    #16 0x7f284470385c in operator() third_party/crosstool/v18/stable/src/libcxx/include/__memory/unique_ptr.h:77:5
    #17 0x7f284470385c in reset third_party/crosstool/v18/stable/src/libcxx/include/__memory/unique_ptr.h:290:7
    #18 0x7f284470385c in mlir::MLIRContextImpl::~MLIRContextImpl() /llvm-project/mlir/lib/IR/MLIRContext.cpp:282:18
    #19 0x7f28446fb2b0 in operator() third_party/crosstool/v18/stable/src/libcxx/include/__memory/unique_ptr.h:77:5
    #20 0x7f28446fb2b0 in reset third_party/crosstool/v18/stable/src/libcxx/include/__memory/unique_ptr.h:290:7
    #21 0x7f28446fb2b0 in ~unique_ptr third_party/crosstool/v18/stable/src/libcxx/include/__memory/unique_ptr.h:259:71
    #22 0x7f28446fb2b0 in mlir::MLIRContext::~MLIRContext() /llvm-project/mlir/lib/IR/MLIRContext.cpp:362:27
    #23 0x7f286f022942 in (anonymous namespace)::Remark_TestRemarkFinal_Test::TestBody() /llvm-project/mlir/unittests/IR/RemarkTest.cpp:375:3

SUMMARY: UndefinedBehaviorSanitizer: null-pointer-use /llvm-project/mlir/lib/IR/MLIRContext.cpp:435:24  (///llvm-project/mlir/unittests:ir_tests)
```

Specifically in `Remarks.cpp` it seems `os << flc.getFilename()` is what is failing.

https://github.com/llvm/llvm-project/pull/160526


More information about the Mlir-commits mailing list