[llvm] r322619 - [MC] Fix -stack-size-section on ARM

Sean Eveson via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 17 01:01:29 PST 2018


Author: seaneveson
Date: Wed Jan 17 01:01:29 2018
New Revision: 322619

URL: http://llvm.org/viewvc/llvm-project?rev=322619&view=rev
Log:
[MC] Fix -stack-size-section on ARM

Change symbol values in the stack_size section from being 8 bytes, to being a target dependent size.

Differential Revision: https://reviews.llvm.org/D42108

Added:
    llvm/trunk/test/CodeGen/ARM/stack-size-section.ll
Modified:
    llvm/trunk/docs/CodeGenerator.rst
    llvm/trunk/docs/CommandGuide/llc.rst
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Modified: llvm/trunk/docs/CodeGenerator.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CodeGenerator.rst?rev=322619&r1=322618&r2=322619&view=diff
==============================================================================
--- llvm/trunk/docs/CodeGenerator.rst (original)
+++ llvm/trunk/docs/CodeGenerator.rst Wed Jan 17 01:01:29 2018
@@ -1584,7 +1584,7 @@ Emitting function stack size information
 A section containing metadata on function stack sizes will be emitted when
 ``TargetLoweringObjectFile::StackSizesSection`` is not null, and
 ``TargetOptions::EmitStackSizeSection`` is set (-stack-size-section). The
-section will contain an array of pairs of function symbol references (8 byte)
+section will contain an array of pairs of function symbol values (pointer size)
 and stack sizes (unsigned LEB128). The stack size values only include the space
 allocated in the function prologue. Functions with dynamic stack allocations are
 not included.

Modified: llvm/trunk/docs/CommandGuide/llc.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llc.rst?rev=322619&r1=322618&r2=322619&view=diff
==============================================================================
--- llvm/trunk/docs/CommandGuide/llc.rst (original)
+++ llvm/trunk/docs/CommandGuide/llc.rst Wed Jan 17 01:01:29 2018
@@ -135,7 +135,7 @@ End-user Options
 .. option:: -stack-size-section
 
  Emit the .stack_sizes section which contains stack size metadata. The section
- contains an array of pairs of function symbol references (8 byte) and stack
+ contains an array of pairs of function symbol values (pointer size) and stack
  sizes (unsigned LEB128). The stack size values only include the space allocated
  in the function prologue. Functions with dynamic stack allocations are not
  included.

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=322619&r1=322618&r2=322619&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Jan 17 01:01:29 2018
@@ -976,8 +976,7 @@ void AsmPrinter::emitStackSizeSection(co
 
   const MCSymbol *FunctionSymbol = getSymbol(&MF.getFunction());
   uint64_t StackSize = FrameInfo.getStackSize();
-  OutStreamer->EmitValue(MCSymbolRefExpr::create(FunctionSymbol, OutContext),
-                         /* size = */ 8);
+  OutStreamer->EmitSymbolValue(FunctionSymbol, TM.getPointerSize());
   OutStreamer->EmitULEB128IntValue(StackSize);
 
   OutStreamer->PopSection();

Added: llvm/trunk/test/CodeGen/ARM/stack-size-section.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/stack-size-section.ll?rev=322619&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/stack-size-section.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/stack-size-section.ll Wed Jan 17 01:01:29 2018
@@ -0,0 +1,30 @@
+; RUN: llc < %s -mtriple=armv7-linux -stack-size-section | FileCheck %s
+
+; CHECK-LABEL: func1:
+; CHECK: .section .stack_sizes,"",%progbits
+; CHECK-NEXT: .long func1
+; CHECK-NEXT: .byte 8
+define void @func1(i32, i32) #0 {
+  alloca i32, align 4
+  alloca i32, align 4
+  ret void
+}
+
+; CHECK-LABEL: func2:
+; CHECK: .section .stack_sizes,"",%progbits
+; CHECK-NEXT: .long func2
+; CHECK-NEXT: .byte 16
+define void @func2() #0 {
+  alloca i32, align 4
+  call void @func1(i32 1, i32 2)
+  ret void
+}
+
+; CHECK-LABEL: dynalloc:
+; CHECK-NOT: .section .stack_sizes
+define void @dynalloc(i32 %N) #0 {
+  alloca i32, i32 %N
+  ret void
+}
+
+attributes #0 = { "no-frame-pointer-elim"="true" }




More information about the llvm-commits mailing list