Don't inline functions with different SafeStack attributes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268999 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evgeniy Stepanov 2016-05-10 00:33:07 +00:00
parent b03e0b7cfd
commit d3d318a084
2 changed files with 20 additions and 0 deletions

View File

@ -190,6 +190,7 @@ class CompatRule<string F> {
def : CompatRule<"isEqual<SanitizeAddressAttr>">; def : CompatRule<"isEqual<SanitizeAddressAttr>">;
def : CompatRule<"isEqual<SanitizeThreadAttr>">; def : CompatRule<"isEqual<SanitizeThreadAttr>">;
def : CompatRule<"isEqual<SanitizeMemoryAttr>">; def : CompatRule<"isEqual<SanitizeMemoryAttr>">;
def : CompatRule<"isEqual<SafeStackAttr>">;
class MergeRule<string F> { class MergeRule<string F> {
// The name of the function called to merge the attributes of the caller and // The name of the function called to merge the attributes of the caller and

View File

@ -17,6 +17,10 @@ define i32 @sanitize_memory_callee(i32 %i) sanitize_memory {
ret i32 %i ret i32 %i
} }
define i32 @safestack_callee(i32 %i) safestack {
ret i32 %i
}
define i32 @alwaysinline_callee(i32 %i) alwaysinline { define i32 @alwaysinline_callee(i32 %i) alwaysinline {
ret i32 %i ret i32 %i
} }
@ -33,6 +37,10 @@ define i32 @alwaysinline_sanitize_memory_callee(i32 %i) alwaysinline sanitize_me
ret i32 %i ret i32 %i
} }
define i32 @alwaysinline_safestack_callee(i32 %i) alwaysinline safestack {
ret i32 %i
}
; Check that: ; Check that:
; * noattr callee is inlined into noattr caller, ; * noattr callee is inlined into noattr caller,
@ -111,6 +119,17 @@ define i32 @test_sanitize_thread(i32 %arg) sanitize_thread {
; CHECK-NEXT: ret i32 ; CHECK-NEXT: ret i32
} }
define i32 @test_safestack(i32 %arg) safestack {
%x1 = call i32 @noattr_callee(i32 %arg)
%x2 = call i32 @safestack_callee(i32 %x1)
%x3 = call i32 @alwaysinline_callee(i32 %x2)
%x4 = call i32 @alwaysinline_safestack_callee(i32 %x3)
ret i32 %x4
; CHECK-LABEL: @test_safestack(
; CHECK-NEXT: @noattr_callee
; CHECK-NEXT: ret i32
}
; Check that a function doesn't get inlined if target-cpu strings don't match ; Check that a function doesn't get inlined if target-cpu strings don't match
; exactly. ; exactly.
define i32 @test_target_cpu_callee0(i32 %i) "target-cpu"="corei7" { define i32 @test_target_cpu_callee0(i32 %i) "target-cpu"="corei7" {