-
Notifications
You must be signed in to change notification settings - Fork 162
[CIR] Fix parsing of a generic TBAAAttr #1846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ With the latest revision this PR passed the C/C++ code formatter. |
5833486
to
f246e76
Compare
I'm not sure I do, maybe @xlauko knows some tricks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after nits
We've had a side-channel discussion with @xlauko and I reworked the solution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks much nicer, thanks for the extra here. Few minor tweaks pending and LGTM
@@ -14,6 +14,7 @@ | |||
#define CLANG_CIR_DIALECT_IR_CIRTBAAATTRS_TD | |||
|
|||
include "clang/CIR/Dialect/IR/CIRTypes.td" | |||
include "clang/CIR/Dialect/IR/CIRAttrs.td" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is cyclic dependency CIRAttrs.td
include CIRTBAAAttrs.td
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I guess I will have to move CIR_Attr
to a different file then. I need this include to be able to generate the hpp/cpp for the constraint from CIR_AnyTBAAAttr
def CIR_TBAAAttrConstraint : AttrConstraint<CPred<"::cir::isTBAAAttr($_self)">>{ | ||
string cppType = "::mlir::Attribute"; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is literally the same as CIR_AnyTBAAAttr
. Why don't you use that everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the constraint is used in the definition of the TBAA Attributes and I can't define the CIR_AnyTBAAAttr
before the attributes are defined
This PR fixes an issue when parsing
TBAAAttr
derived attributes.The root cause of the issue is that the RTTI system is not capable of downcasting
mlir::Attribute
to theBaseType
, which iscir::TBAAAttr
, since each attribute has its unique TypeID. As such, the default generated parser fails, because thedyn_cast
tocir::TBAAAttr
fails (this happens for example with the attached test case).If anyone can think of a solution that wouldn't require explicitly listing all the attributes I'm happy to modify it.