1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

llc: Don't overwrite frame-pointer attribute

Continue making command line flags with matching attribute behavior
consistent.
This commit is contained in:
Matt Arsenault 2019-12-09 18:39:58 +05:30 committed by Matt Arsenault
parent b1c09bbef0
commit b1cd77c7fd
7 changed files with 71 additions and 34 deletions

View File

@ -400,7 +400,8 @@ setFunctionAttributes(StringRef CPU, StringRef Features, Function &F) {
NewAttrs.addAttribute("target-features", Appended);
}
}
if (FramePointerUsage.getNumOccurrences() > 0) {
if (FramePointerUsage.getNumOccurrences() > 0 &&
!F.hasFnAttribute("frame-pointer")) {
if (FramePointerUsage == llvm::FramePointer::All)
NewAttrs.addAttribute("frame-pointer", "all");
else if (FramePointerUsage == llvm::FramePointer::NonLeaf)

View File

@ -2,7 +2,7 @@
; RUN: llc %s -verify-machineinstrs -mtriple aarch64-apple-darwin -global-isel -global-isel-abort=1 -frame-pointer=non-leaf -o - 2>&1 | FileCheck %s
; Check that we get a tail call to foo without saving fp/lr.
define void @bar(i32 %a) #1 {
define void @bar(i32 %a) {
; CHECK-LABEL: bar:
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: b _zoo
@ -18,6 +18,3 @@ define void @zoo(i32 %a) {
entry:
ret void
}
attributes #1 = { "frame-pointer"="all" }

View File

@ -525,8 +525,8 @@ while.cond:
br label %while.cond
}
attributes #0 = { nounwind readonly "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #0 = { nounwind readonly "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { nounwind }

View File

@ -15,7 +15,7 @@
ret void
}
attributes #0 = { noinline noredzone "frame-pointer"="all" }
attributes #0 = { noinline noredzone }
...
---
# This test ensures that we

View File

@ -1,16 +1,16 @@
; RUN: llc < %s -mtriple armv7-none-linux-gnueabi -O1 | FileCheck %s --check-prefix=DISABLE-FP-ELIM
; RUN: llc < %s -mtriple armv7-none-linux-gnueabi -fast-isel -O1 | FileCheck %s --check-prefix=DISABLE-FP-ELIM
; RUN: llc < %s -mtriple armv7-none-linux-gnueabi -frame-pointer=all -O1 | FileCheck %s --check-prefix=DISABLE-FP-ELIM
; RUN: llc < %s -mtriple armv7-none-linux-gnueabi -frame-pointer=none -O1 | FileCheck %s --check-prefix=ENABLE-FP-ELIM
; RUN: llc < %s -mtriple armv7-none-linux-gnueabi -frame-pointer=none -O0 | FileCheck %s --check-prefix=DISABLE-FP-ELIM
; Check that command line option "-frame-pointer=all" overrides function attribute
; "frame-pointer"="all". Also, check frame pointer elimination is disabled
; when fast-isel is used.
; Check that command line option "-frame-pointer=all" sets function
; attribute "frame-pointer"="all". Also, check frame pointer
; elimination is disabled when fast-isel is used.
; ENABLE-FP-ELIM-NOT: .setfp
; DISABLE-FP-ELIM: .setfp r11, sp
define i32 @foo1(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) #0 {
define i32 @foo1(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
entry:
%call = tail call i32 @foo2(i32 %a)
%add = add i32 %c, %b
@ -21,5 +21,3 @@ entry:
}
declare i32 @foo2(i32)
attributes #0 = { nounwind "frame-pointer"="all" }

View File

@ -1,5 +1,5 @@
; RUN: llc < %s -mtriple=i686-- -asm-verbose=false | FileCheck %s -check-prefix=FP-ELIM
; RUN: llc < %s -mtriple=i686-- -asm-verbose=false -frame-pointer=all | FileCheck %s -check-prefix=NO-ELIM
; RUN: llc < %s -mtriple=i686-- -asm-verbose=false | FileCheck %s -check-prefixes=FP-ELIM,ANY
; RUN: llc < %s -mtriple=i686-- -asm-verbose=false -frame-pointer=all | FileCheck %s -check-prefixes=NO-ELIM,ANY
; Implement -momit-leaf-frame-pointer
; rdar://7886181
@ -31,30 +31,21 @@ entry:
ret void
}
; The local non-leaf attribute takes precendece over the command line flag.
define i32 @t3() "frame-pointer"="non-leaf" nounwind readnone {
entry:
; FP-ELIM-LABEL: t3:
; FP-ELIM-NEXT: movl
; FP-ELIM-NEXT: ret
; NO-ELIM-LABEL: t3:
; NO-ELIM-NEXT: pushl %ebp
; NO-ELIM: popl %ebp
; NO-ELIM-NEXT: ret
; ANY-ELIM-LABEL: t3:
; ANY-ELIM-NEXT: movl
; ANY-ELIM-NEXT: ret
ret i32 10
}
define void @t4() "frame-pointer"="non-leaf" nounwind {
entry:
; FP-ELIM-LABEL: t4:
; FP-ELIM-NEXT: pushl %ebp
; FP-ELIM: popl %ebp
; FP-ELIM-NEXT: ret
; NO-ELIM-LABEL: t4:
; NO-ELIM-NEXT: pushl %ebp
; NO-ELIM: popl %ebp
; NO-ELIM-NEXT: ret
; ANY-ELIM-LABEL: t4:
; ANY-ELIM-NEXT: pushl %ebp
; ANY-ELIM: popl %ebp
; ANY-ELIM-NEXT: ret
tail call void @foo(i32 0) nounwind
ret void
}

