Propagating certain debug info attributes using location info?

Hi all,
I’ve run into a, perhaps, fairly common issue of propagating external/discardable attributes on operations through different compiler transformations.

For now, I need to propagate just a single piece of information (very similar to a unit attribute) and I was thinking about using location info on ops to do that, so that I don’t have to manually make sure this single piece gets dropped.

Specifically, I was thinking of using FusedLoc or OpaqueLoc. It would be a misuse of those constructs but I wanted to get a second opinion on whether it would be a bad idea to do this.

Locations are discardable as well, but probably better preserved by default. This will still be best effort so you need to be ready for a degradation of the information throughout the compiler.

+1 to what Mehdi said, but also now you can define your own location attribute if you want :slight_smile: see [mlir] Add the ability to define dialect-specific location attrs. by bzcheeseman · Pull Request #105584 · llvm/llvm-project · GitHub - there’s an example in the test dialect