summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorSean Eveson <eveson.sean@gmail.com>2017-11-30 13:05:14 +0000
committerSean Eveson <eveson.sean@gmail.com>2017-11-30 13:05:14 +0000
commita6bcd53d5229db563d0ba25b6385e3ca5d0820de (patch)
tree7cef0a8088cba473cf19d7eb789bad9521ea4687 /llvm/include
parent661e4fbf83887a074ab3ab06ae41470cce4ff45c (diff)
downloadbcm5719-llvm-a6bcd53d5229db563d0ba25b6385e3ca5d0820de.tar.gz
bcm5719-llvm-a6bcd53d5229db563d0ba25b6385e3ca5d0820de.zip
[MC] Function stack size section.
Re applying after fixing issues in the diff, sorry for any painful conflicts/merges! Original RFC: http://lists.llvm.org/pipermail/llvm-dev/2017-August/117028.html This change adds a '.stack-size' section containing metadata on function stack sizes to output ELF files behind the new -stack-size-section flag. The section contains pairs of function symbol references (8 byte) and stack sizes (unsigned LEB128). The contents of this section can be used to measure changes to stack sizes between different versions of the compiler or a source base. The advantage of having a section is that we can extract this information when examining binaries that we didn't build, and it allows users and tools easy access to that information just by referencing the binary. There is a follow up change to add an option to clang. Thanks. Reviewers: hfinkel, MatzeB Reviewed By: MatzeB Subscribers: thegameg, asb, llvm-commits Differential Revision: https://reviews.llvm.org/D39788 llvm-svn: 319430
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/CodeGen/AsmPrinter.h2
-rw-r--r--llvm/include/llvm/CodeGen/CommandFlags.def5
-rw-r--r--llvm/include/llvm/MC/MCObjectFileInfo.h5
-rw-r--r--llvm/include/llvm/Target/TargetOptions.h5
4 files changed, 16 insertions, 1 deletions
diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h
index 1d65f703b84..b8944a66800 100644
--- a/llvm/include/llvm/CodeGen/AsmPrinter.h
+++ b/llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -295,6 +295,8 @@ public:
void emitFrameAlloc(const MachineInstr &MI);
+ void emitStackSizeSection(const MachineFunction &MF);
+
enum CFIMoveType { CFI_M_None, CFI_M_EH, CFI_M_Debug };
CFIMoveType needsCFIMoves() const;
diff --git a/llvm/include/llvm/CodeGen/CommandFlags.def b/llvm/include/llvm/CodeGen/CommandFlags.def
index 83cbeb0341f..fe96033a9c6 100644
--- a/llvm/include/llvm/CodeGen/CommandFlags.def
+++ b/llvm/include/llvm/CodeGen/CommandFlags.def
@@ -255,6 +255,10 @@ static cl::opt<DebuggerKind> DebuggerTuningOpt(
clEnumValN(DebuggerKind::LLDB, "lldb", "lldb"),
clEnumValN(DebuggerKind::SCE, "sce", "SCE targets (e.g. PS4)")));
+static cl::opt<bool> EnableStackSizeSection(
+ "stack-size-section",
+ cl::desc("Emit a section containing stack size metadata"), cl::init(false));
+
// Common utility function tightly tied to the options listed here. Initializes
// a TargetOptions object with CodeGen flags and returns it.
static TargetOptions InitTargetOptionsFromCodeGenFlags() {
@@ -281,6 +285,7 @@ static TargetOptions InitTargetOptionsFromCodeGenFlags() {
Options.UniqueSectionNames = UniqueSectionNames;
Options.EmulatedTLS = EmulatedTLS;
Options.ExceptionModel = ExceptionModel;
+ Options.EmitStackSizeSection = EnableStackSizeSection;
Options.MCOptions = InitMCTargetOptionsFromFlags();
diff --git a/llvm/include/llvm/MC/MCObjectFileInfo.h b/llvm/include/llvm/MC/MCObjectFileInfo.h
index d95f84d1d81..c0b1443591c 100644
--- a/llvm/include/llvm/MC/MCObjectFileInfo.h
+++ b/llvm/include/llvm/MC/MCObjectFileInfo.h
@@ -154,6 +154,9 @@ protected:
/// It is initialized on demand so it can be overwritten (with uniquing).
MCSection *EHFrameSection;
+ /// Section containing metadata on function stack sizes.
+ MCSection *StackSizesSection;
+
// ELF specific sections.
MCSection *DataRelROSection;
MCSection *MergeableConst4Section;
@@ -287,6 +290,8 @@ public:
MCSection *getStackMapSection() const { return StackMapSection; }
MCSection *getFaultMapSection() const { return FaultMapSection; }
+ MCSection *getStackSizesSection() const { return StackSizesSection; }
+
// ELF specific sections.
MCSection *getDataRelROSection() const { return DataRelROSection; }
const MCSection *getMergeableConst4Section() const {
diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h
index 5c2063880f8..70fac7833f3 100644
--- a/llvm/include/llvm/Target/TargetOptions.h
+++ b/llvm/include/llvm/Target/TargetOptions.h
@@ -108,7 +108,7 @@ namespace llvm {
DisableIntegratedAS(false), RelaxELFRelocations(false),
FunctionSections(false), DataSections(false),
UniqueSectionNames(true), TrapUnreachable(false), EmulatedTLS(false),
- EnableIPRA(false) {}
+ EnableIPRA(false), EmitStackSizeSection(false) {}
/// PrintMachineCode - This flag is enabled when the -print-machineinstrs
/// option is specified on the command line, and should enable debugging
@@ -216,6 +216,9 @@ namespace llvm {
/// This flag enables InterProcedural Register Allocation (IPRA).
unsigned EnableIPRA : 1;
+ /// Emit section containing metadata on function stack sizes.
+ unsigned EmitStackSizeSection : 1;
+
/// FloatABIType - This setting is set by -float-abi=xxx option is specfied
/// on the command line. This setting may either be Default, Soft, or Hard.
/// Default selects the target's default behavior. Soft selects the ABI for
OpenPOWER on IntegriCloud