-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[CodeGen] Enhance inline asm constraint diagnostics #101354
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
This is a continuation of #96363. Here I want backends to provide additional information why a register can't be allocated. My points of concerns:
Hi @arsenm @RKSimon @efriedma-quic @phoebewang what do you think? Are there better ways to make backends more friendly in terms of diagnostics. This is a draft. When or if we agree with the approach, I'll cover all failures from |
@@ -2,7 +2,7 @@ | |||
; RUN: not llc -o /dev/null %s 2>&1 | FileCheck %s | |||
target triple = "x86_64-unknown-linux-gnu" | |||
|
|||
; CHECK: error: couldn't allocate input reg for constraint 'r' | |||
; CHECK: error: couldn't allocate input reg for constraint 'r': couldn't allocate for type v8i16 |
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.
Maybe we can be more specific? Something like "expected an integer, found v8i16"?
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 hard. To be precise and informative we need to name all the vector combinations that can fit in 128 bits in case of 'x' constraint and even naming is not simple, as we need to understand whether v8f16
is available or not to include it into the message. Or do you mean r
constraint in particular?
@@ -5034,7 +5034,8 @@ class TargetLowering : public TargetLoweringBase { | |||
/// returns a register number of 0 and a null register class pointer. | |||
virtual std::pair<unsigned, const TargetRegisterClass *> | |||
getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, | |||
StringRef Constraint, MVT VT) const; | |||
StringRef Constraint, MVT VT, | |||
std::string &ErrMsg) const; |
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.
Maybe SmallStringImpl&?
I don't really see how you can do much better than that; an error message is, ultimately, just a string, given we don't support translation or anything like that.
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.
Error or StringError?
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.
I like the idea of SmallString
. Error
and StringError
, they consist of std::string
and additionally have a return code that we don't have use of.
Ok, since there aren't strong points for using something like Expected
, I'll continue with returning an error message by reference.
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.
Out argument string message is a worse API. I would prefer to use one of the proper return with bundled error message options
No description provided.