Skip to content

Commit 8269073

Browse files
committed
[Clang] Fix crash for incompatible types in inline assembly
1 parent 7787328 commit 8269073

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

clang/lib/Sema/SemaStmtAsm.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,11 +664,22 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
664664
SmallerValueMentioned |= OutSize < InSize;
665665
}
666666

667+
// If the input is an integer register while the output is floating point,
668+
// there is no way they can work together.
669+
bool FPBoundToInt = false;
670+
if (InputDomain != AD_FP && OutputDomain == AD_FP) {
671+
FPBoundToInt = true;
672+
}
673+
if (InputDomain == AD_FP && OutputDomain != AD_FP) {
674+
FPBoundToInt = true;
675+
}
676+
667677
// If the smaller value wasn't mentioned in the asm string, and if the
668678
// output was a register, just extend the shorter one to the size of the
669679
// larger one.
670-
if (!SmallerValueMentioned && InputDomain != AD_Other &&
680+
if (!SmallerValueMentioned && !FPBoundToInt && InputDomain != AD_Other &&
671681
OutputConstraintInfos[TiedTo].allowsRegister()) {
682+
672683
// FIXME: GCC supports the OutSize to be 128 at maximum. Currently codegen
673684
// crash when the size larger than the register size. So we limit it here.
674685
if (OutTy->isStructureType() &&

0 commit comments

Comments
 (0)