2013-09-20 04:32:16 +08:00
|
|
|
// Note: %s must be preceded by --, otherwise it may be interpreted as a
|
|
|
|
// command-line option, e.g. on Mac where %s is commonly under /Users.
|
|
|
|
|
2016-06-16 04:34:33 +08:00
|
|
|
// RUN: %clang_cl --target=i686-pc-win32 /fallback /Dfoo=bar /Ubaz /Ifoo /O0 /Ox /GR /GR- /GS /GS- /Gy /Gy- \
|
Add Windows Control Flow Guard checks (/guard:cf).
Summary:
A new function pass (Transforms/CFGuard/CFGuard.cpp) inserts CFGuard checks on
indirect function calls, using either the check mechanism (X86, ARM, AArch64) or
or the dispatch mechanism (X86-64). The check mechanism requires a new calling
convention for the supported targets. The dispatch mechanism adds the target as
an operand bundle, which is processed by SelectionDAG. Another pass
(CodeGen/CFGuardLongjmp.cpp) identifies and emits valid longjmp targets, as
required by /guard:cf. This feature is enabled using the `cfguard` CC1 option.
Reviewers: thakis, rnk, theraven, pcc
Subscribers: ychen, hans, metalcanine, dmajor, tomrittervg, alex, mehdi_amini, mgorny, javed.absar, kristof.beyls, hiraditya, steven_wu, dexonsmith, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D65761
2019-10-28 21:22:19 +08:00
|
|
|
// RUN: /Gw /Gw- /LD /LDd /EHs /EHs- /Zl /MD /MDd /MTd /MT /guard:cf /guard:cf- /FImyheader.h /Zi \
|
2016-01-26 05:14:52 +08:00
|
|
|
// RUN: -garbage -moregarbage \
|
2014-04-08 00:14:38 +08:00
|
|
|
// RUN: -### -- %s 2>&1 \
|
2014-03-25 22:48:54 +08:00
|
|
|
// RUN: | FileCheck %s
|
2013-09-24 08:08:55 +08:00
|
|
|
// CHECK: "-fdiagnostics-format" "msvc-fallback"
|
2013-09-20 04:32:16 +08:00
|
|
|
// CHECK: ||
|
|
|
|
// CHECK: cl.exe
|
2013-09-25 01:36:21 +08:00
|
|
|
// CHECK: "/nologo"
|
2013-09-20 04:32:16 +08:00
|
|
|
// CHECK: "/c"
|
|
|
|
// CHECK: "/W0"
|
|
|
|
// CHECK: "-D" "foo=bar"
|
|
|
|
// CHECK: "-U" "baz"
|
|
|
|
// CHECK: "-I" "foo"
|
2015-07-27 15:32:11 +08:00
|
|
|
// CHECK: "/Oi"
|
|
|
|
// CHECK: "/Og"
|
|
|
|
// CHECK: "/Ot"
|
|
|
|
// CHECK: "/Ob2"
|
|
|
|
// CHECK: "/Oy"
|
|
|
|
// CHECK: "/GF"
|
2013-09-20 04:32:16 +08:00
|
|
|
// CHECK: "/GR-"
|
2016-06-16 04:34:33 +08:00
|
|
|
// CHECK: "/GS-"
|
2014-03-25 22:48:54 +08:00
|
|
|
// CHECK: "/Gy-"
|
2014-04-08 00:14:38 +08:00
|
|
|
// CHECK: "/Gw-"
|
2014-02-20 06:05:59 +08:00
|
|
|
// CHECK: "/Z7"
|
2013-09-28 01:54:18 +08:00
|
|
|
// CHECK: "/FImyheader.h"
|
2013-09-20 04:32:16 +08:00
|
|
|
// CHECK: "/LD"
|
|
|
|
// CHECK: "/LDd"
|
2014-06-28 01:02:02 +08:00
|
|
|
// CHECK: "/EHs"
|
|
|
|
// CHECK: "/EHs-"
|
2015-07-25 14:07:59 +08:00
|
|
|
// CHECK: "/Zl"
|
2013-09-20 04:32:16 +08:00
|
|
|
// CHECK: "/MT"
|
Add Windows Control Flow Guard checks (/guard:cf).
Summary:
A new function pass (Transforms/CFGuard/CFGuard.cpp) inserts CFGuard checks on
indirect function calls, using either the check mechanism (X86, ARM, AArch64) or
or the dispatch mechanism (X86-64). The check mechanism requires a new calling
convention for the supported targets. The dispatch mechanism adds the target as
an operand bundle, which is processed by SelectionDAG. Another pass
(CodeGen/CFGuardLongjmp.cpp) identifies and emits valid longjmp targets, as
required by /guard:cf. This feature is enabled using the `cfguard` CC1 option.
Reviewers: thakis, rnk, theraven, pcc
Subscribers: ychen, hans, metalcanine, dmajor, tomrittervg, alex, mehdi_amini, mgorny, javed.absar, kristof.beyls, hiraditya, steven_wu, dexonsmith, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D65761
2019-10-28 21:22:19 +08:00
|
|
|
// CHECK: "/guard:cf-"
|
2016-01-26 05:14:52 +08:00
|
|
|
// CHECK: "-garbage"
|
|
|
|
// CHECK: "-moregarbage"
|
2013-09-20 04:32:16 +08:00
|
|
|
// CHECK: "/Tc" "{{.*cl-fallback.c}}"
|
|
|
|
// CHECK: "/Fo{{.*cl-fallback.*.obj}}"
|
2013-09-25 02:17:21 +08:00
|
|
|
|
2014-07-02 06:24:56 +08:00
|
|
|
// RUN: %clang_cl /fallback /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR %s
|
|
|
|
// GR: cl.exe
|
|
|
|
// GR: "/GR-"
|
|
|
|
|
2016-06-16 04:34:33 +08:00
|
|
|
// RUN: %clang_cl /fallback /GS- -### -- %s 2>&1 | FileCheck -check-prefix=GS %s
|
|
|
|
// GS: cl.exe
|
|
|
|
// GS: "/GS-"
|
|
|
|
|
2016-11-09 08:56:42 +08:00
|
|
|
// RUN: %clang_cl /fallback /Zc:threadSafeInit -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafe %s
|
|
|
|
// ThreadSafe: /Zc:threadSafeInit
|
|
|
|
|
|
|
|
// RUN: %clang_cl /fallback /Zc:threadSafeInit- -### -- %s 2>&1 | FileCheck -check-prefix=NonThreadSafe %s
|
|
|
|
// NonThreadSafe: /Zc:threadSafeInit-
|
|
|
|
|
2013-09-25 02:17:21 +08:00
|
|
|
// RUN: %clang_cl /fallback /Od -### -- %s 2>&1 | FileCheck -check-prefix=O0 %s
|
|
|
|
// O0: cl.exe
|
|
|
|
// O0: "/Od"
|
2015-08-25 08:46:45 +08:00
|
|
|
// RUN: %clang_cl --target=i686-pc-win32 /fallback /O1 -### -- %s 2>&1 | FileCheck -check-prefix=O1 %s
|
2013-09-25 02:17:21 +08:00
|
|
|
// O1: cl.exe
|
2015-07-27 15:32:11 +08:00
|
|
|
// O1: "/Og" "/Os" "/Ob2" "/Oy" "/GF" "/Gy"
|
2015-08-25 08:46:45 +08:00
|
|
|
// RUN: %clang_cl --target=i686-pc-win32 /fallback /O2 -### -- %s 2>&1 | FileCheck -check-prefix=O2 %s
|
2013-09-25 02:17:21 +08:00
|
|
|
// O2: cl.exe
|
2015-07-27 15:32:11 +08:00
|
|
|
// O2: "/Oi" "/Og" "/Ot" "/Ob2" "/Oy" "/GF" "/Gy"
|
2015-08-25 08:46:45 +08:00
|
|
|
// RUN: %clang_cl --target=i686-pc-win32 /fallback /Os -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
|
2013-09-25 02:17:21 +08:00
|
|
|
// Os: cl.exe
|
2015-07-27 15:32:11 +08:00
|
|
|
// Os: "/Os"
|
2015-08-25 08:46:45 +08:00
|
|
|
// RUN: %clang_cl --target=i686-pc-win32 /fallback /Ox -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
|
2013-09-25 02:17:21 +08:00
|
|
|
// Ox: cl.exe
|
2015-07-27 15:32:11 +08:00
|
|
|
// Ox: "/Oi" "/Og" "/Ot" "/Ob2" "/Oy" "/GF"
|
2014-01-14 06:24:42 +08:00
|
|
|
|
|
|
|
// Only fall back when actually compiling, not for e.g. /P (preprocess).
|
|
|
|
// RUN: %clang_cl /fallback /P -### -- %s 2>&1 | FileCheck -check-prefix=P %s
|
|
|
|
// P-NOT: ||
|
|
|
|
// P-NOT: "cl.exe"
|
2014-02-19 05:42:51 +08:00
|
|
|
|
|
|
|
// RUN: not %clang_cl /fallback /c -- %s 2>&1 | \
|
2014-02-19 10:10:19 +08:00
|
|
|
// RUN: FileCheck -check-prefix=ErrWarn %s
|
|
|
|
// ErrWarn: warning: falling back to {{.*}}cl.exe
|
2014-02-19 05:42:51 +08:00
|
|
|
|
2014-05-15 00:03:05 +08:00
|
|
|
// RUN: %clang_cl /fallback /c /GR /GR- -### -- %s 2>&1 | \
|
|
|
|
// RUN: FileCheck -check-prefix=NO_RTTI %s
|
|
|
|
// NO_RTTI: "-cc1"
|
|
|
|
// NO_RTTI: ||
|
|
|
|
// NO_RTTI: cl.exe
|
2014-07-02 06:24:56 +08:00
|
|
|
// NO_RTTI: "/GR-"
|
2014-05-15 00:03:05 +08:00
|
|
|
|
2014-04-26 00:44:17 +08:00
|
|
|
// Don't fall back on non-C or C++ files.
|
|
|
|
// RUN: %clang_cl /fallback -### -- %S/Inputs/file.ll 2>&1 | FileCheck -check-prefix=LL %s
|
|
|
|
// LL: file.ll
|
|
|
|
// LL-NOT: ||
|
|
|
|
// LL-NOT: "cl.exe"
|
|
|
|
|
|
|
|
|
2014-02-19 05:42:51 +08:00
|
|
|
#error "This fails to compile."
|