[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 7 15:19:40 PST 2024
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 <2292398666 at qq.com>
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 00000000000000..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
More information about the cfe-commits
mailing list