[PATCH] D107141: [Inline-asm] Add semacheck for unsupported constraint
Pengfei Wang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 2 07:33:05 PDT 2021
pengfei added a comment.
@jyu2, Thanks for the detailed information.
> Besides, if we change "=rm" to "=r"
> or "=m", GCC and ICC will report error differently. Which gives me an
> impression that the use of constraint is undefined behavior.
> To me it is defined behavior. Or I may missing some thing here.
Sorry, I didn't describe it clearly. I meant it's ub when they are used together with structure type. E.g., https://godbolt.org/z/ssY5K4xEP
As you can see, when we use "=rm", GCC and ICC happen to work, that's because GCC only allows the structure to be passed on register with ICC only allows memory. I didn't find a document which describes the relationships between structure and its output constraint.
Besides, https://godbolt.org/z/5ex9x3dvv shows GCC and ICC have some rules when we passing a structure (Adding one more element in the exapmles will fail on both GCC and ICC). I didn't find the document either.
> code doesn't make much sense to me.
This patch doesn't change any functionality of Clang. We just adding more sema checks to avoid the ugly crash. This is required from our user.
I believe we can do more things to march the behavior of GCC and ICC. I have added a FIXME in the code. Considering we don't have a clear document and such a case is in rare. And we don't have such requirment from user. I think this patch is till better than none.
Does it make sense?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107141/new/
https://reviews.llvm.org/D107141
More information about the cfe-commits
mailing list