[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 18:40:35 PDT 2021


pengfei added a comment.

> First I did not say "code doesn't make much sense to me". This is copy form your description.

Oop, my bad understanding. :)

> both gcc and icc generated code is not making sense to you.

Yes. Unless there's document to specify the behavior clearly.

> So instead, you want clang give error for this when output size greater than input size.

Giving error only when output size greater than input size and output type is not one of the 3 cases in CGStmt.cpp:2480. I.e.: `OutputDomain != AD_Other || OutSize <= InSize`. Otherwise, Clang will crash there.

> What about input size greater than output size? It seems the error already emit for that case in Sema. Should also handle the same with your case in Sema?

Sema emits error when 1) `InputDomain != AD_Other` 2) Output is mentioned and `OutSize < InSize`. So input size is allow to be greater than output size only when output is not mentioned. I don't fully understand the code in CGStmt.cpp, but according to comment in line 2463, it seems only larger output result needs to be handled.



================
Comment at: clang/lib/Sema/SemaStmtAsm.cpp:670
+        OutputConstraintInfos[TiedTo].allowsRegister() &&
+        (OutputDomain != AD_Other || OutSize <= InSize))
       continue;
----------------
jyu2 wrote:
> Why not emit error in here?
Actually, adding this condition will let it fall through and emit error at line 688.


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