[PATCH] MIR Serialization: Serialize references from stack objects to named allocas.

Duncan P. N. Exon Smith dexonsmith at apple.com
Tue Jul 14 16:17:44 PDT 2015


> On 2015-Jul-14, at 16:04, Alex L <arphaman at gmail.com> wrote:
> 
> Hi,
> 
> This patch serializes the references to the named LLVM alloca instructions from the stack objects in the machine frame info. This commit adds a field 'Name' to the struct 'yaml::MachineStackObject'. This new field is used to store the name of the alloca instruction when the alloca is present and when it has a name.
> 
> Cheers,
> Alex
> <0001-MIR-Serialization-Serialize-references-from-stack-ob.patch>

> From eb929476f0efa98aef6a28c220371ef4b071c24a Mon Sep 17 00:00:00 2001
> From: Alex Lorenz <arphaman at gmail.com>
> Date: Wed, 8 Jul 2015 11:52:02 -0700
> Subject: [PATCH] MIR Serialization: Serialize references from stack objects to
>  named allocas.
> 
> ---
>  include/llvm/CodeGen/MIRYamlMapping.h              |  5 +++-
>  lib/CodeGen/MIRParser/MIRParser.cpp                | 23 ++++++++++++-----
>  lib/CodeGen/MIRPrinter.cpp                         |  6 +++++
>  test/CodeGen/MIR/X86/stack-object-invalid-name.mir | 30 ++++++++++++++++++++++
>  test/CodeGen/MIR/X86/stack-objects.mir             |  8 +++---
>  .../MIR/X86/variable-sized-stack-objects.mir       |  4 +--
>  6 files changed, 63 insertions(+), 13 deletions(-)
>  create mode 100644 test/CodeGen/MIR/X86/stack-object-invalid-name.mir
> 
> diff --git a/lib/CodeGen/MIRPrinter.cpp b/lib/CodeGen/MIRPrinter.cpp
> index d5cf924..3b8fc27 100644
> --- a/lib/CodeGen/MIRPrinter.cpp
> +++ b/lib/CodeGen/MIRPrinter.cpp
> @@ -19,6 +19,7 @@
>  #include "llvm/CodeGen/MachineRegisterInfo.h"
>  #include "llvm/CodeGen/MIRYamlMapping.h"
>  #include "llvm/IR/BasicBlock.h"
> +#include "llvm/IR/Instructions.h"
>  #include "llvm/IR/Module.h"
>  #include "llvm/IR/ModuleSlotTracker.h"
>  #include "llvm/Support/MemoryBuffer.h"
> @@ -199,6 +200,11 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &MF,
>  
>      yaml::MachineStackObject YamlObject;
>      YamlObject.ID = ID++;
> +    if (const auto *Alloca = MFI.getObjectAllocation(I))
> +      YamlObject.Name.Value =
> +          Alloca->hasName() ? Alloca->getName() : "<unnamed alloca>";
> +    else
> +      YamlObject.Name.Value = "";

Is it necessary to manually set `YamlObject.Name.Value` to an empty
string here?  Isn't that handled by the default initializer?

Otherwise, LGTM.

>      YamlObject.Type = MFI.isSpillSlotObjectIndex(I)
>                            ? yaml::MachineStackObject::SpillSlot
>                            : MFI.isVariableSizedObjectIndex(I)





More information about the llvm-commits mailing list