View File

@ -0,0 +1,50 @@
; RUN: opt < %s -mtriple=x86_64-apple-darwin -frame-pointer=all -S | FileCheck -check-prefixes=ALL,CHECK %s
; RUN: opt < %s -mtriple=x86_64-apple-darwin -frame-pointer=none -S | FileCheck -check-prefixes=NONE,CHECK %s
; RUN: opt < %s -mtriple=x86_64-apple-darwin -frame-pointer=non-leaf -S | FileCheck -check-prefixes=NONLEAF,CHECK %s
; Check behavior of -frame-pointer flag and frame-pointer atttribute.
; CHECK: @no_frame_pointer_attr() [[VARATTR:#[0-9]+]] {
define i32 @no_frame_pointer_attr() #0 {
entry:
ret i32 0
}
; CHECK: @frame_pointer_attr_all() [[ALL_ATTR:#[0-9]+]] {
define i32 @frame_pointer_attr_all() #1 {
entry:
ret i32 0
}
; CHECK: @frame_pointer_attr_none() [[NONE_ATTR:#[0-9]+]] {
define i32 @frame_pointer_attr_none() #2 {
entry:
ret i32 0
}
; CHECK: @frame_pointer_attr_leaf() [[NONLEAF_ATTR:#[0-9]+]] {
define i32 @frame_pointer_attr_leaf() #3 {
entry:
ret i32 0
}
; ALL-DAG: attributes [[VARATTR]] = { nounwind "frame-pointer"="all" }
; ALL-DAG: attributes [[NONE_ATTR]] = { nounwind "frame-pointer"="none" }
; ALL-DAG: attributes [[NONLEAF_ATTR]] = { nounwind "frame-pointer"="non-leaf" }
; ALL-NOT: attributes
; NONE-DAG: attributes [[VARATTR]] = { nounwind "frame-pointer"="none" }
; NONE-DAG: attributes [[ALL_ATTR]] = { nounwind "frame-pointer"="all" }
; NONE-DAG: attributes [[NONLEAF_ATTR]] = { nounwind "frame-pointer"="non-leaf" }
; NONE-NOT: attributes
; NONLEAF-DAG: attributes [[VARATTR]] = { nounwind "frame-pointer"="non-leaf" }
; NONLEAF-DAG: attributes [[ALL_ATTR]] = { nounwind "frame-pointer"="all" }
; NONLEAF-DAG: attributes [[NONE_ATTR]] = { nounwind "frame-pointer"="none" }
; NONLEAF-NOT: attributes
attributes #0 = { nounwind }
attributes #1 = { nounwind "frame-pointer"="all" }
attributes #2 = { nounwind "frame-pointer"="none" }
attributes #3 = { nounwind "frame-pointer"="non-leaf" }