This revision was automatically updated to reflect the committed changes. Closed by commit rC326689: [x86][CET] Introduce _get_ssp, _inc_ssp intrinsics (authored by aivchenk, committed by ).
Repository: rC Clang https://reviews.llvm.org/D43814 Files: lib/Headers/cetintrin.h test/CodeGen/cetintrin.c Index: test/CodeGen/cetintrin.c =================================================================== --- test/CodeGen/cetintrin.c +++ test/CodeGen/cetintrin.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -ffreestanding %s -triple=i386-apple-darwin -target-feature +shstk -emit-llvm -o - -Wall -Werror | FileCheck %s -// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +shstk -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=X86_64 +// RUN: %clang_cc1 -ffreestanding %s -triple=i386-apple-darwin -target-feature +shstk -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=I386 --check-prefix=CHECK +// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +shstk -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=X86_64 --check-prefix=CHECK #include <immintrin.h> @@ -15,6 +15,20 @@ // X86_64: call void @llvm.x86.incsspq(i64 %{{[a-z0-9.]+}}) _incsspq(a); } + +void test_inc_ssp(unsigned int a) { + // X86_64-LABEL: @test_inc_ssp + // X86_64: call void @llvm.x86.incsspq(i64 %{{[a-z0-9.]+}}) + _inc_ssp(a); +} +#else + +void test_inc_ssp(unsigned int a) { + // I386-LABEL: @test_inc_ssp + // I386: call void @llvm.x86.incsspd(i32 %{{[0-9]+}}) + _inc_ssp(a); +} + #endif unsigned int test_rdsspd(unsigned int a) { @@ -29,6 +43,21 @@ // X86_64: call i64 @llvm.x86.rdsspq(i64 %{{[a-z0-9.]+}}) return _rdsspq(a); } + +unsigned long long test_get_ssp(void) { + // X86_64-LABEL: @test_get_ssp + // X86_64: call i64 @llvm.x86.rdsspq(i64 0) + return _get_ssp(); +} + +#else + +unsigned int test_get_ssp(void) { + // I386-LABEL: @test_get_ssp + // I386: call i32 @llvm.x86.rdsspd(i32 0) + return _get_ssp(); +} + #endif void test_saveprevssp() { Index: lib/Headers/cetintrin.h =================================================================== --- lib/Headers/cetintrin.h +++ lib/Headers/cetintrin.h @@ -42,6 +42,16 @@ } #endif /* __x86_64__ */ +#ifdef __x86_64__ +static __inline__ void __DEFAULT_FN_ATTRS _inc_ssp(unsigned int __a) { + __builtin_ia32_incsspq(__a); +} +#else /* __x86_64__ */ +static __inline__ void __DEFAULT_FN_ATTRS _inc_ssp(unsigned int __a) { + __builtin_ia32_incsspd((int)__a); +} +#endif /* __x86_64__ */ + static __inline__ unsigned int __DEFAULT_FN_ATTRS _rdsspd(unsigned int __a) { return __builtin_ia32_rdsspd(__a); } @@ -52,6 +62,16 @@ } #endif /* __x86_64__ */ +#ifdef __x86_64__ +static __inline__ unsigned long long __DEFAULT_FN_ATTRS _get_ssp(void) { + return __builtin_ia32_rdsspq(0); +} +#else /* __x86_64__ */ +static __inline__ unsigned int __DEFAULT_FN_ATTRS _get_ssp(void) { + return __builtin_ia32_rdsspd(0); +} +#endif /* __x86_64__ */ + static __inline__ void __DEFAULT_FN_ATTRS _saveprevssp() { __builtin_ia32_saveprevssp(); }
Index: test/CodeGen/cetintrin.c =================================================================== --- test/CodeGen/cetintrin.c +++ test/CodeGen/cetintrin.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -ffreestanding %s -triple=i386-apple-darwin -target-feature +shstk -emit-llvm -o - -Wall -Werror | FileCheck %s -// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +shstk -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=X86_64 +// RUN: %clang_cc1 -ffreestanding %s -triple=i386-apple-darwin -target-feature +shstk -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=I386 --check-prefix=CHECK +// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +shstk -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=X86_64 --check-prefix=CHECK #include <immintrin.h> @@ -15,6 +15,20 @@ // X86_64: call void @llvm.x86.incsspq(i64 %{{[a-z0-9.]+}}) _incsspq(a); } + +void test_inc_ssp(unsigned int a) { + // X86_64-LABEL: @test_inc_ssp + // X86_64: call void @llvm.x86.incsspq(i64 %{{[a-z0-9.]+}}) + _inc_ssp(a); +} +#else + +void test_inc_ssp(unsigned int a) { + // I386-LABEL: @test_inc_ssp + // I386: call void @llvm.x86.incsspd(i32 %{{[0-9]+}}) + _inc_ssp(a); +} + #endif unsigned int test_rdsspd(unsigned int a) { @@ -29,6 +43,21 @@ // X86_64: call i64 @llvm.x86.rdsspq(i64 %{{[a-z0-9.]+}}) return _rdsspq(a); } + +unsigned long long test_get_ssp(void) { + // X86_64-LABEL: @test_get_ssp + // X86_64: call i64 @llvm.x86.rdsspq(i64 0) + return _get_ssp(); +} + +#else + +unsigned int test_get_ssp(void) { + // I386-LABEL: @test_get_ssp + // I386: call i32 @llvm.x86.rdsspd(i32 0) + return _get_ssp(); +} + #endif void test_saveprevssp() { Index: lib/Headers/cetintrin.h =================================================================== --- lib/Headers/cetintrin.h +++ lib/Headers/cetintrin.h @@ -42,6 +42,16 @@ } #endif /* __x86_64__ */ +#ifdef __x86_64__ +static __inline__ void __DEFAULT_FN_ATTRS _inc_ssp(unsigned int __a) { + __builtin_ia32_incsspq(__a); +} +#else /* __x86_64__ */ +static __inline__ void __DEFAULT_FN_ATTRS _inc_ssp(unsigned int __a) { + __builtin_ia32_incsspd((int)__a); +} +#endif /* __x86_64__ */ + static __inline__ unsigned int __DEFAULT_FN_ATTRS _rdsspd(unsigned int __a) { return __builtin_ia32_rdsspd(__a); } @@ -52,6 +62,16 @@ } #endif /* __x86_64__ */ +#ifdef __x86_64__ +static __inline__ unsigned long long __DEFAULT_FN_ATTRS _get_ssp(void) { + return __builtin_ia32_rdsspq(0); +} +#else /* __x86_64__ */ +static __inline__ unsigned int __DEFAULT_FN_ATTRS _get_ssp(void) { + return __builtin_ia32_rdsspd(0); +} +#endif /* __x86_64__ */ + static __inline__ void __DEFAULT_FN_ATTRS _saveprevssp() { __builtin_ia32_saveprevssp(); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits