Skip to content

Commit 9263936

Browse files
committed
RuntimeLibcalls: Avoid reporting __stack_chk_guard as available for msvc
The predicate system is currently primitive and alternative call predicates should be mutually exclusive.
1 parent 60f5c59 commit 9263936

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ def isWindowsMSVCEnvironment : RuntimeLibcallPredicate<
3232
def isNotOSLinuxAndNotOSOpenBSD : RuntimeLibcallPredicate<
3333
[{!TT.isOSLinux() && !TT.isOSOpenBSD()}]>;
3434

35+
def isNotOSAIXAndNotOSOpenBSD : RuntimeLibcallPredicate<
36+
[{!TT.isOSAIX() && !TT.isOSOpenBSD()}]>;
37+
38+
// OpenBSD uses __guard_local. AIX uses __ssp_canary_word, MSVC/Windows
39+
// Itanium uses __security_cookie
40+
def hasStackChkFail : RuntimeLibcallPredicate<
41+
[{ !TT.isOSOpenBSD() && !TT.isWindowsMSVCEnvironment() &&
42+
!TT.isWindowsItaniumEnvironment()}]>;
43+
3544
def isWindowsMSVCOrItaniumEnvironment : RuntimeLibcallPredicate<
3645
[{TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment()}]>;
3746

@@ -1241,9 +1250,9 @@ defvar LibmHasLdexpF80 = LibcallImpls<(add ldexpl_f80), isNotOSWindowsOrIsCygwin
12411250
defvar LibmHasFrexpF128 = LibcallImpls<(add frexpl_f128), isNotOSWindowsOrIsCygwinMinGW>;
12421251
defvar LibmHasLdexpF128 = LibcallImpls<(add ldexpl_f128), isNotOSWindowsOrIsCygwinMinGW>;
12431252

1244-
defvar has__stack_chk_fail = LibcallImpls<(add __stack_chk_fail), isNotOSOpenBSD>;
1253+
defvar has__stack_chk_fail = LibcallImpls<(add __stack_chk_fail), hasStackChkFail>;
12451254
defvar has__stack_chk_guard =
1246-
LibcallImpls<(add __stack_chk_guard), isNotOSOpenBSD>;
1255+
LibcallImpls<(add __stack_chk_guard), hasStackChkFail>;
12471256
defvar has__stack_smash_handler = LibcallImpls<(add __stack_smash_handler), isOSOpenBSD>;
12481257
defvar has___guard_local = LibcallImpls<(add __guard_local), isOSOpenBSD>;
12491258

@@ -2316,11 +2325,11 @@ def PPCSystemLibrary
23162325
LibmHasSinCosPPCF128,
23172326
AvailableIf<memcpy, isNotAIX>,
23182327
LibcallImpls<(add Int128RTLibcalls), isPPC64>,
2319-
has__stack_chk_fail,
23202328
has__stack_smash_handler,
23212329
has___guard_local,
23222330
AvailableIf<__ssp_canary_word, isAIX>,
2323-
AvailableIf<__stack_chk_guard, isNotAIX>)>;
2331+
AvailableIf<__stack_chk_fail, isNotOSOpenBSD>,
2332+
AvailableIf<__stack_chk_guard, isNotOSAIXAndNotOSOpenBSD>)>;
23242333

23252334
//===----------------------------------------------------------------------===//
23262335
// RISCV Runtime Libcalls

0 commit comments

Comments
 (0)