llvm.org GIT mirror llvm / a6a3cde
Revert "Merging r328039:" This reverts commit r332001. I forgot to run make check before committing and the tests cases with this patch fail. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@332008 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 2 years ago
3 changed file(s) with 4 addition(s) and 208 deletion(s). Raw diff Collapse all Expand all
20642064
20652065 void X86TargetLowering::insertSSPDeclarations(Module &M) const {
20662066 // MSVC CRT provides functionalities for stack protection.
2067 if (Subtarget.getTargetTriple().isWindowsMSVCEnvironment() ||
2068 Subtarget.getTargetTriple().isWindowsItaniumEnvironment()) {
2067 if (Subtarget.getTargetTriple().isOSMSVCRT()) {
20692068 // MSVC CRT has a global variable holding security cookie.
20702069 M.getOrInsertGlobal("__security_cookie",
20712070 Type::getInt8PtrTy(M.getContext()));
20872086
20882087 Value *X86TargetLowering::getSDagStackGuard(const Module &M) const {
20892088 // MSVC CRT has a global variable holding security cookie.
2090 if (Subtarget.getTargetTriple().isWindowsMSVCEnvironment() ||
2091 Subtarget.getTargetTriple().isWindowsItaniumEnvironment()) {
2089 if (Subtarget.getTargetTriple().isOSMSVCRT())
20922090 return M.getGlobalVariable("__security_cookie");
2093 }
20942091 return TargetLowering::getSDagStackGuard(M);
20952092 }
20962093
20972094 Value *X86TargetLowering::getSSPStackGuardCheck(const Module &M) const {
20982095 // MSVC CRT has a function to validate security cookie.
2099 if (Subtarget.getTargetTriple().isWindowsMSVCEnvironment() ||
2100 Subtarget.getTargetTriple().isWindowsItaniumEnvironment()) {
2096 if (Subtarget.getTargetTriple().isOSMSVCRT())
21012097 return M.getFunction("__security_check_cookie");
2102 }
21032098 return TargetLowering::getSSPStackGuardCheck(M);
21042099 }
21052100
33 ; RUN: llc -mtriple=x86_64-apple-darwin < %s -o - | FileCheck --check-prefix=DARWIN-X64 %s
44 ; RUN: llc -mtriple=amd64-pc-openbsd < %s -o - | FileCheck --check-prefix=OPENBSD-AMD64 %s
55 ; RUN: llc -mtriple=i386-pc-windows-msvc < %s -o - | FileCheck -check-prefix=MSVC-I386 %s
6 ; RUN: llc -mtriple=x86_64-w64-mingw32 < %s -o - | FileCheck --check-prefix=MINGW-X64 %s
76
87 %struct.foo = type { [16 x i8] }
98 %struct.foo.0 = type { [4 x i8] }
4544 ; MSVC-I386-LABEL: test1a:
4645 ; MSVC-I386-NOT: calll @__security_check_cookie@4
4746 ; MSVC-I386: retl
48
49 ; MINGW-X64-LABEL: test1a:
50 ; MINGW-X64-NOT: callq __stack_chk_fail
51 ; MINGW-X64: .seh_endproc
52
5347 %a.addr = alloca i8*, align 8
5448 %buf = alloca [16 x i8], align 16
5549 store i8* %a, i8** %a.addr, align 8
9084 ; MSVC-I386-LABEL: test1b:
9185 ; MSVC-I386: movl ___security_cookie,
9286 ; MSVC-I386: calll @__security_check_cookie@4
93
94 ; MINGW-X64-LABEL: test1b:
95 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
96 ; MINGW-X64: callq __stack_chk_fail
97
9887 %a.addr = alloca i8*, align 8
9988 %buf = alloca [16 x i8], align 16
10089 store i8* %a, i8** %a.addr, align 8
131120 ; MSVC-I386-LABEL: test1c:
132121 ; MSVC-I386: movl ___security_cookie,
133122 ; MSVC-I386: calll @__security_check_cookie@4
134
135 ; MINGW-X64-LABEL: test1c:
136 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
137 ; MINGW-X64: callq __stack_chk_fail
138
139123 %a.addr = alloca i8*, align 8
140124 %buf = alloca [16 x i8], align 16
141125 store i8* %a, i8** %a.addr, align 8
172156 ; MSVC-I386-LABEL: test1d:
173157 ; MSVC-I386: movl ___security_cookie,
174158 ; MSVC-I386: calll @__security_check_cookie@4
175
176 ; MINGW-X64-LABEL: test1d:
177 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
178 ; MINGW-X64: callq __stack_chk_fail
179
180159 %a.addr = alloca i8*, align 8
181160 %buf = alloca [16 x i8], align 16
182161 store i8* %a, i8** %a.addr, align 8
212191 ; MSVC-I386-LABEL: test2a:
213192 ; MSVC-I386-NOT: calll @__security_check_cookie@4
214193 ; MSVC-I386: retl
215
216 ; MINGW-X64-LABEL: test2a:
217 ; MINGW-X64-NOT: callq __stack_chk_fail
218 ; MINGW-X64: .seh_endproc
219
220194 %a.addr = alloca i8*, align 8
221195 %b = alloca %struct.foo, align 1
222196 store i8* %a, i8** %a.addr, align 8
251225 ; DARWIN-X64-LABEL: test2b:
252226 ; DARWIN-X64: mov{{l|q}} ___stack_chk_guard
253227 ; DARWIN-X64: callq ___stack_chk_fail
254
255 ; MINGW-X64-LABEL: test2b:
256 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
257 ; MINGW-X64: callq __stack_chk_fail
258
259228 %a.addr = alloca i8*, align 8
260229 %b = alloca %struct.foo, align 1
261230 store i8* %a, i8** %a.addr, align 8
294263 ; MSVC-I386-LABEL: test2c:
295264 ; MSVC-I386: movl ___security_cookie,
296265 ; MSVC-I386: calll @__security_check_cookie@4
297
298 ; MINGW-X64-LABEL: test2c:
299 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
300 ; MINGW-X64: callq __stack_chk_fail
301
302266 %a.addr = alloca i8*, align 8
303267 %b = alloca %struct.foo, align 1
304268 store i8* %a, i8** %a.addr, align 8
337301 ; MSVC-I386-LABEL: test2d:
338302 ; MSVC-I386: movl ___security_cookie,
339303 ; MSVC-I386: calll @__security_check_cookie@4
340
341 ; MINGW-X64-LABEL: test2d:
342 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
343 ; MINGW-X64: callq __stack_chk_fail
344
345304 %a.addr = alloca i8*, align 8
346305 %b = alloca %struct.foo, align 1
347306 store i8* %a, i8** %a.addr, align 8
379338 ; MSVC-I386-LABEL: test3a:
380339 ; MSVC-I386-NOT: calll @__security_check_cookie@4
381340 ; MSVC-I386: retl
382
383 ; MINGW-X64-LABEL: test3a:
384 ; MINGW-X64-NOT: callq __stack_chk_fail
385 ; MINGW-X64: .seh_endproc
386
387341 %a.addr = alloca i8*, align 8
388342 %buf = alloca [4 x i8], align 1
389343 store i8* %a, i8** %a.addr, align 8
420374 ; MSVC-I386-LABEL: test3b:
421375 ; MSVC-I386-NOT: calll @__security_check_cookie@4
422376 ; MSVC-I386: retl
423
424 ; MINGW-X64-LABEL: test3b:
425 ; MINGW-X64-NOT: callq __stack_chk_fail
426 ; MINGW-X64: .seh_endproc
427
428377 %a.addr = alloca i8*, align 8
429378 %buf = alloca [4 x i8], align 1
430379 store i8* %a, i8** %a.addr, align 8
461410 ; MSVC-I386-LABEL: test3c:
462411 ; MSVC-I386: movl ___security_cookie,
463412 ; MSVC-I386: calll @__security_check_cookie@4
464
465 ; MINGW-X64-LABEL: test3c:
466 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
467 ; MINGW-X64: callq __stack_chk_fail
468
469413 %a.addr = alloca i8*, align 8
470414 %buf = alloca [4 x i8], align 1
471415 store i8* %a, i8** %a.addr, align 8
502446 ; MSVC-I386-LABEL: test3d:
503447 ; MSVC-I386: movl ___security_cookie,
504448 ; MSVC-I386: calll @__security_check_cookie@4
505
506 ; MINGW-X64-LABEL: test3d:
507 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
508 ; MINGW-X64: callq __stack_chk_fail
509
510449 %a.addr = alloca i8*, align 8
511450 %buf = alloca [4 x i8], align 1
512451 store i8* %a, i8** %a.addr, align 8
542481 ; MSVC-I386-LABEL: test4a:
543482 ; MSVC-I386-NOT: calll @__security_check_cookie@4
544483 ; MSVC-I386: retl
545
546 ; MINGW-X64-LABEL: test4a:
547 ; MINGW-X64-NOT: callq __stack_chk_fail
548 ; MINGW-X64: .seh_endproc
549
550484 %a.addr = alloca i8*, align 8
551485 %b = alloca %struct.foo.0, align 1
552486 store i8* %a, i8** %a.addr, align 8
585519 ; MSVC-I386-LABEL: test4b:
586520 ; MSVC-I386-NOT: calll @__security_check_cookie@4
587521 ; MSVC-I386: retl
588
589 ; MINGW-X64-LABEL: test4b:
590 ; MINGW-X64-NOT: callq __stack_chk_fail
591 ; MINGW-X64: .seh_endproc
592
593522 %a.addr = alloca i8*, align 8
594523 %b = alloca %struct.foo.0, align 1
595524 store i8* %a, i8** %a.addr, align 8
628557 ; MSVC-I386-LABEL: test4c:
629558 ; MSVC-I386: movl ___security_cookie,
630559 ; MSVC-I386: calll @__security_check_cookie@4
631
632 ; MINGW-X64-LABEL: test4c:
633 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
634 ; MINGW-X64: callq __stack_chk_fail
635
636560 %a.addr = alloca i8*, align 8
637561 %b = alloca %struct.foo.0, align 1
638562 store i8* %a, i8** %a.addr, align 8
671595 ; MSVC-I386-LABEL: test4d:
672596 ; MSVC-I386: movl ___security_cookie,
673597 ; MSVC-I386: calll @__security_check_cookie@4
674
675 ; MINGW-X64-LABEL: test4d:
676 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
677 ; MINGW-X64: callq __stack_chk_fail
678
679598 %a.addr = alloca i8*, align 8
680599 %b = alloca %struct.foo.0, align 1
681600 store i8* %a, i8** %a.addr, align 8
713632 ; MSVC-I386-LABEL: test5a:
714633 ; MSVC-I386-NOT: calll @__security_check_cookie@4
715634 ; MSVC-I386: retl
716
717 ; MINGW-X64-LABEL: test5a:
718 ; MINGW-X64-NOT: callq __stack_chk_fail
719 ; MINGW-X64: .seh_endproc
720
721635 %a.addr = alloca i8*, align 8
722636 store i8* %a, i8** %a.addr, align 8
723637 %0 = load i8*, i8** %a.addr, align 8
750664 ; MSVC-I386-LABEL: test5b:
751665 ; MSVC-I386-NOT: calll @__security_check_cookie@4
752666 ; MSVC-I386: retl
753
754 ; MINGW-X64-LABEL: test5b:
755 ; MINGW-X64-NOT: callq __stack_chk_fail
756 ; MINGW-X64: .seh_endproc
757
758667 %a.addr = alloca i8*, align 8
759668 store i8* %a, i8** %a.addr, align 8
760669 %0 = load i8*, i8** %a.addr, align 8
787696 ; MSVC-I386-LABEL: test5c:
788697 ; MSVC-I386-NOT: calll @__security_check_cookie@4
789698 ; MSVC-I386: retl
790
791 ; MINGW-X64-LABEL: test5c:
792 ; MINGW-X64-NOT: callq __stack_chk_fail
793 ; MINGW-X64: .seh_endproc
794
795699 %a.addr = alloca i8*, align 8
796700 store i8* %a, i8** %a.addr, align 8
797701 %0 = load i8*, i8** %a.addr, align 8
824728 ; MSVC-I386-LABEL: test5d:
825729 ; MSVC-I386: movl ___security_cookie,
826730 ; MSVC-I386: calll @__security_check_cookie@4
827
828 ; MINGW-X64-LABEL: test5d:
829 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
830 ; MINGW-X64: callq __stack_chk_fail
831
832731 %a.addr = alloca i8*, align 8
833732 store i8* %a, i8** %a.addr, align 8
834733 %0 = load i8*, i8** %a.addr, align 8
860759 ; MSVC-I386-LABEL: test6a:
861760 ; MSVC-I386-NOT: calll @__security_check_cookie@4
862761 ; MSVC-I386: retl
863
864 ; MINGW-X64-LABEL: test6a:
865 ; MINGW-X64-NOT: callq __stack_chk_fail
866 ; MINGW-X64: .seh_endproc
867
868762 %retval = alloca i32, align 4
869763 %a = alloca i32, align 4
870764 %j = alloca i32*, align 8
898792 ; DARWIN-X64-NOT: callq ___stack_chk_fail
899793 ; DARWIN-X64: .cfi_endproc
900794
795
901796 ; MSVC-I386-LABEL: test6b:
902797 ; MSVC-I386-NOT: calll @__security_check_cookie@4
903798 ; MSVC-I386: retl
904
905 ; MINGW-X64-LABEL: test6b:
906 ; MINGW-X64-NOT: callq __stack_chk_fail
907 ; MINGW-X64: .seh_endproc
908
909799 %retval = alloca i32, align 4
910800 %a = alloca i32, align 4
911801 %j = alloca i32*, align 8
942832 ; MSVC-I386-LABEL: test6c:
943833 ; MSVC-I386: movl ___security_cookie,
944834 ; MSVC-I386: calll @__security_check_cookie@4
945
946 ; MINGW-X64-LABEL: test6c:
947 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
948 ; MINGW-X64: callq __stack_chk_fail
949
950835 %retval = alloca i32, align 4
951836 %a = alloca i32, align 4
952837 %j = alloca i32*, align 8
983868 ; MSVC-I386-LABEL: test6d:
984869 ; MSVC-I386: movl ___security_cookie,
985870 ; MSVC-I386: calll @__security_check_cookie@4
986
987 ; MINGW-X64-LABEL: test6d:
988 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
989 ; MINGW-X64: callq __stack_chk_fail
990
991871 %retval = alloca i32, align 4
992872 %a = alloca i32, align 4
993873 %j = alloca i32*, align 8
1023903 ; MSVC-I386-LABEL: test7a:
1024904 ; MSVC-I386-NOT: calll @__security_check_cookie@4
1025905 ; MSVC-I386: retl
1026
1027 ; MINGW-X64-LABEL: test7a:
1028 ; MINGW-X64-NOT: callq __stack_chk_fail
1029 ; MINGW-X64: .seh_endproc
1030
1031906 %a = alloca i32, align 4
1032907 %0 = ptrtoint i32* %a to i64
1033908 %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i64 %0)
1059934 ; MSVC-I386-LABEL: test7b:
1060935 ; MSVC-I386-NOT: calll @__security_check_cookie@4
1061936 ; MSVC-I386: retl
1062
1063 ; MINGW-X64-LABEL: test7b:
1064 ; MINGW-X64-NOT: callq __stack_chk_fail
1065 ; MINGW-X64: .seh_endproc
1066
1067937 %a = alloca i32, align 4
1068938 %0 = ptrtoint i32* %a to i64
1069939 %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i64 %0)
1095965 ; MSVC-I386-LABEL: test7c:
1096966 ; MSVC-I386: movl ___security_cookie,
1097967 ; MSVC-I386: calll @__security_check_cookie@4
1098
1099 ; MINGW-X64-LABEL: test7c:
1100 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
1101 ; MINGW-X64: .seh_endproc
1102
1103968 %a = alloca i32, align 4
1104969 %0 = ptrtoint i32* %a to i64
1105970 %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i64 %0)
1131996 ; MSVC-I386-LABEL: test7d:
1132997 ; MSVC-I386: movl ___security_cookie,
1133998 ; MSVC-I386: calll @__security_check_cookie@4
1134
1135 ; MINGW-X64-LABEL: test7d:
1136 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
1137 ; MINGW-X64: callq __stack_chk_fail
1138
1139999 %a = alloca i32, align 4
11401000 %0 = ptrtoint i32* %a to i64
11411001 %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i64 %0)
11661026 ; MSVC-I386-LABEL: test8a:
11671027 ; MSVC-I386-NOT: calll @__security_check_cookie@4
11681028 ; MSVC-I386: retl
1169
1170 ; MINGW-X64-LABEL: test8a:
1171 ; MINGW-X64-NOT: callq __stack_chk_fail
1172 ; MINGW-X64: .seh_endproc
1173
11741029 %b = alloca i32, align 4
11751030 call void @funcall(i32* %b)
11761031 ret void
12011056 ; MSVC-I386-LABEL: test8b:
12021057 ; MSVC-I386-NOT: calll @__security_check_cookie@4
12031058 ; MSVC-I386: retl
1204
1205 ; MINGW-X64-LABEL: test8b:
1206 ; MINGW-X64-NOT: callq __stack_chk_fail
1207 ; MINGW-X64: .seh_endproc
1208
12091059 %b = alloca i32, align 4
12101060 call void @funcall(i32* %b)
12111061 ret void
12361086 ; MSVC-I386-LABEL: test8c:
12371087 ; MSVC-I386: movl ___security_cookie,
12381088 ; MSVC-I386: calll @__security_check_cookie@4
1239
1240 ; MINGW-X64-LABEL: test8c:
1241 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
1242 ; MINGW-X64: callq __stack_chk_fail
1243
12441089 %b = alloca i32, align 4
12451090 call void @funcall(i32* %b)
12461091 ret void
12711116 ; MSVC-I386-LABEL: test8d:
12721117 ; MSVC-I386: movl ___security_cookie,
12731118 ; MSVC-I386: calll @__security_check_cookie@4
1274
1275 ; MINGW-X64-LABEL: test8d:
1276 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
1277 ; MINGW-X64: callq __stack_chk_fail
1278
12791119 %b = alloca i32, align 4
12801120 call void @funcall(i32* %b)
12811121 ret void
28462686 ; MSVC-I386-LABEL: test19d:
28472687 ; MSVC-I386: movl ___security_cookie,
28482688 ; MSVC-I386: calll @__security_check_cookie@4
2849
2850 ; MINGW-X64-LABEL: test19d:
2851 ; MINGW-X64: mov{{l|q}} __stack_chk_guard
2852 ; MINGW-X64: callq __stack_chk_fail
2853
28542689 %c = alloca %struct.pair, align 4
28552690 %exn.slot = alloca i8*
28562691 %ehselector.slot = alloca i32
36193454 ; MSVC-I386-LABEL: test25b:
36203455 ; MSVC-I386-NOT: calll @__security_check_cookie@4
36213456 ; MSVC-I386: retl
3622
3623 ; MINGW-X64-LABEL: test25b:
3624 ; MINGW-X64-NOT: callq __stack_chk_fail
3625 ; MINGW-X64: .seh_endproc
3626
36273457 %a = alloca [4 x i32], align 16
36283458 %arrayidx = getelementptr inbounds [4 x i32], [4 x i32]* %a, i32 0, i64 0
36293459 %0 = load i32, i32* %arrayidx, align 4
+0
-29
test/CodeGen/X86/win32-ssp.ll less more
None ; RUN: llc -mtriple=x86_64-w64-mingw32 < %s -o - | FileCheck --check-prefix=MINGW %s
1 ; RUN: llc -mtriple=x86_64-pc-windows-itanium < %s -o - | FileCheck --check-prefix=MSVC %s
2 ; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s -o - | FileCheck --check-prefix=MSVC %s
3
4 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
5 declare dso_local void @other(i8*)
6 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
7
8 define dso_local void @func() sspstrong {
9 entry:
10 ; MINGW-LABEL: func:
11 ; MINGW: mov{{l|q}} __stack_chk_guard
12 ; MINGW: callq other
13 ; MINGW: mov{{l|q}} __stack_chk_guard
14 ; MINGW: callq __stack_chk_fail
15 ; MINGW: .seh_endproc
16
17 ; MSVC-LABEL: func:
18 ; MSVC: mov{{l|q}} __security_cookie
19 ; MSVC: callq other
20 ; MSVC: callq __security_check_cookie
21 ; MSVC: .seh_endproc
22
23 %c = alloca i8, align 1
24 call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %c)
25 call void @other(i8* nonnull %c)
26 call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull %c)
27 ret void
28 }