[llvm] r245249 - MIR Serialization: Serialize the local offsets for the stack objects.
Alex Lorenz via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 17 15:17:42 PDT 2015
Author: arphaman
Date: Mon Aug 17 17:17:42 2015
New Revision: 245249
URL: http://llvm.org/viewvc/llvm-project?rev=245249&view=rev
Log:
MIR Serialization: Serialize the local offsets for the stack objects.
Added:
llvm/trunk/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir
Modified:
llvm/trunk/include/llvm/CodeGen/MIRYamlMapping.h
llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/trunk/lib/CodeGen/MIRPrinter.cpp
Modified: llvm/trunk/include/llvm/CodeGen/MIRYamlMapping.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MIRYamlMapping.h?rev=245249&r1=245248&r2=245249&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MIRYamlMapping.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MIRYamlMapping.h Mon Aug 17 17:17:42 2015
@@ -184,8 +184,7 @@ template <> struct MappingTraits<Machine
/// determined by the object's type and frame information flags.
/// Dead stack objects aren't serialized.
///
-/// TODO: Determine isPreallocated flag by mapping between objects and local
-/// objects (Serialize local objects).
+/// The 'isPreallocated' flag is determined by the local offset.
struct MachineStackObject {
enum ObjectType { DefaultType, SpillSlot, VariableSized };
UnsignedValue ID;
@@ -196,6 +195,7 @@ struct MachineStackObject {
uint64_t Size = 0;
unsigned Alignment = 0;
StringValue CalleeSavedRegister;
+ Optional<int64_t> LocalOffset;
};
template <> struct ScalarEnumerationTraits<MachineStackObject::ObjectType> {
@@ -220,6 +220,7 @@ template <> struct MappingTraits<Machine
YamlIO.mapOptional("alignment", Object.Alignment);
YamlIO.mapOptional("callee-saved-register", Object.CalleeSavedRegister,
StringValue()); // Don't print it out when it's empty.
+ YamlIO.mapOptional("local-offset", Object.LocalOffset);
}
static const bool flow = true;
@@ -338,7 +339,6 @@ struct MachineFrameInfo {
bool HasCalls = false;
// TODO: Serialize StackProtectorIdx and FunctionContextIdx
unsigned MaxCallFrameSize = 0;
- // TODO: Serialize local frame objects.
bool HasOpaqueSPAdjustment = false;
bool HasVAStart = false;
bool HasMustTailInVarArgFunc = false;
Modified: llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp?rev=245249&r1=245248&r2=245249&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp Mon Aug 17 17:17:42 2015
@@ -487,6 +487,8 @@ bool MIRParserImpl::initializeFrameInfo(
if (parseCalleeSavedRegister(MF, PFS, CSIInfo, Object.CalleeSavedRegister,
ObjectIdx))
return true;
+ if (Object.LocalOffset)
+ MFI.mapLocalFrameObject(ObjectIdx, Object.LocalOffset.getValue());
}
MFI.setCalleeSavedInfo(CSIInfo);
if (!CSIInfo.empty())
Modified: llvm/trunk/lib/CodeGen/MIRPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRPrinter.cpp?rev=245249&r1=245248&r2=245249&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRPrinter.cpp Mon Aug 17 17:17:42 2015
@@ -324,6 +324,15 @@ void MIRPrinter::convertStackObjects(yam
else
MF.StackObjects[StackObject.ID].CalleeSavedRegister = Reg;
}
+ for (unsigned I = 0, E = MFI.getLocalFrameObjectCount(); I < E; ++I) {
+ auto LocalObject = MFI.getLocalFrameObjectMap(I);
+ auto StackObjectInfo = StackObjectOperandMapping.find(LocalObject.first);
+ assert(StackObjectInfo != StackObjectOperandMapping.end() &&
+ "Invalid stack object index");
+ const FrameIndexOperand &StackObject = StackObjectInfo->second;
+ assert(!StackObject.IsFixed && "Expected a locally mapped stack object");
+ MF.StackObjects[StackObject.ID].LocalOffset = LocalObject.second;
+ }
}
void MIRPrinter::convert(yaml::MachineFunction &MF,
Added: llvm/trunk/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir?rev=245249&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir (added)
+++ llvm/trunk/test/CodeGen/MIR/AArch64/stack-object-local-offset.mir Mon Aug 17 17:17:42 2015
@@ -0,0 +1,41 @@
+# RUN: llc -mtriple=aarch64-none-linux-gnu -start-after machine-sink -stop-after machine-sink -o /dev/null %s | FileCheck %s
+
+--- |
+ @var = global i64 0
+ @local_addr = global i64* null
+
+ define void @stack_local() {
+ entry:
+ %local_var = alloca i64
+ %val = load i64, i64* @var
+ store i64 %val, i64* %local_var
+ store i64* %local_var, i64** @local_addr
+ ret void
+ }
+...
+---
+name: stack_local
+isSSA: true
+tracksRegLiveness: true
+registers:
+ - { id: 0, class: gpr64common }
+ - { id: 1, class: gpr64 }
+ - { id: 2, class: gpr64common }
+ - { id: 3, class: gpr64common }
+frameInfo:
+ maxAlignment: 8
+# CHECK-LABEL: stack_local
+# CHECK: stack:
+# CHECK_NEXT: { id:0, name:local_var, offset:0, size:8, alignment:8, local-offset: -8 }
+stack:
+ - { id: 0,name: local_var,offset: 0,size: 8,alignment: 8, local-offset: -8 }
+body: |
+ bb.0.entry:
+ %0 = ADRP @var
+ %1 = LDRXui killed %0, @var :: (load 8 from %ir.var)
+ STRXui killed %1, %stack.0.local_var, 0 :: (store 8 into %ir.local_var)
+ %2 = ADRP @local_addr
+ %3 = ADDXri %stack.0.local_var, 0, 0
+ STRXui killed %3, killed %2, @local_addr :: (store 8 into %ir.local_addr)
+ RET_ReallyLR
+...
More information about the llvm-commits
mailing list