Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions clang/lib/CodeGen/Targets/X86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ bool IsX86_MMXType(llvm::Type *IRType) {
static llvm::Type *X86AdjustInlineAsmType(CodeGen::CodeGenFunction &CGF,
StringRef Constraint,
llvm::Type *Ty) {
bool IsMMXCons = llvm::StringSwitch<bool>(Constraint)
.Cases({"y", "&y", "^Ym"}, true)
.Default(false);
if (IsMMXCons && Ty->isVectorTy() &&
cast<llvm::VectorType>(Ty)->getPrimitiveSizeInBits().getFixedValue() !=
64)
return nullptr; // Invalid MMX constraint

if (Constraint == "k") {
llvm::Type *Int1Ty = llvm::Type::getInt1Ty(CGF.getLLVMContext());
return llvm::FixedVectorType::get(Int1Ty, Ty->getScalarSizeInBits());
Expand Down
4 changes: 3 additions & 1 deletion clang/test/CodeGen/X86/mmx-inline-asm-error.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// RUN: %clang_cc1 -verify -triple x86_64-unknown-unknown -emit-llvm-only %s
// RUN: %clang_cc1 -verify=omp -triple x86_64-unknown-unknown -emit-llvm-only -fopenmp %s
typedef int vec256 __attribute__((ext_vector_type(8)));

vec256 foo(vec256 in) {
vec256 out;

asm("something %0" : : "y"(in)); // expected-error {{invalid input size for constraint 'y'}}
// omp-error@+1 {{invalid type 'vec256' (vector of 8 'int' values) in asm input for constraint 'y'}}
asm("something %0" : "=y"(out)); // expected-error {{invalid output size for constraint '=y'}}
// omp-error@+1 {{invalid type 'vec256' (vector of 8 'int' values) in asm input for constraint 'y'}}
asm("something %0, %0" : "+y"(out)); // expected-error {{invalid output size for constraint '+y'}}

return out;
}