[PATCH] D71256: llc: Don't overwrite frame-pointer attribute

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 04:48:47 PST 2019


arsenm created this revision.
arsenm added reviewers: echristo, thegameg, ahatanak.
Herald added subscribers: dexonsmith, wdng.
Herald added a project: LLVM.
arsenm added a parent revision: D71253: llc/MIR: Fix setFunctionAttributes for MIR functions.

Continue making command line flags with matching attribute behavior
consistent.


https://reviews.llvm.org/D71256

Files:
  llvm/include/llvm/CodeGen/CommandFlags.inc
  llvm/test/Other/opt-override-frame-pointer.ll


Index: llvm/test/Other/opt-override-frame-pointer.ll
===================================================================
--- /dev/null
+++ llvm/test/Other/opt-override-frame-pointer.ll
@@ -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" }
Index: llvm/include/llvm/CodeGen/CommandFlags.inc
===================================================================
--- llvm/include/llvm/CodeGen/CommandFlags.inc
+++ llvm/include/llvm/CodeGen/CommandFlags.inc
@@ -395,7 +395,8 @@
       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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71256.233054.patch
Type: text/x-patch
Size: 2729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191210/ba161585/attachment.bin>


More information about the llvm-commits mailing list