Skip to content

Commit 367261c

Browse files
committed
[Clang] Fix crash for incompatible types in inline assembly
1 parent 66f9448 commit 367261c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

clang/lib/Sema/SemaStmtAsm.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
668668
// output was a register, just extend the shorter one to the size of the
669669
// larger one.
670670
if (!SmallerValueMentioned && InputDomain != AD_Other &&
671+
InputDomain == OutputDomain &&
671672
OutputConstraintInfos[TiedTo].allowsRegister()) {
672673
// FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen
673674
// crash when the size larger than the register size. So we limit it here.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
extern __inline double
2+
fabs (char __x)
3+
{
4+
register double __value;
5+
__asm __volatile__
6+
("fabs"
7+
: "=t" (__value) : "0" (__x));
8+
return __value;
9+
}
10+
int
11+
foo ()
12+
{
13+
int i, j, k;
14+
double x = 0, y = ((i == j) ? 1 : 0);
15+
for (i = 0; i < 10; i++)
16+
;
17+
fabs (x - y);
18+
return 0;
19+
}

0 commit comments

Comments
 (0)