[llvm] r244534 - MIR Parser: Report an error when a fixed stack object is redefined.

Alex Lorenz via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 16:45:02 PDT 2015


Author: arphaman
Date: Mon Aug 10 18:45:02 2015
New Revision: 244534

URL: http://llvm.org/viewvc/llvm-project?rev=244534&view=rev
Log:
MIR Parser: Report an error when a fixed stack object is redefined.

Added:
    llvm/trunk/test/CodeGen/MIR/X86/fixed-stack-object-redefinition-error.mir
Modified:
    llvm/trunk/include/llvm/CodeGen/MIRYamlMapping.h
    llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp

Modified: llvm/trunk/include/llvm/CodeGen/MIRYamlMapping.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MIRYamlMapping.h?rev=244534&r1=244533&r2=244534&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MIRYamlMapping.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MIRYamlMapping.h Mon Aug 10 18:45:02 2015
@@ -245,7 +245,7 @@ template <> struct MappingTraits<Machine
 /// MachineFrameInfo class.
 struct FixedMachineStackObject {
   enum ObjectType { DefaultType, SpillSlot };
-  unsigned ID;
+  UnsignedValue ID;
   ObjectType Type = DefaultType;
   int64_t Offset = 0;
   uint64_t Size = 0;

Modified: llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp?rev=244534&r1=244533&r2=244534&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp Mon Aug 10 18:45:02 2015
@@ -489,8 +489,12 @@ bool MIRParserImpl::initializeFrameInfo(
     else
       ObjectIdx = MFI.CreateFixedSpillStackObject(Object.Size, Object.Offset);
     MFI.setObjectAlignment(ObjectIdx, Object.Alignment);
-    // TODO: Report an error when objects are redefined.
-    PFS.FixedStackObjectSlots.insert(std::make_pair(Object.ID, ObjectIdx));
+    if (!PFS.FixedStackObjectSlots.insert(std::make_pair(Object.ID.Value,
+                                                         ObjectIdx))
+             .second)
+      return error(Object.ID.SourceRange.Start,
+                   Twine("redefinition of fixed stack object '%fixed-stack.") +
+                       Twine(Object.ID.Value) + "'");
     if (parseCalleeSavedRegister(MF, PFS, CSIInfo, Object.CalleeSavedRegister,
                                  ObjectIdx))
       return true;

Added: llvm/trunk/test/CodeGen/MIR/X86/fixed-stack-object-redefinition-error.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/fixed-stack-object-redefinition-error.mir?rev=244534&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/fixed-stack-object-redefinition-error.mir (added)
+++ llvm/trunk/test/CodeGen/MIR/X86/fixed-stack-object-redefinition-error.mir Mon Aug 10 18:45:02 2015
@@ -0,0 +1,30 @@
+# RUN: not llc -march=x86 -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s
+
+--- |
+
+  define i32 @test(i32 %a, i32 %b) #0 {
+  entry:
+    %c = add i32 %a, %b
+    ret i32 %c
+  }
+
+  attributes #0 = { "no-frame-pointer-elim"="false" }
+
+...
+---
+name:            test
+tracksRegLiveness: true
+frameInfo:
+  maxAlignment:    4
+fixedStack:
+  - { id: 0, offset: 4, size: 4, alignment: 4, isImmutable: true, isAliased: false }
+# CHECK: [[@LINE+1]]:11: redefinition of fixed stack object '%fixed-stack.0'
+  - { id: 0, offset: 0, size: 4, alignment: 16, isImmutable: true, isAliased: false }
+body:
+  - id:              0
+    name:            entry
+    instructions:
+      - '%eax = MOV32rm %esp, 1, _, 4, _'
+      - '%eax = ADD32rm killed %eax, %esp, 1, _, 8, _, implicit-def dead %eflags'
+      - 'RETL %eax'
+...




More information about the llvm-commits mailing list