Add support for __declspec(guard(nocf))
Summary:
Avoid using the `nocf_check` attribute with Control Flow Guard. Instead, use a
new `"guard_nocf"` function attribute to indicate that checks should not be
added on indirect calls within that function. Add support for
`__declspec(guard(nocf))` following the same syntax as MSVC.
Reviewers: rnk, dmajor, pcc, hans, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: aaron.ballman, tomrittervg, hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D72167
2020-01-10 19:08:18 +08:00
|
|
|
// RUN: %clang_cc1 -triple %ms_abi_triple -fms-extensions -emit-llvm -O2 -o - %s | FileCheck %s
|
|
|
|
|
2022-02-16 05:06:01 +08:00
|
|
|
void target_func(void);
|
|
|
|
void (*func_ptr)(void) = &target_func;
|
Add support for __declspec(guard(nocf))
Summary:
Avoid using the `nocf_check` attribute with Control Flow Guard. Instead, use a
new `"guard_nocf"` function attribute to indicate that checks should not be
added on indirect calls within that function. Add support for
`__declspec(guard(nocf))` following the same syntax as MSVC.
Reviewers: rnk, dmajor, pcc, hans, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: aaron.ballman, tomrittervg, hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D72167
2020-01-10 19:08:18 +08:00
|
|
|
|
|
|
|
// The "guard_nocf" attribute must be added.
|
2022-02-16 05:06:01 +08:00
|
|
|
__declspec(guard(nocf)) void nocf0(void) {
|
Add support for __declspec(guard(nocf))
Summary:
Avoid using the `nocf_check` attribute with Control Flow Guard. Instead, use a
new `"guard_nocf"` function attribute to indicate that checks should not be
added on indirect calls within that function. Add support for
`__declspec(guard(nocf))` following the same syntax as MSVC.
Reviewers: rnk, dmajor, pcc, hans, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: aaron.ballman, tomrittervg, hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D72167
2020-01-10 19:08:18 +08:00
|
|
|
(*func_ptr)();
|
|
|
|
}
|
|
|
|
// CHECK-LABEL: nocf0
|
|
|
|
// CHECK: call{{.*}}[[NOCF:#[0-9]+]]
|
|
|
|
|
|
|
|
// The "guard_nocf" attribute must *not* be added.
|
2022-02-16 05:06:01 +08:00
|
|
|
void cf0(void) {
|
Add support for __declspec(guard(nocf))
Summary:
Avoid using the `nocf_check` attribute with Control Flow Guard. Instead, use a
new `"guard_nocf"` function attribute to indicate that checks should not be
added on indirect calls within that function. Add support for
`__declspec(guard(nocf))` following the same syntax as MSVC.
Reviewers: rnk, dmajor, pcc, hans, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: aaron.ballman, tomrittervg, hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D72167
2020-01-10 19:08:18 +08:00
|
|
|
(*func_ptr)();
|
|
|
|
}
|
|
|
|
// CHECK-LABEL: cf0
|
|
|
|
// CHECK: call{{.*}}[[CF:#[0-9]+]]
|
|
|
|
|
|
|
|
// If the modifier is present on either the function declaration or definition,
|
|
|
|
// the "guard_nocf" attribute must be added.
|
2022-02-16 05:06:01 +08:00
|
|
|
__declspec(guard(nocf)) void nocf1(void);
|
|
|
|
void nocf1(void) {
|
Add support for __declspec(guard(nocf))
Summary:
Avoid using the `nocf_check` attribute with Control Flow Guard. Instead, use a
new `"guard_nocf"` function attribute to indicate that checks should not be
added on indirect calls within that function. Add support for
`__declspec(guard(nocf))` following the same syntax as MSVC.
Reviewers: rnk, dmajor, pcc, hans, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: aaron.ballman, tomrittervg, hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D72167
2020-01-10 19:08:18 +08:00
|
|
|
(*func_ptr)();
|
|
|
|
}
|
|
|
|
// CHECK-LABEL: nocf1
|
|
|
|
// CHECK: call{{.*}}[[NOCF:#[0-9]+]]
|
|
|
|
|
2022-02-16 05:06:01 +08:00
|
|
|
void nocf2(void);
|
|
|
|
__declspec(guard(nocf)) void nocf2(void) {
|
Add support for __declspec(guard(nocf))
Summary:
Avoid using the `nocf_check` attribute with Control Flow Guard. Instead, use a
new `"guard_nocf"` function attribute to indicate that checks should not be
added on indirect calls within that function. Add support for
`__declspec(guard(nocf))` following the same syntax as MSVC.
Reviewers: rnk, dmajor, pcc, hans, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: aaron.ballman, tomrittervg, hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D72167
2020-01-10 19:08:18 +08:00
|
|
|
(*func_ptr)();
|
|
|
|
}
|
|
|
|
// CHECK-LABEL: nocf2
|
|
|
|
// CHECK: call{{.*}}[[NOCF:#[0-9]+]]
|
|
|
|
|
|
|
|
// When inlining a function, the "guard_nocf" attribute on indirect calls must
|
|
|
|
// be preserved.
|
2022-02-16 05:06:01 +08:00
|
|
|
void nocf3(void) {
|
Add support for __declspec(guard(nocf))
Summary:
Avoid using the `nocf_check` attribute with Control Flow Guard. Instead, use a
new `"guard_nocf"` function attribute to indicate that checks should not be
added on indirect calls within that function. Add support for
`__declspec(guard(nocf))` following the same syntax as MSVC.
Reviewers: rnk, dmajor, pcc, hans, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: aaron.ballman, tomrittervg, hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D72167
2020-01-10 19:08:18 +08:00
|
|
|
nocf0();
|
|
|
|
}
|
|
|
|
// CHECK-LABEL: nocf3
|
|
|
|
// CHECK: call{{.*}}[[NOCF:#[0-9]+]]
|
|
|
|
|
|
|
|
// When inlining into a function marked as __declspec(guard(nocf)), the
|
|
|
|
// "guard_nocf" attribute must *not* be added to the inlined calls.
|
2022-02-16 05:06:01 +08:00
|
|
|
__declspec(guard(nocf)) void cf1(void) {
|
Add support for __declspec(guard(nocf))
Summary:
Avoid using the `nocf_check` attribute with Control Flow Guard. Instead, use a
new `"guard_nocf"` function attribute to indicate that checks should not be
added on indirect calls within that function. Add support for
`__declspec(guard(nocf))` following the same syntax as MSVC.
Reviewers: rnk, dmajor, pcc, hans, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: aaron.ballman, tomrittervg, hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D72167
2020-01-10 19:08:18 +08:00
|
|
|
cf0();
|
|
|
|
}
|
|
|
|
// CHECK-LABEL: cf1
|
|
|
|
// CHECK: call{{.*}}[[CF:#[0-9]+]]
|
|
|
|
|
|
|
|
// CHECK: attributes [[NOCF]] = { {{.*}}"guard_nocf"{{.*}} }
|
|
|
|
// CHECK-NOT: attributes [[CF]] = { {{.*}}"guard_nocf"{{.*}} }
|