You've already forked linux-packaging-mono
Imported Upstream version 5.18.0.167
Former-commit-id: 289509151e0fee68a1b591a20c9f109c3c789d3a
This commit is contained in:
parent
e19d552987
commit
b084638f15
@ -1,20 +0,0 @@
|
||||
; RUN: opt -safe-stack -S -mtriple=aarch64-linux-android < %s -o - | FileCheck %s
|
||||
|
||||
|
||||
define void @foo() nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK: %[[TP:.*]] = call i8* @llvm.thread.pointer()
|
||||
; CHECK: %[[SPA0:.*]] = getelementptr i8, i8* %[[TP]], i32 72
|
||||
; CHECK: %[[SPA:.*]] = bitcast i8* %[[SPA0]] to i8**
|
||||
; CHECK: %[[USP:.*]] = load i8*, i8** %[[SPA]]
|
||||
; CHECK: %[[USST:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
|
||||
; CHECK: store i8* %[[USST]], i8** %[[SPA]]
|
||||
|
||||
%a = alloca i8, align 8
|
||||
call void @Capture(i8* %a)
|
||||
|
||||
; CHECK: store i8* %[[USP]], i8** %[[SPA]]
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @Capture(i8*)
|
@ -1,23 +0,0 @@
|
||||
; RUN: opt -safe-stack -S -mtriple=aarch64-linux-android < %s -o - | FileCheck --check-prefixes=TLS,ANDROID %s
|
||||
; RUN: opt -safe-stack -S -mtriple=aarch64-unknown-fuchsia < %s -o - | FileCheck --check-prefixes=TLS,FUCHSIA %s
|
||||
|
||||
define void @foo() nounwind uwtable safestack sspreq {
|
||||
entry:
|
||||
; The first @llvm.thread.pointer is for the unsafe stack pointer, skip it.
|
||||
; TLS: call i8* @llvm.thread.pointer()
|
||||
|
||||
; TLS: %[[TP2:.*]] = call i8* @llvm.thread.pointer()
|
||||
; ANDROID: %[[B:.*]] = getelementptr i8, i8* %[[TP2]], i32 40
|
||||
; FUCHSIA: %[[B:.*]] = getelementptr i8, i8* %[[TP2]], i32 -16
|
||||
; TLS: %[[C:.*]] = bitcast i8* %[[B]] to i8**
|
||||
; TLS: %[[StackGuard:.*]] = load i8*, i8** %[[C]]
|
||||
; TLS: store i8* %[[StackGuard]], i8** %[[StackGuardSlot:.*]]
|
||||
%a = alloca i128, align 16
|
||||
call void @Capture(i128* %a)
|
||||
|
||||
; TLS: %[[A:.*]] = load i8*, i8** %[[StackGuardSlot]]
|
||||
; TLS: icmp ne i8* %[[StackGuard]], %[[A]]
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @Capture(i128*)
|
@ -1,3 +0,0 @@
|
||||
if not 'AArch64' in config.root.targets:
|
||||
config.unsupported = True
|
||||
|
@ -1,18 +0,0 @@
|
||||
; RUN: opt -safe-stack -S -mtriple=arm-linux-android < %s -o - | FileCheck %s
|
||||
|
||||
|
||||
define void @foo() nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK: %[[SPA:.*]] = call i8** @__safestack_pointer_address()
|
||||
; CHECK: %[[USP:.*]] = load i8*, i8** %[[SPA]]
|
||||
; CHECK: %[[USST:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
|
||||
; CHECK: store i8* %[[USST]], i8** %[[SPA]]
|
||||
|
||||
%a = alloca i8, align 8
|
||||
call void @Capture(i8* %a)
|
||||
|
||||
; CHECK: store i8* %[[USP]], i8** %[[SPA]]
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @Capture(i8*)
|
@ -1,3 +0,0 @@
|
||||
if not 'ARM' in config.root.targets:
|
||||
config.unsupported = True
|
||||
|
@ -1,36 +0,0 @@
|
||||
; Test stack pointer restore after setjmp() with the function-call safestack ABI.
|
||||
; RUN: opt -safe-stack -S -mtriple=arm-linux-androideabi < %s -o - | FileCheck %s
|
||||
|
||||
@env = global [64 x i32] zeroinitializer, align 4
|
||||
|
||||
define void @f(i32 %b) safestack {
|
||||
entry:
|
||||
; CHECK: %[[SPA:.*]] = call i8** @__safestack_pointer_address()
|
||||
; CHECK: %[[USP:.*]] = load i8*, i8** %[[SPA]]
|
||||
; CHECK: %[[USDP:.*]] = alloca i8*
|
||||
; CHECK: store i8* %[[USP]], i8** %[[USDP]]
|
||||
; CHECK: call i32 @setjmp
|
||||
|
||||
%call = call i32 @setjmp(i32* getelementptr inbounds ([64 x i32], [64 x i32]* @env, i32 0, i32 0)) returns_twice
|
||||
|
||||
; CHECK: %[[USP2:.*]] = load i8*, i8** %[[USDP]]
|
||||
; CHECK: store i8* %[[USP2]], i8** %[[SPA]]
|
||||
|
||||
%tobool = icmp eq i32 %b, 0
|
||||
br i1 %tobool, label %if.end, label %if.then
|
||||
|
||||
if.then:
|
||||
%0 = alloca [42 x i8], align 1
|
||||
%.sub = getelementptr inbounds [42 x i8], [42 x i8]* %0, i32 0, i32 0
|
||||
call void @_Z7CapturePv(i8* %.sub)
|
||||
br label %if.end
|
||||
|
||||
if.end:
|
||||
; CHECK: store i8* %[[USP:.*]], i8** %[[SPA:.*]]
|
||||
|
||||
ret void
|
||||
}
|
||||
|
||||
declare i32 @setjmp(i32*) returns_twice
|
||||
|
||||
declare void @_Z7CapturePv(i8*)
|
@ -1,30 +0,0 @@
|
||||
; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s --check-prefix=TLS
|
||||
; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s --check-prefix=TLS
|
||||
; RUN: opt -safe-stack -S -mtriple=i686-linux-android < %s -o - | FileCheck %s --check-prefix=DIRECT-TLS32
|
||||
; RUN: opt -safe-stack -S -mtriple=x86_64-linux-android < %s -o - | FileCheck %s --check-prefix=DIRECT-TLS64
|
||||
|
||||
|
||||
define void @foo() nounwind uwtable safestack {
|
||||
entry:
|
||||
; TLS: %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr
|
||||
; TLS: %[[USST:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
|
||||
; TLS: store i8* %[[USST]], i8** @__safestack_unsafe_stack_ptr
|
||||
|
||||
; DIRECT-TLS32: %[[USP:.*]] = load i8*, i8* addrspace(256)* inttoptr (i32 36 to i8* addrspace(256)*)
|
||||
; DIRECT-TLS32: %[[USST:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
|
||||
; DIRECT-TLS32: store i8* %[[USST]], i8* addrspace(256)* inttoptr (i32 36 to i8* addrspace(256)*)
|
||||
|
||||
; DIRECT-TLS64: %[[USP:.*]] = load i8*, i8* addrspace(257)* inttoptr (i32 72 to i8* addrspace(257)*)
|
||||
; DIRECT-TLS64: %[[USST:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
|
||||
; DIRECT-TLS64: store i8* %[[USST]], i8* addrspace(257)* inttoptr (i32 72 to i8* addrspace(257)*)
|
||||
|
||||
%a = alloca i8, align 8
|
||||
call void @Capture(i8* %a)
|
||||
|
||||
; TLS: store i8* %[[USP]], i8** @__safestack_unsafe_stack_ptr
|
||||
; DIRECT-TLS32: store i8* %[[USP]], i8* addrspace(256)* inttoptr (i32 36 to i8* addrspace(256)*)
|
||||
; DIRECT-TLS64: store i8* %[[USP]], i8* addrspace(257)* inttoptr (i32 72 to i8* addrspace(257)*)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @Capture(i8*)
|
@ -1,26 +0,0 @@
|
||||
; RUN: opt -safe-stack -S -mtriple=i686-pc-linux-gnu < %s -o - | FileCheck --check-prefixes=COMMON,TLS32 %s
|
||||
; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck --check-prefixes=COMMON,TLS64 %s
|
||||
|
||||
; RUN: opt -safe-stack -S -mtriple=i686-linux-android < %s -o - | FileCheck --check-prefixes=COMMON,GLOBAL32 %s
|
||||
; RUN: opt -safe-stack -S -mtriple=i686-linux-android24 < %s -o - | FileCheck --check-prefixes=COMMON,TLS32 %s
|
||||
|
||||
; RUN: opt -safe-stack -S -mtriple=x86_64-linux-android < %s -o - | FileCheck --check-prefixes=COMMON,TLS64 %s
|
||||
|
||||
; RUN: opt -safe-stack -S -mtriple=x86_64-unknown-fuchsia < %s -o - | FileCheck --check-prefixes=COMMON,FUCHSIA64 %s
|
||||
|
||||
define void @foo() safestack sspreq {
|
||||
entry:
|
||||
; TLS32: %[[StackGuard:.*]] = load i8*, i8* addrspace(256)* inttoptr (i32 20 to i8* addrspace(256)*)
|
||||
; TLS64: %[[StackGuard:.*]] = load i8*, i8* addrspace(257)* inttoptr (i32 40 to i8* addrspace(257)*)
|
||||
; FUCHSIA64: %[[StackGuard:.*]] = load i8*, i8* addrspace(257)* inttoptr (i32 16 to i8* addrspace(257)*)
|
||||
; GLOBAL32: %[[StackGuard:.*]] = load i8*, i8** @__stack_chk_guard
|
||||
; COMMON: store i8* %[[StackGuard]], i8** %[[StackGuardSlot:.*]]
|
||||
%a = alloca i8, align 1
|
||||
call void @Capture(i8* %a)
|
||||
|
||||
; COMMON: %[[A:.*]] = load i8*, i8** %[[StackGuardSlot]]
|
||||
; COMMON: icmp ne i8* %[[StackGuard]], %[[A]]
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @Capture(i8*)
|
@ -1,22 +0,0 @@
|
||||
; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
|
||||
@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
|
||||
|
||||
; Address-of local taken (j = &a)
|
||||
; Requires protector.
|
||||
|
||||
define void @foo() nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK: __safestack_unsafe_stack_ptr
|
||||
%retval = alloca i32, align 4
|
||||
%a = alloca i32, align 4
|
||||
%j = alloca i32*, align 8
|
||||
store i32 0, i32* %retval
|
||||
%0 = load i32, i32* %a, align 4
|
||||
%add = add nsw i32 %0, 1
|
||||
store i32 %add, i32* %a, align 4
|
||||
store i32* %a, i32** %j, align 8
|
||||
ret void
|
||||
}
|
||||
|
@ -1,38 +0,0 @@
|
||||
; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
|
||||
@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
|
||||
|
||||
; array of [16 x i8]
|
||||
|
||||
define void @foo(i8* %a) nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK: %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr
|
||||
|
||||
; CHECK: %[[USST:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
|
||||
|
||||
; CHECK: store i8* %[[USST]], i8** @__safestack_unsafe_stack_ptr
|
||||
|
||||
%a.addr = alloca i8*, align 8
|
||||
%buf = alloca [16 x i8], align 16
|
||||
|
||||
; CHECK: %[[AADDR:.*]] = alloca i8*, align 8
|
||||
; CHECK: store i8* {{.*}}, i8** %[[AADDR]], align 8
|
||||
store i8* %a, i8** %a.addr, align 8
|
||||
|
||||
; CHECK: %[[BUFPTR:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
|
||||
; CHECK: %[[BUFPTR2:.*]] = bitcast i8* %[[BUFPTR]] to [16 x i8]*
|
||||
; CHECK: %[[GEP:.*]] = getelementptr inbounds [16 x i8], [16 x i8]* %[[BUFPTR2]], i32 0, i32 0
|
||||
%gep = getelementptr inbounds [16 x i8], [16 x i8]* %buf, i32 0, i32 0
|
||||
|
||||
; CHECK: %[[A2:.*]] = load i8*, i8** %[[AADDR]], align 8
|
||||
%a2 = load i8*, i8** %a.addr, align 8
|
||||
|
||||
; CHECK: call i8* @strcpy(i8* %[[GEP]], i8* %[[A2]])
|
||||
%call = call i8* @strcpy(i8* %gep, i8* %a2)
|
||||
|
||||
; CHECK: store i8* %[[USP]], i8** @__safestack_unsafe_stack_ptr
|
||||
ret void
|
||||
}
|
||||
|
||||
declare i8* @strcpy(i8*, i8*)
|
@ -1,89 +0,0 @@
|
||||
; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
; RUN: opt -safe-stack -S -mtriple=i386-pc-contiki-unknown < %s -o - | FileCheck -check-prefix=SINGLE-THREAD %s
|
||||
; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
|
||||
; array [4 x i8]
|
||||
; Requires protector.
|
||||
|
||||
; CHECK: @__safestack_unsafe_stack_ptr = external thread_local(initialexec) global i8*
|
||||
; SINGLE-THREAD: @__safestack_unsafe_stack_ptr = external global i8*
|
||||
|
||||
define void @foo(i8* %a) nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK: %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr
|
||||
|
||||
; CHECK: %[[USST:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
|
||||
|
||||
; CHECK: store i8* %[[USST]], i8** @__safestack_unsafe_stack_ptr
|
||||
|
||||
%a.addr = alloca i8*, align 8
|
||||
%buf = alloca [4 x i8], align 1
|
||||
|
||||
; CHECK: %[[AADDR:.*]] = alloca i8*, align 8
|
||||
; CHECK: store i8* {{.*}}, i8** %[[AADDR]], align 8
|
||||
store i8* %a, i8** %a.addr, align 8
|
||||
|
||||
; CHECK: %[[BUFPTR:.*]] = getelementptr i8, i8* %[[USP]], i32 -4
|
||||
; CHECK: %[[BUFPTR2:.*]] = bitcast i8* %[[BUFPTR]] to [4 x i8]*
|
||||
; CHECK: %[[GEP:.*]] = getelementptr inbounds [4 x i8], [4 x i8]* %[[BUFPTR2]], i32 0, i32 0
|
||||
%gep = getelementptr inbounds [4 x i8], [4 x i8]* %buf, i32 0, i32 0
|
||||
|
||||
; CHECK: %[[A2:.*]] = load i8*, i8** %[[AADDR]], align 8
|
||||
%a2 = load i8*, i8** %a.addr, align 8
|
||||
|
||||
; CHECK: call i8* @strcpy(i8* %[[GEP]], i8* %[[A2]])
|
||||
%call = call i8* @strcpy(i8* %gep, i8* %a2)
|
||||
|
||||
; CHECK: store i8* %[[USP]], i8** @__safestack_unsafe_stack_ptr
|
||||
ret void
|
||||
}
|
||||
|
||||
; Load from an array at a fixed offset, no overflow.
|
||||
define i8 @StaticArrayFixedSafe() nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define i8 @StaticArrayFixedSafe(
|
||||
; CHECK-NOT: __safestack_unsafe_stack_ptr
|
||||
; CHECK: ret i8
|
||||
%buf = alloca i8, i32 4, align 1
|
||||
%gep = getelementptr inbounds i8, i8* %buf, i32 2
|
||||
%x = load i8, i8* %gep, align 1
|
||||
ret i8 %x
|
||||
}
|
||||
|
||||
; Load from an array at a fixed offset with overflow.
|
||||
define i8 @StaticArrayFixedUnsafe() nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define i8 @StaticArrayFixedUnsafe(
|
||||
; CHECK: __safestack_unsafe_stack_ptr
|
||||
; CHECK: ret i8
|
||||
%buf = alloca i8, i32 4, align 1
|
||||
%gep = getelementptr inbounds i8, i8* %buf, i32 5
|
||||
%x = load i8, i8* %gep, align 1
|
||||
ret i8 %x
|
||||
}
|
||||
|
||||
; Load from an array at an unknown offset.
|
||||
define i8 @StaticArrayVariableUnsafe(i32 %ofs) nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define i8 @StaticArrayVariableUnsafe(
|
||||
; CHECK: __safestack_unsafe_stack_ptr
|
||||
; CHECK: ret i8
|
||||
%buf = alloca i8, i32 4, align 1
|
||||
%gep = getelementptr inbounds i8, i8* %buf, i32 %ofs
|
||||
%x = load i8, i8* %gep, align 1
|
||||
ret i8 %x
|
||||
}
|
||||
|
||||
; Load from an array of an unknown size.
|
||||
define i8 @DynamicArrayUnsafe(i32 %sz) nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define i8 @DynamicArrayUnsafe(
|
||||
; CHECK: __safestack_unsafe_stack_ptr
|
||||
; CHECK: ret i8
|
||||
%buf = alloca i8, i32 %sz, align 1
|
||||
%gep = getelementptr inbounds i8, i8* %buf, i32 2
|
||||
%x = load i8, i8* %gep, align 1
|
||||
ret i8 %x
|
||||
}
|
||||
|
||||
declare i8* @strcpy(i8*, i8*)
|
@ -1,51 +0,0 @@
|
||||
; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
%struct.S = type { [100 x i32] }
|
||||
|
||||
; Safe access to a byval argument.
|
||||
define i32 @ByValSafe(%struct.S* byval nocapture readonly align 8 %zzz) norecurse nounwind readonly safestack uwtable {
|
||||
entry:
|
||||
; CHECK-LABEL: @ByValSafe
|
||||
; CHECK-NOT: __safestack_unsafe_stack_ptr
|
||||
; CHECK: ret i32
|
||||
%arrayidx = getelementptr inbounds %struct.S, %struct.S* %zzz, i64 0, i32 0, i64 3
|
||||
%0 = load i32, i32* %arrayidx, align 4
|
||||
ret i32 %0
|
||||
}
|
||||
|
||||
; Unsafe access to a byval argument.
|
||||
; Argument is copied to the unsafe stack.
|
||||
define i32 @ByValUnsafe(%struct.S* byval nocapture readonly align 8 %zzz, i64 %idx) norecurse nounwind readonly safestack uwtable {
|
||||
entry:
|
||||
; CHECK-LABEL: @ByValUnsafe
|
||||
; CHECK: %[[A:.*]] = load {{.*}} @__safestack_unsafe_stack_ptr
|
||||
; CHECK: store {{.*}} @__safestack_unsafe_stack_ptr
|
||||
; CHECK: %[[B:.*]] = getelementptr i8, i8* %[[A]], i32 -400
|
||||
; CHECK: %[[C:.*]] = bitcast %struct.S* %zzz to i8*
|
||||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %[[B]], i8* %[[C]], i64 400, i32 8, i1 false)
|
||||
; CHECK: ret i32
|
||||
%arrayidx = getelementptr inbounds %struct.S, %struct.S* %zzz, i64 0, i32 0, i64 %idx
|
||||
%0 = load i32, i32* %arrayidx, align 4
|
||||
ret i32 %0
|
||||
}
|
||||
|
||||
; Highly aligned byval argument.
|
||||
define i32 @ByValUnsafeAligned(%struct.S* byval nocapture readonly align 64 %zzz, i64 %idx) norecurse nounwind readonly safestack uwtable {
|
||||
entry:
|
||||
; CHECK-LABEL: @ByValUnsafeAligned
|
||||
; CHECK: %[[A:.*]] = load {{.*}} @__safestack_unsafe_stack_ptr
|
||||
; CHECK: %[[B:.*]] = ptrtoint i8* %[[A]] to i64
|
||||
; CHECK: and i64 %[[B]], -64
|
||||
; CHECK: ret i32
|
||||
%arrayidx = getelementptr inbounds %struct.S, %struct.S* %zzz, i64 0, i32 0, i64 0
|
||||
%0 = load i32, i32* %arrayidx, align 64
|
||||
%arrayidx2 = getelementptr inbounds %struct.S, %struct.S* %zzz, i64 0, i32 0, i64 %idx
|
||||
%1 = load i32, i32* %arrayidx2, align 4
|
||||
%add = add nsw i32 %1, %0
|
||||
ret i32 %add
|
||||
}
|
||||
|
178
external/llvm/test/Transforms/SafeStack/X86/call.ll
vendored
178
external/llvm/test/Transforms/SafeStack/X86/call.ll
vendored
@ -1,178 +0,0 @@
|
||||
; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
|
||||
@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
|
||||
|
||||
; no arrays / no nested arrays
|
||||
; Requires no protector.
|
||||
|
||||
define void @foo(i8* %a) nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define void @foo(
|
||||
; CHECK-NOT: __safestack_unsafe_stack_ptr
|
||||
; CHECK: ret void
|
||||
%a.addr = alloca i8*, align 8
|
||||
store i8* %a, i8** %a.addr, align 8
|
||||
%0 = load i8*, i8** %a.addr, align 8
|
||||
%call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* %0)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare i32 @printf(i8*, ...)
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
define void @call_memset(i64 %len) safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define void @call_memset
|
||||
; CHECK: @__safestack_unsafe_stack_ptr
|
||||
; CHECK: ret void
|
||||
%q = alloca [10 x i8], align 1
|
||||
%arraydecay = getelementptr inbounds [10 x i8], [10 x i8]* %q, i32 0, i32 0
|
||||
call void @llvm.memset.p0i8.i64(i8* %arraydecay, i8 1, i64 %len, i32 1, i1 false)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @call_constant_memset() safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define void @call_constant_memset
|
||||
; CHECK-NOT: @__safestack_unsafe_stack_ptr
|
||||
; CHECK: ret void
|
||||
%q = alloca [10 x i8], align 1
|
||||
%arraydecay = getelementptr inbounds [10 x i8], [10 x i8]* %q, i32 0, i32 2
|
||||
call void @llvm.memset.p0i8.i64(i8* %arraydecay, i8 1, i64 7, i32 1, i1 false)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @call_constant_overflow_memset() safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define void @call_constant_overflow_memset
|
||||
; CHECK: @__safestack_unsafe_stack_ptr
|
||||
; CHECK: ret void
|
||||
%q = alloca [10 x i8], align 1
|
||||
%arraydecay = getelementptr inbounds [10 x i8], [10 x i8]* %q, i32 0, i32 7
|
||||
call void @llvm.memset.p0i8.i64(i8* %arraydecay, i8 1, i64 5, i32 1, i1 false)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @call_constant_underflow_memset() safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define void @call_constant_underflow_memset
|
||||
; CHECK: @__safestack_unsafe_stack_ptr
|
||||
; CHECK: ret void
|
||||
%q = alloca [10 x i8], align 1
|
||||
%arraydecay = getelementptr [10 x i8], [10 x i8]* %q, i32 0, i32 -1
|
||||
call void @llvm.memset.p0i8.i64(i8* %arraydecay, i8 1, i64 3, i32 1, i1 false)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Readnone nocapture -> safe
|
||||
define void @call_readnone(i64 %len) safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define void @call_readnone
|
||||
; CHECK-NOT: @__safestack_unsafe_stack_ptr
|
||||
; CHECK: ret void
|
||||
%q = alloca [10 x i8], align 1
|
||||
%arraydecay = getelementptr inbounds [10 x i8], [10 x i8]* %q, i32 0, i32 0
|
||||
call void @readnone(i8* %arraydecay)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Arg0 is readnone, arg1 is not. Pass alloca ptr as arg0 -> safe
|
||||
define void @call_readnone0_0(i64 %len) safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define void @call_readnone0_0
|
||||
; CHECK-NOT: @__safestack_unsafe_stack_ptr
|
||||
; CHECK: ret void
|
||||
%q = alloca [10 x i8], align 1
|
||||
%arraydecay = getelementptr inbounds [10 x i8], [10 x i8]* %q, i32 0, i32 0
|
||||
call void @readnone0(i8* %arraydecay, i8* zeroinitializer)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Arg0 is readnone, arg1 is not. Pass alloca ptr as arg1 -> unsafe
|
||||
define void @call_readnone0_1(i64 %len) safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define void @call_readnone0_1
|
||||
; CHECK: @__safestack_unsafe_stack_ptr
|
||||
; CHECK: ret void
|
||||
%q = alloca [10 x i8], align 1
|
||||
%arraydecay = getelementptr inbounds [10 x i8], [10 x i8]* %q, i32 0, i32 0
|
||||
call void @readnone0(i8 *zeroinitializer, i8* %arraydecay)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Readonly nocapture -> unsafe
|
||||
define void @call_readonly(i64 %len) safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define void @call_readonly
|
||||
; CHECK: @__safestack_unsafe_stack_ptr
|
||||
; CHECK: ret void
|
||||
%q = alloca [10 x i8], align 1
|
||||
%arraydecay = getelementptr inbounds [10 x i8], [10 x i8]* %q, i32 0, i32 0
|
||||
call void @readonly(i8* %arraydecay)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Readonly nocapture -> unsafe
|
||||
define void @call_arg_readonly(i64 %len) safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define void @call_arg_readonly
|
||||
; CHECK: @__safestack_unsafe_stack_ptr
|
||||
; CHECK: ret void
|
||||
%q = alloca [10 x i8], align 1
|
||||
%arraydecay = getelementptr inbounds [10 x i8], [10 x i8]* %q, i32 0, i32 0
|
||||
call void @arg_readonly(i8* %arraydecay)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Readwrite nocapture -> unsafe
|
||||
define void @call_readwrite(i64 %len) safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define void @call_readwrite
|
||||
; CHECK: @__safestack_unsafe_stack_ptr
|
||||
; CHECK: ret void
|
||||
%q = alloca [10 x i8], align 1
|
||||
%arraydecay = getelementptr inbounds [10 x i8], [10 x i8]* %q, i32 0, i32 0
|
||||
call void @readwrite(i8* %arraydecay)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Captures the argument -> unsafe
|
||||
define void @call_capture(i64 %len) safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: define void @call_capture
|
||||
; CHECK: @__safestack_unsafe_stack_ptr
|
||||
; CHECK: ret void
|
||||
%q = alloca [10 x i8], align 1
|
||||
%arraydecay = getelementptr inbounds [10 x i8], [10 x i8]* %q, i32 0, i32 0
|
||||
call void @capture(i8* %arraydecay)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Lifetime intrinsics are always safe.
|
||||
define void @call_lifetime(i32* %p) {
|
||||
; CHECK-LABEL: define void @call_lifetime
|
||||
; CHECK-NOT: @__safestack_unsafe_stack_ptr
|
||||
; CHECK: ret void
|
||||
entry:
|
||||
%q = alloca [100 x i8], align 16
|
||||
%0 = bitcast [100 x i8]* %q to i8*
|
||||
call void @llvm.lifetime.start.p0i8(i64 100, i8* %0)
|
||||
call void @llvm.lifetime.end.p0i8(i64 100, i8* %0)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @readonly(i8* nocapture) readonly
|
||||
declare void @arg_readonly(i8* readonly nocapture)
|
||||
declare void @readwrite(i8* nocapture)
|
||||
declare void @capture(i8* readnone) readnone
|
||||
|
||||
declare void @readnone(i8* nocapture) readnone
|
||||
declare void @readnone0(i8* nocapture readnone, i8* nocapture)
|
||||
|
||||
declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind argmemonly
|
||||
|
||||
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) nounwind argmemonly
|
||||
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) nounwind argmemonly
|
@ -1,39 +0,0 @@
|
||||
; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
|
||||
@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
|
||||
|
||||
; PtrToInt/IntToPtr Cast
|
||||
|
||||
define void @IntToPtr() nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: @IntToPtr(
|
||||
; CHECK-NOT: __safestack_unsafe_stack_ptr
|
||||
; CHECK: ret void
|
||||
%a = alloca i32, align 4
|
||||
%0 = ptrtoint i32* %a to i64
|
||||
%1 = inttoptr i64 %0 to i32*
|
||||
ret void
|
||||
}
|
||||
|
||||
define i8 @BitCastNarrow() nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: @BitCastNarrow(
|
||||
; CHECK-NOT: __safestack_unsafe_stack_ptr
|
||||
; CHECK: ret i8
|
||||
%a = alloca i32, align 4
|
||||
%0 = bitcast i32* %a to i8*
|
||||
%1 = load i8, i8* %0, align 1
|
||||
ret i8 %1
|
||||
}
|
||||
|
||||
define i64 @BitCastWide() nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK-LABEL: @BitCastWide(
|
||||
; CHECK: __safestack_unsafe_stack_ptr
|
||||
; CHECK: ret i64
|
||||
%a = alloca i32, align 4
|
||||
%0 = bitcast i32* %a to i64*
|
||||
%1 = load i64, i64* %0, align 1
|
||||
ret i64 %1
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
; RUN: opt -safe-stack -safe-stack-coloring=1 -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
|
||||
; %x and %y share a stack slot between them, but not with the stack guard.
|
||||
define void @f() safestack sspreq {
|
||||
; CHECK-LABEL: define void @f
|
||||
entry:
|
||||
; CHECK: %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr
|
||||
; CHECK: getelementptr i8, i8* %[[USP]], i32 -16
|
||||
|
||||
; CHECK: %[[A:.*]] = getelementptr i8, i8* %[[USP]], i32 -8
|
||||
; CHECK: %[[StackGuardSlot:.*]] = bitcast i8* %[[A]] to i8**
|
||||
; CHECK: store i8* %{{.*}}, i8** %[[StackGuardSlot]]
|
||||
|
||||
%x = alloca i64, align 8
|
||||
%y = alloca i64, align 8
|
||||
%x0 = bitcast i64* %x to i8*
|
||||
%y0 = bitcast i64* %y to i8*
|
||||
|
||||
call void @llvm.lifetime.start.p0i8(i64 -1, i8* %x0)
|
||||
; CHECK: getelementptr i8, i8* %[[USP]], i32 -16
|
||||
call void @capture64(i64* %x)
|
||||
call void @llvm.lifetime.end.p0i8(i64 -1, i8* %x0)
|
||||
|
||||
call void @llvm.lifetime.start.p0i8(i64 -1, i8* %y0)
|
||||
; CHECK: getelementptr i8, i8* %[[USP]], i32 -16
|
||||
call void @capture64(i64* %y)
|
||||
call void @llvm.lifetime.end.p0i8(i64 -1, i8* %y0)
|
||||
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
|
||||
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
|
||||
declare void @capture64(i64*)
|
@ -1,44 +0,0 @@
|
||||
; RUN: opt -safe-stack -safe-stack-coloring=1 -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
; RUN: opt -safe-stack -safe-stack-coloring=1 -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
|
||||
define void @f() safestack {
|
||||
entry:
|
||||
; CHECK: %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr
|
||||
; CHECK: %[[USST:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
|
||||
|
||||
%x = alloca i32, align 4
|
||||
%x1 = alloca i32, align 4
|
||||
%x2 = alloca i32, align 4
|
||||
%0 = bitcast i32* %x to i8*
|
||||
call void @llvm.lifetime.start.p0i8(i64 4, i8* %0)
|
||||
|
||||
; CHECK: %[[A1:.*]] = getelementptr i8, i8* %[[USP]], i32 -4
|
||||
; CHECK: %[[A2:.*]] = bitcast i8* %[[A1]] to i32*
|
||||
; CHECK: call void @capture(i32* nonnull %[[A2]])
|
||||
|
||||
call void @capture(i32* nonnull %x)
|
||||
call void @llvm.lifetime.end.p0i8(i64 4, i8* %0)
|
||||
%1 = bitcast i32* %x1 to i8*
|
||||
call void @llvm.lifetime.start.p0i8(i64 4, i8* %1)
|
||||
|
||||
; CHECK: %[[B1:.*]] = getelementptr i8, i8* %[[USP]], i32 -4
|
||||
; CHECK: %[[B2:.*]] = bitcast i8* %[[B1]] to i32*
|
||||
; CHECK: call void @capture(i32* nonnull %[[B2]])
|
||||
|
||||
call void @capture(i32* nonnull %x1)
|
||||
call void @llvm.lifetime.end.p0i8(i64 4, i8* %1)
|
||||
%2 = bitcast i32* %x2 to i8*
|
||||
call void @llvm.lifetime.start.p0i8(i64 4, i8* %2)
|
||||
|
||||
; CHECK: %[[C1:.*]] = getelementptr i8, i8* %[[USP]], i32 -4
|
||||
; CHECK: %[[C2:.*]] = bitcast i8* %[[C1]] to i32*
|
||||
; CHECK: call void @capture(i32* nonnull %[[C2]])
|
||||
|
||||
call void @capture(i32* nonnull %x2)
|
||||
call void @llvm.lifetime.end.p0i8(i64 4, i8* %2)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
|
||||
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
|
||||
declare void @capture(i32*)
|
File diff suppressed because it is too large
Load Diff
@ -1,26 +0,0 @@
|
||||
; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
|
||||
%struct.nest = type { %struct.pair, %struct.pair }
|
||||
%struct.pair = type { i32, i32 }
|
||||
|
||||
@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
|
||||
|
||||
; Nested structure, no arrays, no address-of expressions.
|
||||
; Verify that the resulting gep-of-gep does not incorrectly trigger
|
||||
; a safe stack protector.
|
||||
; safestack attribute
|
||||
; Requires no protector.
|
||||
; CHECK-LABEL: @foo(
|
||||
define void @foo() nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK-NOT: __safestack_unsafe_stack_ptr
|
||||
%c = alloca %struct.nest, align 4
|
||||
%b = getelementptr inbounds %struct.nest, %struct.nest* %c, i32 0, i32 1
|
||||
%_a = getelementptr inbounds %struct.pair, %struct.pair* %b, i32 0, i32 0
|
||||
%0 = load i32, i32* %_a, align 4
|
||||
%call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %0)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare i32 @printf(i8*, ...)
|
@ -1,20 +0,0 @@
|
||||
; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
|
||||
%class.A = type { [2 x i8] }
|
||||
|
||||
@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
|
||||
|
||||
; [2 x i8] in a class
|
||||
; safestack attribute
|
||||
; Requires no protector.
|
||||
; CHECK-LABEL: @foo(
|
||||
define signext i8 @foo() nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK-NOT: __safestack_unsafe_stack_ptr
|
||||
%a = alloca %class.A, align 1
|
||||
%array = getelementptr inbounds %class.A, %class.A* %a, i32 0, i32 0
|
||||
%arrayidx = getelementptr inbounds [2 x i8], [2 x i8]* %array, i32 0, i64 0
|
||||
%0 = load i8, i8* %arrayidx, align 1
|
||||
ret i8 %0
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
|
||||
|
||||
%struct.deep = type { %union.anon }
|
||||
%union.anon = type { %struct.anon }
|
||||
%struct.anon = type { %struct.anon.0 }
|
||||
%struct.anon.0 = type { %union.anon.1 }
|
||||
%union.anon.1 = type { [2 x i8] }
|
||||
|
||||
@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
|
||||
|
||||
; [2 x i8] nested in several layers of structs and unions
|
||||
; safestack attribute
|
||||
; Requires no protector.
|
||||
; CHECK-LABEL: @foo(
|
||||
define signext i8 @foo() nounwind uwtable safestack {
|
||||
entry:
|
||||
; CHECK-NOT: __safestack_unsafe_stack_ptr
|
||||
%x = alloca %struct.deep, align 1
|
||||
%b = getelementptr inbounds %struct.deep, %struct.deep* %x, i32 0, i32 0
|
||||
%c = bitcast %union.anon* %b to %struct.anon*
|
||||
%d = getelementptr inbounds %struct.anon, %struct.anon* %c, i32 0, i32 0
|
||||
%e = getelementptr inbounds %struct.anon.0, %struct.anon.0* %d, i32 0, i32 0
|
||||
%array = bitcast %union.anon.1* %e to [2 x i8]*
|
||||
%arrayidx = getelementptr inbounds [2 x i8], [2 x i8]* %array, i32 0, i64 0
|
||||
%0 = load i8, i8* %arrayidx, align 1
|
||||
ret i8 %0
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user