[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
shafik wrote: I just realized it was already merged https://github.com/llvm/llvm-project/pull/119098 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/shafik commented: Thank you for the fix. Please add a more detailed summary, these are important since they go into the git log and can be important for debugging downstream breaks. Something like "Fix by adding check in ActOnGCCAsmStmt that the domains of the input and output match and reject if not" or something along those lines. https://github.com/llvm/llvm-project/pull/119098 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
github-actions[bot] wrote: @AdUhTkJm Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/119098 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/arsenm closed https://github.com/llvm/llvm-project/pull/119098 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/119098 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/119098 >From 56670608becf2032867405778fa7b2b1a36fb3cf Mon Sep 17 00:00:00 2001 From: AdUhTkJm <[email protected]> Date: Sun, 8 Dec 2024 08:07:59 +0800 Subject: [PATCH] [Clang] Fix crash for incompatible types in inline assembly --- clang/lib/Sema/SemaStmtAsm.cpp | 7 ++- clang/test/Sema/asm.c | 21 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 0b272b806391c4..a0b203fbdfec21 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -664,11 +664,16 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, SmallerValueMentioned |= OutSize < InSize; } +// If the input is an integer register while the output is floating point, +// or vice-versa, there is no way they can work together. +bool FPTiedToInt = (InputDomain == AD_FP) ^ (OutputDomain == AD_FP); + // If the smaller value wasn't mentioned in the asm string, and if the // output was a register, just extend the shorter one to the size of the // larger one. -if (!SmallerValueMentioned && InputDomain != AD_Other && +if (!SmallerValueMentioned && !FPTiedToInt && InputDomain != AD_Other && OutputConstraintInfos[TiedTo].allowsRegister()) { + // FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen // crash when the size larger than the register size. So we limit it here. if (OutTy->isStructureType() && diff --git a/clang/test/Sema/asm.c b/clang/test/Sema/asm.c index a9cff5947ef5d0..a666b45b3150ca 100644 --- a/clang/test/Sema/asm.c +++ b/clang/test/Sema/asm.c @@ -365,3 +365,24 @@ void test19(long long x) // FIXME: This case should be supported by codegen, but it fails now. asm ("" : "=rm" (x): "0" (e)); // expected-error {{unsupported inline asm: input with type 'st_size128' (aka 'struct _st_size128') matching output with type 'long long'}} } + +typedef int int2 __attribute__((ext_vector_type(2))); + +// GH118892 +void test20(char x) { + double d; + float f; + + asm ("fabs" : "=t" (d): "0" (x)); // expected-error {{unsupported inline asm: input with type 'char' matching output with type 'double'}} + asm ("fabs" : "=t" (x): "0" (d)); // expected-error {{unsupported inline asm: input with type 'double' matching output with type 'char'}} + asm ("fabs" : "=t" (f): "0" (d)); // no-error + asm ("fabs" : "=t" (d): "0" (f)); // no-error + + st_size64 a; + asm ("fabs" : "=t" (d): "0" (a)); // expected-error {{unsupported inline asm: input with type 'st_size64' (aka 'struct _st_size64') matching output with type 'double'}} + asm ("fabs" : "=t" (a): "0" (d)); // expected-error {{unsupported inline asm: input with type 'double' matching output with type 'st_size64' (aka 'struct _st_size64')}} + + int2 v; + asm ("fabs" : "=t" (d): "0" (v)); // expected-error {{unsupported inline asm: input with type 'int2' (vector of 2 'int' values) matching output with type 'double'}} + asm ("fabs" : "=t" (v): "0" (d)); // expected-error {{unsupported inline asm: input with type 'double' matching output with type 'int2' (vector of 2 'int' values)}} +} ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
@@ -365,3 +365,9 @@ void test19(long long x)
// FIXME: This case should be supported by codegen, but it fails now.
asm ("" : "=rm" (x): "0" (e)); // expected-error {{unsupported inline asm:
input with type 'st_size128' (aka 'struct _st_size128') matching output with
type 'long long'}}
}
+
+// GH118892
+void test20(char x) {
+ double value;
+ asm ("fabs" : "=t" (value): "0" (x)); // expected-error {{unsupported inline
asm: input with type 'char' matching output with type 'double'}}
+}
AdUhTkJm wrote:
Added.
https://github.com/llvm/llvm-project/pull/119098
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
@@ -664,11 +664,22 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc,
bool IsSimple,
SmallerValueMentioned |= OutSize < InSize;
}
+// If the input is an integer register while the output is floating point,
+// there is no way they can work together.
+bool FPBoundToInt = false;
+if (InputDomain != AD_FP && OutputDomain == AD_FP) {
+ FPBoundToInt = true;
+}
+if (InputDomain == AD_FP && OutputDomain != AD_FP) {
+ FPBoundToInt = true;
+}
AdUhTkJm wrote:
Done.
https://github.com/llvm/llvm-project/pull/119098
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/119098 >From 56670608becf2032867405778fa7b2b1a36fb3cf Mon Sep 17 00:00:00 2001 From: AdUhTkJm <[email protected]> Date: Sun, 8 Dec 2024 08:07:59 +0800 Subject: [PATCH] [Clang] Fix crash for incompatible types in inline assembly --- clang/lib/Sema/SemaStmtAsm.cpp | 7 ++- clang/test/Sema/asm.c | 21 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 0b272b806391c4..a0b203fbdfec21 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -664,11 +664,16 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, SmallerValueMentioned |= OutSize < InSize; } +// If the input is an integer register while the output is floating point, +// or vice-versa, there is no way they can work together. +bool FPTiedToInt = (InputDomain == AD_FP) ^ (OutputDomain == AD_FP); + // If the smaller value wasn't mentioned in the asm string, and if the // output was a register, just extend the shorter one to the size of the // larger one. -if (!SmallerValueMentioned && InputDomain != AD_Other && +if (!SmallerValueMentioned && !FPTiedToInt && InputDomain != AD_Other && OutputConstraintInfos[TiedTo].allowsRegister()) { + // FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen // crash when the size larger than the register size. So we limit it here. if (OutTy->isStructureType() && diff --git a/clang/test/Sema/asm.c b/clang/test/Sema/asm.c index a9cff5947ef5d0..a666b45b3150ca 100644 --- a/clang/test/Sema/asm.c +++ b/clang/test/Sema/asm.c @@ -365,3 +365,24 @@ void test19(long long x) // FIXME: This case should be supported by codegen, but it fails now. asm ("" : "=rm" (x): "0" (e)); // expected-error {{unsupported inline asm: input with type 'st_size128' (aka 'struct _st_size128') matching output with type 'long long'}} } + +typedef int int2 __attribute__((ext_vector_type(2))); + +// GH118892 +void test20(char x) { + double d; + float f; + + asm ("fabs" : "=t" (d): "0" (x)); // expected-error {{unsupported inline asm: input with type 'char' matching output with type 'double'}} + asm ("fabs" : "=t" (x): "0" (d)); // expected-error {{unsupported inline asm: input with type 'double' matching output with type 'char'}} + asm ("fabs" : "=t" (f): "0" (d)); // no-error + asm ("fabs" : "=t" (d): "0" (f)); // no-error + + st_size64 a; + asm ("fabs" : "=t" (d): "0" (a)); // expected-error {{unsupported inline asm: input with type 'st_size64' (aka 'struct _st_size64') matching output with type 'double'}} + asm ("fabs" : "=t" (a): "0" (d)); // expected-error {{unsupported inline asm: input with type 'double' matching output with type 'st_size64' (aka 'struct _st_size64')}} + + int2 v; + asm ("fabs" : "=t" (d): "0" (v)); // expected-error {{unsupported inline asm: input with type 'int2' (vector of 2 'int' values) matching output with type 'double'}} + asm ("fabs" : "=t" (v): "0" (d)); // expected-error {{unsupported inline asm: input with type 'double' matching output with type 'int2' (vector of 2 'int' values)}} +} ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/119098 >From 56670608becf2032867405778fa7b2b1a36fb3cf Mon Sep 17 00:00:00 2001 From: AdUhTkJm <[email protected]> Date: Sun, 8 Dec 2024 08:07:59 +0800 Subject: [PATCH] [Clang] Fix crash for incompatible types in inline assembly --- clang/lib/Sema/SemaStmtAsm.cpp | 7 ++- clang/test/Sema/asm.c | 21 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 0b272b806391c4..a0b203fbdfec21 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -664,11 +664,16 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, SmallerValueMentioned |= OutSize < InSize; } +// If the input is an integer register while the output is floating point, +// or vice-versa, there is no way they can work together. +bool FPTiedToInt = (InputDomain == AD_FP) ^ (OutputDomain == AD_FP); + // If the smaller value wasn't mentioned in the asm string, and if the // output was a register, just extend the shorter one to the size of the // larger one. -if (!SmallerValueMentioned && InputDomain != AD_Other && +if (!SmallerValueMentioned && !FPTiedToInt && InputDomain != AD_Other && OutputConstraintInfos[TiedTo].allowsRegister()) { + // FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen // crash when the size larger than the register size. So we limit it here. if (OutTy->isStructureType() && diff --git a/clang/test/Sema/asm.c b/clang/test/Sema/asm.c index a9cff5947ef5d0..a666b45b3150ca 100644 --- a/clang/test/Sema/asm.c +++ b/clang/test/Sema/asm.c @@ -365,3 +365,24 @@ void test19(long long x) // FIXME: This case should be supported by codegen, but it fails now. asm ("" : "=rm" (x): "0" (e)); // expected-error {{unsupported inline asm: input with type 'st_size128' (aka 'struct _st_size128') matching output with type 'long long'}} } + +typedef int int2 __attribute__((ext_vector_type(2))); + +// GH118892 +void test20(char x) { + double d; + float f; + + asm ("fabs" : "=t" (d): "0" (x)); // expected-error {{unsupported inline asm: input with type 'char' matching output with type 'double'}} + asm ("fabs" : "=t" (x): "0" (d)); // expected-error {{unsupported inline asm: input with type 'double' matching output with type 'char'}} + asm ("fabs" : "=t" (f): "0" (d)); // no-error + asm ("fabs" : "=t" (d): "0" (f)); // no-error + + st_size64 a; + asm ("fabs" : "=t" (d): "0" (a)); // expected-error {{unsupported inline asm: input with type 'st_size64' (aka 'struct _st_size64') matching output with type 'double'}} + asm ("fabs" : "=t" (a): "0" (d)); // expected-error {{unsupported inline asm: input with type 'double' matching output with type 'st_size64' (aka 'struct _st_size64')}} + + int2 v; + asm ("fabs" : "=t" (d): "0" (v)); // expected-error {{unsupported inline asm: input with type 'int2' (vector of 2 'int' values) matching output with type 'double'}} + asm ("fabs" : "=t" (v): "0" (d)); // expected-error {{unsupported inline asm: input with type 'double' matching output with type 'int2' (vector of 2 'int' values)}} +} ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/119098 >From 37b8121ea94fa5fd6ec275caf5984f18f25ba081 Mon Sep 17 00:00:00 2001 From: AdUhTkJm <[email protected]> Date: Sun, 8 Dec 2024 08:07:59 +0800 Subject: [PATCH] [Clang] Fix crash for incompatible types in inline assembly --- clang/lib/Sema/SemaStmtAsm.cpp | 7 ++- clang/test/Sema/asm.c | 21 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 0b272b806391c4..a0b203fbdfec21 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -664,11 +664,16 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, SmallerValueMentioned |= OutSize < InSize; } +// If the input is an integer register while the output is floating point, +// or vice-versa, there is no way they can work together. +bool FPTiedToInt = (InputDomain == AD_FP) ^ (OutputDomain == AD_FP); + // If the smaller value wasn't mentioned in the asm string, and if the // output was a register, just extend the shorter one to the size of the // larger one. -if (!SmallerValueMentioned && InputDomain != AD_Other && +if (!SmallerValueMentioned && !FPTiedToInt && InputDomain != AD_Other && OutputConstraintInfos[TiedTo].allowsRegister()) { + // FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen // crash when the size larger than the register size. So we limit it here. if (OutTy->isStructureType() && diff --git a/clang/test/Sema/asm.c b/clang/test/Sema/asm.c index a9cff5947ef5d0..88f85bc3ed9720 100644 --- a/clang/test/Sema/asm.c +++ b/clang/test/Sema/asm.c @@ -365,3 +365,24 @@ void test19(long long x) // FIXME: This case should be supported by codegen, but it fails now. asm ("" : "=rm" (x): "0" (e)); // expected-error {{unsupported inline asm: input with type 'st_size128' (aka 'struct _st_size128') matching output with type 'long long'}} } + +typedef int int2 __attribute__((ext_vector_type(2))); + +// GH118892 +void test20(char x) { + double d; + float f; + + asm ("fabs" : "=t" (d): "0" (x)); // expected-error {{unsupported inline asm: input with type 'char' matching output with type 'double'}} + asm ("fabs" : "=t" (x): "0" (d)); // expected-error {{unsupported inline asm: input with type 'double' matching output with type 'char'}} + asm ("fabs" : "=t" (f): "0" (d)); // no-error + asm ("fabs" : "=t" (d): "0" (f)); // no-error + + st_size64 a; + asm ("fabs" : "=t" (d): "0" (a)); // expected-error {{unsupported inline asm: input with type 'st_size64' (aka 'struct _st_size64') matching output with type 'double'}} + asm ("fabs" : "=t" (a): "0" (d)); // expected-error {{unsupported inline asm: input with type 'double' matching output with type 'st_size64' (aka 'struct _st_size64')}} + + int2 v; + asm ("fabs" : "=t" (d): "0" (v)); // expected-error {{error: unsupported inline asm: input with type 'int2' (vector of 2 'int' values) matching output with type 'double'}} + asm ("fabs" : "=t" (v): "0" (d)); // expected-error {{unsupported inline asm: input with type 'double' matching output with type 'int2' (vector of 2 'int' values)}} +} ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
@@ -664,11 +664,22 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc,
bool IsSimple,
SmallerValueMentioned |= OutSize < InSize;
}
+// If the input is an integer register while the output is floating point,
+// there is no way they can work together.
+bool FPBoundToInt = false;
+if (InputDomain != AD_FP && OutputDomain == AD_FP) {
+ FPBoundToInt = true;
+}
+if (InputDomain == AD_FP && OutputDomain != AD_FP) {
+ FPBoundToInt = true;
+}
arsenm wrote:
This should be an initialization expression
https://github.com/llvm/llvm-project/pull/119098
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
@@ -365,3 +365,9 @@ void test19(long long x)
// FIXME: This case should be supported by codegen, but it fails now.
asm ("" : "=rm" (x): "0" (e)); // expected-error {{unsupported inline asm:
input with type 'st_size128' (aka 'struct _st_size128') matching output with
type 'long long'}}
}
+
+// GH118892
+void test20(char x) {
+ double value;
+ asm ("fabs" : "=t" (value): "0" (x)); // expected-error {{unsupported inline
asm: input with type 'char' matching output with type 'double'}}
+}
arsenm wrote:
No, I mean like int2 `typedef int int2 __attribute__((ext_vector_type(2)))`
https://github.com/llvm/llvm-project/pull/119098
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
@@ -365,3 +365,9 @@ void test19(long long x)
// FIXME: This case should be supported by codegen, but it fails now.
asm ("" : "=rm" (x): "0" (e)); // expected-error {{unsupported inline asm:
input with type 'st_size128' (aka 'struct _st_size128') matching output with
type 'long long'}}
}
+
+// GH118892
+void test20(char x) {
+ double value;
+ asm ("fabs" : "=t" (value): "0" (x)); // expected-error {{unsupported inline
asm: input with type 'char' matching output with type 'double'}}
+}
AdUhTkJm wrote:
Not sure about vectors (is it `std::vector`)? I'll add test against structs and
floats.
https://github.com/llvm/llvm-project/pull/119098
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/119098 >From 63d966fddaef45f12610274e9e606ba70039f87c Mon Sep 17 00:00:00 2001 From: AdUhTkJm <[email protected]> Date: Sun, 8 Dec 2024 08:07:59 +0800 Subject: [PATCH] [Clang] Fix crash for incompatible types in inline assembly --- clang/lib/Sema/SemaStmtAsm.cpp | 13 - clang/test/Sema/asm.c | 14 ++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 0b272b806391c4..a28ce204446bbf 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -664,11 +664,22 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, SmallerValueMentioned |= OutSize < InSize; } +// If the input is an integer register while the output is floating point, +// there is no way they can work together. +bool FPTiedToInt = false; +if (InputDomain != AD_FP && OutputDomain == AD_FP) { + FPTiedToInt = true; +} +if (InputDomain == AD_FP && OutputDomain != AD_FP) { + FPTiedToInt = true; +} + // If the smaller value wasn't mentioned in the asm string, and if the // output was a register, just extend the shorter one to the size of the // larger one. -if (!SmallerValueMentioned && InputDomain != AD_Other && +if (!SmallerValueMentioned && !FPTiedToInt && InputDomain != AD_Other && OutputConstraintInfos[TiedTo].allowsRegister()) { + // FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen // crash when the size larger than the register size. So we limit it here. if (OutTy->isStructureType() && diff --git a/clang/test/Sema/asm.c b/clang/test/Sema/asm.c index a9cff5947ef5d0..d7201aa7f224aa 100644 --- a/clang/test/Sema/asm.c +++ b/clang/test/Sema/asm.c @@ -365,3 +365,17 @@ void test19(long long x) // FIXME: This case should be supported by codegen, but it fails now. asm ("" : "=rm" (x): "0" (e)); // expected-error {{unsupported inline asm: input with type 'st_size128' (aka 'struct _st_size128') matching output with type 'long long'}} } + +// GH118892 +void test20(char x) { + double d; + float f; + asm ("fabs" : "=t" (d): "0" (x)); // expected-error {{unsupported inline asm: input with type 'char' matching output with type 'double'}} + asm ("fabs" : "=t" (x): "0" (d)); // expected-error {{unsupported inline asm: input with type 'double' matching output with type 'char'}} + asm ("fabs" : "=t" (f): "0" (d)); // no-error + asm ("fabs" : "=t" (d): "0" (f)); // no-error + + st_size64 a; + asm ("fabs" : "=t" (d): "0" (a)); // expected-error {{unsupported inline asm: input with type 'st_size64' (aka 'struct _st_size64') matching output with type 'double'}} + asm ("fabs" : "=t" (a): "0" (d)); // expected-error {{unsupported inline asm: input with type 'double' matching output with type 'st_size64' (aka 'struct _st_size64')}} +} ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
@@ -664,11 +664,22 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc,
bool IsSimple,
SmallerValueMentioned |= OutSize < InSize;
}
+// If the input is an integer register while the output is floating point,
+// there is no way they can work together.
+bool FPBoundToInt = false;
+if (InputDomain != AD_FP && OutputDomain == AD_FP) {
+ FPBoundToInt = true;
+}
+if (InputDomain == AD_FP && OutputDomain != AD_FP) {
+ FPBoundToInt = true;
+}
AdUhTkJm wrote:
I think this might be clearer than expressions like `(InputDomain == AD_FP) ^
(OutputDomain == AD_FP)`. By the way the previous parts uses "Tied", so I think
I'd change it this way.
https://github.com/llvm/llvm-project/pull/119098
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/119098 >From 902de28b3d37c0255d6ba59c1155b8ffb0e2d42e Mon Sep 17 00:00:00 2001 From: AdUhTkJm <[email protected]> Date: Sun, 8 Dec 2024 08:07:59 +0800 Subject: [PATCH] [Clang] Fix crash for incompatible types in inline assembly --- clang/lib/Sema/SemaStmtAsm.cpp | 13 - clang/test/Sema/asm.c | 6 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 0b272b806391c4..770b59d0c3ebfa 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -664,11 +664,22 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, SmallerValueMentioned |= OutSize < InSize; } +// If the input is an integer register while the output is floating point, +// there is no way they can work together. +bool FPBoundToInt = false; +if (InputDomain != AD_FP && OutputDomain == AD_FP) { + FPBoundToInt = true; +} +if (InputDomain == AD_FP && OutputDomain != AD_FP) { + FPBoundToInt = true; +} + // If the smaller value wasn't mentioned in the asm string, and if the // output was a register, just extend the shorter one to the size of the // larger one. -if (!SmallerValueMentioned && InputDomain != AD_Other && +if (!SmallerValueMentioned && !FPBoundToInt && InputDomain != AD_Other && OutputConstraintInfos[TiedTo].allowsRegister()) { + // FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen // crash when the size larger than the register size. So we limit it here. if (OutTy->isStructureType() && diff --git a/clang/test/Sema/asm.c b/clang/test/Sema/asm.c index a9cff5947ef5d0..4fa7e6bafaf635 100644 --- a/clang/test/Sema/asm.c +++ b/clang/test/Sema/asm.c @@ -365,3 +365,9 @@ void test19(long long x) // FIXME: This case should be supported by codegen, but it fails now. asm ("" : "=rm" (x): "0" (e)); // expected-error {{unsupported inline asm: input with type 'st_size128' (aka 'struct _st_size128') matching output with type 'long long'}} } + +// GH118892 +void test20(char x) { + double value; + asm ("fabs" : "=t" (value): "0" (x)); // expected-error {{unsupported inline asm: input with type 'char' matching output with type 'double'}} +} ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
@@ -365,3 +365,9 @@ void test19(long long x)
// FIXME: This case should be supported by codegen, but it fails now.
asm ("" : "=rm" (x): "0" (e)); // expected-error {{unsupported inline asm:
input with type 'st_size128' (aka 'struct _st_size128') matching output with
type 'long long'}}
}
+
+// PR119098
+void test20(char x) {
+ double value;
+ asm ("fabs" : "=t" (value): "0" (x)); // expected-error {{unsupported inline
asm: input with type 'char' matching output with type 'double'}}
+}
zwuis wrote:
nit: add a new line character at EOF
https://github.com/llvm/llvm-project/pull/119098
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
@@ -365,3 +365,9 @@ void test19(long long x)
// FIXME: This case should be supported by codegen, but it fails now.
asm ("" : "=rm" (x): "0" (e)); // expected-error {{unsupported inline asm:
input with type 'st_size128' (aka 'struct _st_size128') matching output with
type 'long long'}}
}
+
+// PR119098
zwuis wrote:
```suggestion
// GH118892
```
https://github.com/llvm/llvm-project/pull/119098
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/119098 >From 9780af34b63423344783ece5e8ec89de5b815c7f Mon Sep 17 00:00:00 2001 From: AdUhTkJm <[email protected]> Date: Sun, 8 Dec 2024 08:07:59 +0800 Subject: [PATCH] [Clang] Fix crash for incompatible types in inline assembly --- clang/lib/Sema/SemaStmtAsm.cpp | 13 - clang/test/Sema/asm.c | 6 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 0b272b806391c4..770b59d0c3ebfa 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -664,11 +664,22 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, SmallerValueMentioned |= OutSize < InSize; } +// If the input is an integer register while the output is floating point, +// there is no way they can work together. +bool FPBoundToInt = false; +if (InputDomain != AD_FP && OutputDomain == AD_FP) { + FPBoundToInt = true; +} +if (InputDomain == AD_FP && OutputDomain != AD_FP) { + FPBoundToInt = true; +} + // If the smaller value wasn't mentioned in the asm string, and if the // output was a register, just extend the shorter one to the size of the // larger one. -if (!SmallerValueMentioned && InputDomain != AD_Other && +if (!SmallerValueMentioned && !FPBoundToInt && InputDomain != AD_Other && OutputConstraintInfos[TiedTo].allowsRegister()) { + // FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen // crash when the size larger than the register size. So we limit it here. if (OutTy->isStructureType() && diff --git a/clang/test/Sema/asm.c b/clang/test/Sema/asm.c index a9cff5947ef5d0..f925849b82b33b 100644 --- a/clang/test/Sema/asm.c +++ b/clang/test/Sema/asm.c @@ -365,3 +365,9 @@ void test19(long long x) // FIXME: This case should be supported by codegen, but it fails now. asm ("" : "=rm" (x): "0" (e)); // expected-error {{unsupported inline asm: input with type 'st_size128' (aka 'struct _st_size128') matching output with type 'long long'}} } + +// PR119098 +void test20(char x) { + double value; + asm ("fabs" : "=t" (value): "0" (x)); // expected-error {{unsupported inline asm: input with type 'char' matching output with type 'double'}} +} \ No newline at end of file ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/119098 >From 8269073360f882daba9d9334ea8f2b6436fe9253 Mon Sep 17 00:00:00 2001 From: AdUhTkJm <[email protected]> Date: Sun, 8 Dec 2024 08:07:59 +0800 Subject: [PATCH] [Clang] Fix crash for incompatible types in inline assembly --- clang/lib/Sema/SemaStmtAsm.cpp | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 0b272b806391c4..770b59d0c3ebfa 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -664,11 +664,22 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, SmallerValueMentioned |= OutSize < InSize; } +// If the input is an integer register while the output is floating point, +// there is no way they can work together. +bool FPBoundToInt = false; +if (InputDomain != AD_FP && OutputDomain == AD_FP) { + FPBoundToInt = true; +} +if (InputDomain == AD_FP && OutputDomain != AD_FP) { + FPBoundToInt = true; +} + // If the smaller value wasn't mentioned in the asm string, and if the // output was a register, just extend the shorter one to the size of the // larger one. -if (!SmallerValueMentioned && InputDomain != AD_Other && +if (!SmallerValueMentioned && !FPBoundToInt && InputDomain != AD_Other && OutputConstraintInfos[TiedTo].allowsRegister()) { + // FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen // crash when the size larger than the register size. So we limit it here. if (OutTy->isStructureType() && ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/119098 >From 9f5c3334a580243f2812824dab4ab15aa80ddfec Mon Sep 17 00:00:00 2001 From: AdUhTkJm <[email protected]> Date: Sun, 8 Dec 2024 08:07:59 +0800 Subject: [PATCH] [Clang] Fix crash for incompatible types in inline assembly --- clang/lib/Sema/SemaStmtAsm.cpp | 13 - clang/test/Sema/PR119098.c | 23 +++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 clang/test/Sema/PR119098.c diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 0b272b806391c4..770b59d0c3ebfa 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -664,11 +664,22 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, SmallerValueMentioned |= OutSize < InSize; } +// If the input is an integer register while the output is floating point, +// there is no way they can work together. +bool FPBoundToInt = false; +if (InputDomain != AD_FP && OutputDomain == AD_FP) { + FPBoundToInt = true; +} +if (InputDomain == AD_FP && OutputDomain != AD_FP) { + FPBoundToInt = true; +} + // If the smaller value wasn't mentioned in the asm string, and if the // output was a register, just extend the shorter one to the size of the // larger one. -if (!SmallerValueMentioned && InputDomain != AD_Other && +if (!SmallerValueMentioned && !FPBoundToInt && InputDomain != AD_Other && OutputConstraintInfos[TiedTo].allowsRegister()) { + // FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen // crash when the size larger than the register size. So we limit it here. if (OutTy->isStructureType() && diff --git a/clang/test/Sema/PR119098.c b/clang/test/Sema/PR119098.c new file mode 100644 index 00..48c41cb1bea042 --- /dev/null +++ b/clang/test/Sema/PR119098.c @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify + +// expected-warning@+2 {{incompatible redeclaration of library function 'fabs'}} +// expected-note@+1 {{'fabs' is a builtin with type 'double (double)'}} +extern __inline double +fabs (char __x) +{ + register double __value; + __asm __volatile__ +("fabs" + : "=t" (__value) : "0" (__x)); // expected-error {{unsupported inline asm: input with type 'char' matching output with type 'double'}} + return __value; +} +int +foo () +{ + int i, j, k; + double x = 0, y = ((i == j) ? 1 : 0); + for (i = 0; i < 10; i++) +; + fabs (x - y); + return 0; +} \ No newline at end of file ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/119098 >From 26bb776fcd750df11a4940899869f59035f78a79 Mon Sep 17 00:00:00 2001 From: AdUhTkJm <[email protected]> Date: Sun, 8 Dec 2024 08:07:59 +0800 Subject: [PATCH] [Clang] Fix crash for incompatible types in inline assembly --- clang/lib/Sema/SemaStmtAsm.cpp | 10 +- clang/test/Sema/PR119098.c | 23 +++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 clang/test/Sema/PR119098.c diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 0b272b806391c4..f3e4d08761ea07 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -664,11 +664,19 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, SmallerValueMentioned |= OutSize < InSize; } +// If the input is in an integer register while the output is floating point, +// there is no way we can extend and we must reject it. +bool FPExtendFromInt = false; +if (InputDomain != AD_Float && OutputDomain == AD_Float) { + FPExtendFromInt = true; +} + // If the smaller value wasn't mentioned in the asm string, and if the // output was a register, just extend the shorter one to the size of the // larger one. -if (!SmallerValueMentioned && InputDomain != AD_Other && +if (!SmallerValueMentioned && !FPExtendFromInt && InputDomain != AD_Other && OutputConstraintInfos[TiedTo].allowsRegister()) { + // FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen // crash when the size larger than the register size. So we limit it here. if (OutTy->isStructureType() && diff --git a/clang/test/Sema/PR119098.c b/clang/test/Sema/PR119098.c new file mode 100644 index 00..48c41cb1bea042 --- /dev/null +++ b/clang/test/Sema/PR119098.c @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify + +// expected-warning@+2 {{incompatible redeclaration of library function 'fabs'}} +// expected-note@+1 {{'fabs' is a builtin with type 'double (double)'}} +extern __inline double +fabs (char __x) +{ + register double __value; + __asm __volatile__ +("fabs" + : "=t" (__value) : "0" (__x)); // expected-error {{unsupported inline asm: input with type 'char' matching output with type 'double'}} + return __value; +} +int +foo () +{ + int i, j, k; + double x = 0, y = ((i == j) ? 1 : 0); + for (i = 0; i < 10; i++) +; + fabs (x - y); + return 0; +} \ No newline at end of file ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/119098 >From 84cd85c3c09482276cbe971f9e11b65673d55db4 Mon Sep 17 00:00:00 2001 From: AdUhTkJm <[email protected]> Date: Sun, 8 Dec 2024 08:07:59 +0800 Subject: [PATCH] [Clang] Fix crash for incompatible types in inline assembly --- clang/lib/Sema/SemaStmtAsm.cpp | 10 +- clang/test/Sema/PR119098.c | 23 +++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 clang/test/Sema/PR119098.c diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 0b272b806391c4..f3e4d08761ea07 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -664,11 +664,19 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, SmallerValueMentioned |= OutSize < InSize; } +// If the input is in an integer register while the output is floating point, +// there is no way we can extend and we must reject it. +bool FPExtendFromInt = false; +if (InputDomain != AD_Float && OutputDomain == AD_Float) { + FPExtendFromInt = true; +} + // If the smaller value wasn't mentioned in the asm string, and if the // output was a register, just extend the shorter one to the size of the // larger one. -if (!SmallerValueMentioned && InputDomain != AD_Other && +if (!SmallerValueMentioned && !FPExtendFromInt && InputDomain != AD_Other && OutputConstraintInfos[TiedTo].allowsRegister()) { + // FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen // crash when the size larger than the register size. So we limit it here. if (OutTy->isStructureType() && diff --git a/clang/test/Sema/PR119098.c b/clang/test/Sema/PR119098.c new file mode 100644 index 00..48c41cb1bea042 --- /dev/null +++ b/clang/test/Sema/PR119098.c @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify + +// expected-warning@+2 {{incompatible redeclaration of library function 'fabs'}} +// expected-note@+1 {{'fabs' is a builtin with type 'double (double)'}} +extern __inline double +fabs (char __x) +{ + register double __value; + __asm __volatile__ +("fabs" + : "=t" (__value) : "0" (__x)); // expected-error {{unsupported inline asm: input with type 'char' matching output with type 'double'}} + return __value; +} +int +foo () +{ + int i, j, k; + double x = 0, y = ((i == j) ? 1 : 0); + for (i = 0; i < 10; i++) +; + fabs (x - y); + return 0; +} \ No newline at end of file ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/AdUhTkJm updated https://github.com/llvm/llvm-project/pull/119098 >From 367261c3b9d8bf80ba39ae296d30f53bff2a2d4b Mon Sep 17 00:00:00 2001 From: AdUhTkJm <[email protected]> Date: Sun, 8 Dec 2024 07:04:11 +0800 Subject: [PATCH] [Clang] Fix crash for incompatible types in inline assembly --- clang/lib/Sema/SemaStmtAsm.cpp| 1 + .../test/Sema/inline-asm-incompatible-types.c | 19 +++ 2 files changed, 20 insertions(+) create mode 100644 clang/test/Sema/inline-asm-incompatible-types.c diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 0b272b806391c4..5e236b59d14b7d 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -668,6 +668,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, // output was a register, just extend the shorter one to the size of the // larger one. if (!SmallerValueMentioned && InputDomain != AD_Other && +InputDomain == OutputDomain && OutputConstraintInfos[TiedTo].allowsRegister()) { // FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen // crash when the size larger than the register size. So we limit it here. diff --git a/clang/test/Sema/inline-asm-incompatible-types.c b/clang/test/Sema/inline-asm-incompatible-types.c new file mode 100644 index 00..849543e8027c20 --- /dev/null +++ b/clang/test/Sema/inline-asm-incompatible-types.c @@ -0,0 +1,19 @@ +extern __inline double +fabs (char __x) +{ + register double __value; + __asm __volatile__ +("fabs" + : "=t" (__value) : "0" (__x)); + return __value; +} +int +foo () +{ + int i, j, k; + double x = 0, y = ((i == j) ? 1 : 0); + for (i = 0; i < 10; i++) +; + fabs (x - y); + return 0; +} \ No newline at end of file ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
llvmbot wrote:
@llvm/pr-subscribers-clang
Author: None (AdUhTkJm)
Changes
Fixed issue #118892.
---
Full diff: https://github.com/llvm/llvm-project/pull/119098.diff
2 Files Affected:
- (modified) clang/lib/Sema/SemaStmtAsm.cpp (+1)
- (added) clang/test/Sema/inline-asm-incompatible-types.c (+19)
``diff
diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp
index 0b272b806391c4..5e236b59d14b7d 100644
--- a/clang/lib/Sema/SemaStmtAsm.cpp
+++ b/clang/lib/Sema/SemaStmtAsm.cpp
@@ -668,6 +668,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc,
bool IsSimple,
// output was a register, just extend the shorter one to the size of the
// larger one.
if (!SmallerValueMentioned && InputDomain != AD_Other &&
+InputDomain == OutputDomain &&
OutputConstraintInfos[TiedTo].allowsRegister()) {
// FIXME: GCC supports the OutSize to be 128 at maximum. Currently
codegen
// crash when the size larger than the register size. So we limit it
here.
diff --git a/clang/test/Sema/inline-asm-incompatible-types.c
b/clang/test/Sema/inline-asm-incompatible-types.c
new file mode 100644
index 00..849543e8027c20
--- /dev/null
+++ b/clang/test/Sema/inline-asm-incompatible-types.c
@@ -0,0 +1,19 @@
+extern __inline double
+fabs (char __x)
+{
+ register double __value;
+ __asm __volatile__
+("fabs"
+ : "=t" (__value) : "0" (__x));
+ return __value;
+}
+int
+foo ()
+{
+ int i, j, k;
+ double x = 0, y = ((i == j) ? 1 : 0);
+ for (i = 0; i < 10; i++)
+;
+ fabs (x - y);
+ return 0;
+}
\ No newline at end of file
``
https://github.com/llvm/llvm-project/pull/119098
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/119098 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
https://github.com/AdUhTkJm created https://github.com/llvm/llvm-project/pull/119098 Fixed issue #118892. >From 367261c3b9d8bf80ba39ae296d30f53bff2a2d4b Mon Sep 17 00:00:00 2001 From: AdUhTkJm <[email protected]> Date: Sun, 8 Dec 2024 07:04:11 +0800 Subject: [PATCH] [Clang] Fix crash for incompatible types in inline assembly --- clang/lib/Sema/SemaStmtAsm.cpp| 1 + .../test/Sema/inline-asm-incompatible-types.c | 19 +++ 2 files changed, 20 insertions(+) create mode 100644 clang/test/Sema/inline-asm-incompatible-types.c diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 0b272b806391c4..5e236b59d14b7d 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -668,6 +668,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, // output was a register, just extend the shorter one to the size of the // larger one. if (!SmallerValueMentioned && InputDomain != AD_Other && +InputDomain == OutputDomain && OutputConstraintInfos[TiedTo].allowsRegister()) { // FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen // crash when the size larger than the register size. So we limit it here. diff --git a/clang/test/Sema/inline-asm-incompatible-types.c b/clang/test/Sema/inline-asm-incompatible-types.c new file mode 100644 index 00..849543e8027c20 --- /dev/null +++ b/clang/test/Sema/inline-asm-incompatible-types.c @@ -0,0 +1,19 @@ +extern __inline double +fabs (char __x) +{ + register double __value; + __asm __volatile__ +("fabs" + : "=t" (__value) : "0" (__x)); + return __value; +} +int +foo () +{ + int i, j, k; + double x = 0, y = ((i == j) ? 1 : 0); + for (i = 0; i < 10; i++) +; + fabs (x - y); + return 0; +} \ No newline at end of file ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
