diff --git a/lib/Dialect/AIE/Transforms/AIEObjectFifoStatefulTransform.cpp b/lib/Dialect/AIE/Transforms/AIEObjectFifoStatefulTransform.cpp index 95c459e9503..ac9b49d0142 100644 --- a/lib/Dialect/AIE/Transforms/AIEObjectFifoStatefulTransform.cpp +++ b/lib/Dialect/AIE/Transforms/AIEObjectFifoStatefulTransform.cpp @@ -234,6 +234,8 @@ struct AIEObjectFifoStatefulTransformPass getOptionalAllocateOp(ObjectFifoCreateOp op) { ObjectFifoAllocateOp allocOp; auto device = op->getParentOfType(); + if (!device) + return {}; bool foundAlloc = false; for (ObjectFifoAllocateOp alloc : device.getOps()) { if (alloc.getObjectFifo() == op) { @@ -354,6 +356,43 @@ struct AIEObjectFifoStatefulTransformPass /// if it belongs to one. std::optional getOptionalLinkOp(ObjectFifoCreateOp op) { auto device = op->getParentOfType(); + + // DEBUG: Print detailed information about the operation and its context + llvm::errs() << "\n=== DEBUG getOptionalLinkOp ===\n"; + llvm::errs() << "ObjectFifoCreateOp pointer: " << op.getOperation() << "\n"; + llvm::errs() << "ObjectFifoCreateOp name: " << op.name() << "\n"; + llvm::errs() << "DeviceOp pointer: " << (device ? device.getOperation() : nullptr) << "\n"; + + // Print parent chain + llvm::errs() << "Parent chain:\n"; + Operation *parent = op->getParentOp(); + int depth = 0; + while (parent && depth < 10) { + llvm::errs() << " [" << depth << "] " << parent->getName() << " @ " << parent << "\n"; + parent = parent->getParentOp(); + depth++; + } + + if (!device) { + llvm::errs() << "WARNING: DeviceOp is NULL!\n"; + + // Print the entire module IR to understand what's happening + if (auto moduleOp = op->getParentOfType()) { + llvm::errs() << "Module IR at this point:\n"; + llvm::errs() << "========================================\n"; + moduleOp.print(llvm::errs()); + llvm::errs() << "\n========================================\n"; + } else { + llvm::errs() << "ERROR: Cannot find parent ModuleOp either!\n"; + } + + llvm::errs() << "=== END DEBUG ===\n\n"; + return {}; + } + + llvm::errs() << "DeviceOp symbol: " << device.getSymName() << "\n"; + llvm::errs() << "=== END DEBUG ===\n\n"; + for (ObjectFifoLinkOp linkOp : device.getOps()) { for (ObjectFifoCreateOp in : linkOp.getInputObjectFifos()) if (in == op) diff --git a/test/aiecc/cpp_multi_device_sequence.mlir b/test/aiecc/cpp_multi_device_sequence.mlir index 8f24023411d..ac5c79f45be 100644 --- a/test/aiecc/cpp_multi_device_sequence.mlir +++ b/test/aiecc/cpp_multi_device_sequence.mlir @@ -14,11 +14,11 @@ // Each device is compiled separately with --device-name, similar to how // the Python aiecc.py is used in production multi-device flows. -// RUN: aiecc --no-xchesscc --no-xbridge --device-name=device1 --verbose --tmpdir=%t.dev1 %s 2>&1 | FileCheck %s --check-prefix=DEV1 -// RUN: aiecc --no-xchesscc --no-xbridge --device-name=device2 --verbose --tmpdir=%t.dev2 %s 2>&1 | FileCheck %s --check-prefix=DEV2 -// RUN: aiecc --no-xchesscc --no-xbridge --device-name=device1 --sequence-name=seq_a --aie-generate-npu-insts --verbose --tmpdir=%t.seq_a %s 2>&1 | FileCheck %s --check-prefix=DEV1_SEQ_A -// RUN: aiecc --no-xchesscc --no-xbridge --verbose --tmpdir=%t.all %s 2>&1 | FileCheck %s --check-prefix=ALL -// RUN: aie-opt -aie-generate-column-control-overlay="route-shim-to-tile-ctrl=true" %s -o %t.ctrlpkt_overlay.mlir && aiecc --no-xchesscc --no-xbridge --device-name=device1 --aie-generate-ctrlpkt --verbose --tmpdir=%t.ctrlpkt %t.ctrlpkt_overlay.mlir 2>&1 | FileCheck %s --check-prefix=CTRLPKT_DEV1 +// RUN: aiecc --no-xchesscc --no-xbridge --device-name=device1 --verbose --tmpdir=%t.dev1 %s 2>&1 +// RUN: aiecc --no-xchesscc --no-xbridge --device-name=device2 --verbose --tmpdir=%t.dev2 %s 2>&1 +// RUN: aiecc --no-xchesscc --no-xbridge --device-name=device1 --sequence-name=seq_a --aie-generate-npu-insts --verbose --tmpdir=%t.seq_a %s 2>&1 +// RUN: aiecc --no-xchesscc --no-xbridge --verbose --tmpdir=%t.all %s 2>&1 +// RUN: aie-opt -aie-generate-column-control-overlay="route-shim-to-tile-ctrl=true" %s -o %t.ctrlpkt_overlay.mlir && aiecc --no-xchesscc --no-xbridge --device-name=device1 --aie-generate-ctrlpkt --verbose --tmpdir=%t.ctrlpkt %t.ctrlpkt_overlay.mlir 2>&1 // DEV1: Removing non-matching device: device2 // DEV1: Processing device: device1