1; RUN: split-file %s %t 2; RUN: cat %t/main.ll %t/a.ll > %t/a2.ll 3; RUN: cat %t/main.ll %t/b.ll > %t/b2.ll 4; RUN: cat %t/main.ll %t/c.ll > %t/c2.ll 5; RUN: cat %t/main.ll %t/d.ll > %t/d2.ll 6; RUN: cat %t/main.ll %t/e.ll > %t/e2.ll 7; RUN: cat %t/main.ll %t/f.ll > %t/f2.ll 8; RUN: cat %t/main.ll %t/g.ll > %t/g2.ll 9; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/a2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s 10; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/b2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s 11; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/c2.ll | FileCheck --check-prefix=CHECK-GLOBAL %s 12; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/d2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s 13; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/e2.ll | FileCheck --check-prefix=CHECK-GS %s 14; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/f2.ll | FileCheck --check-prefix=CHECK-OFFSET %s 15; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/g2.ll | FileCheck --check-prefix=CHECK-NEGATIVE-OFFSET %s 16 17;--- main.ll 18 19; CHECK-TLS-FS-40: movq %fs:40, %rax 20; CHECK-TLS-FS-40: movq %fs:40, %rax 21; CHECK-TLS-FS-40-NEXT: cmpq 16(%rsp), %rax 22; CHECK-TLS-FS-40-NEXT: jne .LBB0_2 23; CHECK-TLS-FS-40: .LBB0_2: 24; CHECK-TLS-FS-40-NEXT: .cfi_def_cfa_offset 32 25; CHECK-TLS-FS-40-NEXT: callq __stack_chk_fail 26 27; CHECK-GS: movq %gs:40, %rax 28; CHECK-GS: movq %gs:40, %rax 29; CHECK-GS-NEXT: cmpq 16(%rsp), %rax 30; CHECK-GS-NEXT: jne .LBB0_2 31; CHECK-GS: .LBB0_2: 32; CHECK-GS-NEXT: .cfi_def_cfa_offset 32 33; CHECK-GS-NEXT: callq __stack_chk_fail 34 35; CHECK-OFFSET: movq %fs:20, %rax 36; CHECK-OFFSET: movq %fs:20, %rax 37; CHECK-OFFSET-NEXT: cmpq 16(%rsp), %rax 38; CHECK-OFFSET-NEXT: jne .LBB0_2 39; CHECK-OFFSET: .LBB0_2: 40; CHECK-OFFSET-NEXT: .cfi_def_cfa_offset 32 41; CHECK-OFFSET-NEXT: callq __stack_chk_fail 42 43; CHECK-NEGATIVE-OFFSET: movl $4294967276, %eax # imm = 0xFFFFFFEC 44; CHECK-NEGATIVE-OFFSET: movq %fs:(%rax), %rcx 45; CHECK-NEGATIVE-OFFSET: movq %fs:(%rax), %rax 46; CHECK-NEGATIVE-OFFSET-NEXT: cmpq 16(%rsp), %rax 47; CHECK-NEGATIVE-OFFSET-NEXT: jne .LBB0_2 48; CHECK-NEGATIVE-OFFSET: .LBB0_2: 49; CHECK-NEGATIVE-OFFSET-NEXT: .cfi_def_cfa_offset 32 50; CHECK-NEGATIVE-OFFSET-NEXT: callq __stack_chk_fail 51 52; CHECK-GLOBAL: movq __stack_chk_guard(%rip), %rax 53; CHECK-GLOBAL: movq __stack_chk_guard(%rip), %rax 54; CHECK-GLOBAL-NEXT: cmpq 16(%rsp), %rax 55; CHECK-GLOBAL-NEXT: jne .LBB0_2 56; CHECK-GLOBAL: .LBB0_2: 57; CHECK-GLOBAL-NEXT: .cfi_def_cfa_offset 32 58; CHECK-GLOBAL-NEXT: callq __stack_chk_fail 59 60; ModuleID = 't.c' 61@.str = private unnamed_addr constant [14 x i8] c"stackoverflow\00", align 1 62@a = dso_local local_unnamed_addr global i8* null, align 8 63 64; Function Attrs: nounwind sspreq uwtable writeonly 65define dso_local i32 @main() local_unnamed_addr #0 { 66entry: 67 %array = alloca [5 x i8], align 1 68 %0 = getelementptr inbounds [5 x i8], [5 x i8]* %array, i64 0, i64 0 69 call void @llvm.lifetime.start.p0i8(i64 5, i8* nonnull %0) #2 70 call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 dereferenceable(14) %0, i8* nonnull align 1 dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 14, i1 false) #2 71 store i8* %0, i8** @a, align 8 72 call void @llvm.lifetime.end.p0i8(i64 5, i8* nonnull %0) #2 73 ret i32 0 74} 75 76; Function Attrs: argmemonly nounwind willreturn 77declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 78 79; Function Attrs: argmemonly nounwind willreturn 80declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 81 82; Function Attrs: argmemonly nounwind willreturn 83declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #1 84 85attributes #0 = { nounwind sspreq uwtable writeonly "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" } 86attributes #1 = { argmemonly nounwind willreturn } 87attributes #2 = { nounwind } 88 89;--- a.ll 90;--- b.ll 91!llvm.module.flags = !{!1} 92!1 = !{i32 2, !"stack-protector-guard", !"tls"} 93;--- c.ll 94!llvm.module.flags = !{!1} 95!1 = !{i32 2, !"stack-protector-guard", !"global"} 96;--- d.ll 97!llvm.module.flags = !{!1} 98!1 = !{i32 2, !"stack-protector-guard-reg", !"fs"} 99;--- e.ll 100!llvm.module.flags = !{!1} 101!1 = !{i32 2, !"stack-protector-guard-reg", !"gs"} 102;--- f.ll 103!llvm.module.flags = !{!1} 104!1 = !{i32 2, !"stack-protector-guard-offset", i32 20} 105;--- g.ll 106!llvm.module.flags = !{!1} 107!1 = !{i32 2, !"stack-protector-guard-offset", i32 -20} 108