forked from OSchip/llvm-project
[MS] Add support for __ud2 and __int2c MSVC intrinsics
This was requested in PR31958 and elsewhere. llvm-svn: 297057
This commit is contained in:
parent
a175512b18
commit
b04cb9ab7a
|
@ -1829,6 +1829,8 @@ TARGET_HEADER_BUILTIN(__emulu, "ULLiUiUi", "nh", "intrin.h", ALL_MS_LANGUAGES, "
|
|||
TARGET_HEADER_BUILTIN(_AddressOfReturnAddress, "v*", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
|
||||
|
||||
TARGET_HEADER_BUILTIN(__stosb, "vUc*Ucz", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
|
||||
TARGET_HEADER_BUILTIN(__int2c, "v", "nr", "intrin.h", ALL_MS_LANGUAGES, "")
|
||||
TARGET_HEADER_BUILTIN(__ud2, "v", "nr", "intrin.h", ALL_MS_LANGUAGES, "")
|
||||
|
||||
#undef BUILTIN
|
||||
#undef TARGET_BUILTIN
|
||||
|
|
|
@ -7982,6 +7982,21 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
|
|||
// instruction, but it will create a memset that won't be optimized away.
|
||||
return Builder.CreateMemSet(Ops[0], Ops[1], Ops[2], 1, true);
|
||||
}
|
||||
case X86::BI__ud2:
|
||||
// llvm.trap makes a ud2a instruction on x86.
|
||||
return EmitTrapCall(Intrinsic::trap);
|
||||
case X86::BI__int2c: {
|
||||
// This syscall signals a driver assertion failure in x86 NT kernels.
|
||||
llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
|
||||
llvm::InlineAsm *IA =
|
||||
llvm::InlineAsm::get(FTy, "int $$0x2c", "", /*SideEffects=*/true);
|
||||
llvm::AttributeSet NoReturnAttr =
|
||||
AttributeSet::get(getLLVMContext(), llvm::AttributeSet::FunctionIndex,
|
||||
llvm::Attribute::NoReturn);
|
||||
CallSite CS = Builder.CreateCall(IA);
|
||||
CS.setAttributes(NoReturnAttr);
|
||||
return CS.getInstruction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,6 @@ void __incfsdword(unsigned long);
|
|||
void __incfsword(unsigned long);
|
||||
unsigned long __indword(unsigned short);
|
||||
void __indwordstring(unsigned short, unsigned long *, unsigned long);
|
||||
void __int2c(void);
|
||||
void __invlpg(void *);
|
||||
unsigned short __inword(unsigned short);
|
||||
void __inwordstring(unsigned short, unsigned short *, unsigned long);
|
||||
|
@ -141,7 +140,6 @@ void __svm_stgi(void);
|
|||
void __svm_vmload(size_t);
|
||||
void __svm_vmrun(size_t);
|
||||
void __svm_vmsave(size_t);
|
||||
void __ud2(void);
|
||||
unsigned __int64 __ull_rshift(unsigned __int64, int);
|
||||
void __vmx_off(void);
|
||||
void __vmx_vmptrst(unsigned __int64 *);
|
||||
|
|
|
@ -28,6 +28,20 @@ void test__stosb(unsigned char *Dest, unsigned char Data, size_t Count) {
|
|||
// CHECK-X64: tail call void @llvm.memset.p0i8.i64(i8* %Dest, i8 %Data, i64 %Count, i32 1, i1 true)
|
||||
// CHECK-X64: ret void
|
||||
// CHECK-X64: }
|
||||
|
||||
void test__ud2(void) {
|
||||
__ud2();
|
||||
}
|
||||
// CHECK-INTEL-LABEL: define{{.*}} void @test__ud2()
|
||||
// CHECK-INTEL: call void @llvm.trap()
|
||||
|
||||
void test__int2c(void) {
|
||||
__int2c();
|
||||
}
|
||||
// CHECK-INTEL-LABEL: define{{.*}} void @test__int2c()
|
||||
// CHECK-INTEL: call void asm sideeffect "int $$0x2c", ""() #[[NORETURN:[0-9]+]]
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
void *test_ReturnAddress() {
|
||||
|
@ -425,7 +439,7 @@ void test__fastfail() {
|
|||
}
|
||||
// CHECK-LABEL: define{{.*}} void @test__fastfail()
|
||||
// CHECK-ARM: call void asm sideeffect "udf #251", "{r0}"(i32 42) #[[NORETURN:[0-9]+]]
|
||||
// CHECK-INTEL: call void asm sideeffect "int $$0x29", "{cx}"(i32 42) #[[NORETURN:[0-9]+]]
|
||||
// CHECK-INTEL: call void asm sideeffect "int $$0x29", "{cx}"(i32 42) #[[NORETURN]]
|
||||
|
||||
// Attributes come last.
|
||||
|
||||
|
|
Loading…
Reference in New Issue