summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2015-07-30 22:00:17 +0000
committerAlex Lorenz <arphaman@gmail.com>2015-07-30 22:00:17 +0000
commit60bf5996073607f31dd41f36e77b6f49d6f10382 (patch)
treefe8db29182f2f3ae5f8f1c450d417ceebf6d4ab3
parenta06c0c6401fd793cfbef1b15630a65d740ff4095 (diff)
downloadbcm5719-llvm-60bf5996073607f31dd41f36e77b6f49d6f10382.tar.gz
bcm5719-llvm-60bf5996073607f31dd41f36e77b6f49d6f10382.zip
MIR Parser: Report an error when a constant pool item is redefined.
llvm-svn: 243696
-rw-r--r--llvm/include/llvm/CodeGen/MIRYamlMapping.h2
-rw-r--r--llvm/lib/CodeGen/MIRParser/MIRParser.cpp9
-rw-r--r--llvm/test/CodeGen/MIR/X86/constant-pool-item-redefinition-error.mir27
3 files changed, 34 insertions, 4 deletions
diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
index c986f57cd95..777819f3eae 100644
--- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h
+++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
@@ -285,7 +285,7 @@ template <> struct MappingTraits<FixedMachineStackObject> {
};
struct MachineConstantPoolValue {
- unsigned ID;
+ UnsignedValue ID;
StringValue Value;
unsigned Alignment = 0;
};
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index 7966f389d3e..1bf4684e924 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -559,9 +559,12 @@ bool MIRParserImpl::initializeConstantPool(
YamlConstant.Alignment
? YamlConstant.Alignment
: M.getDataLayout().getPrefTypeAlignment(Value->getType());
- // TODO: Report an error when the same constant pool value ID is redefined.
- ConstantPoolSlots.insert(std::make_pair(
- YamlConstant.ID, ConstantPool.getConstantPoolIndex(Value, Alignment)));
+ unsigned Index = ConstantPool.getConstantPoolIndex(Value, Alignment);
+ if (!ConstantPoolSlots.insert(std::make_pair(YamlConstant.ID.Value, Index))
+ .second)
+ return error(YamlConstant.ID.SourceRange.Start,
+ Twine("redefinition of constant pool item '%const.") +
+ Twine(YamlConstant.ID.Value) + "'");
}
return false;
}
diff --git a/llvm/test/CodeGen/MIR/X86/constant-pool-item-redefinition-error.mir b/llvm/test/CodeGen/MIR/X86/constant-pool-item-redefinition-error.mir
new file mode 100644
index 00000000000..0ff67302876
--- /dev/null
+++ b/llvm/test/CodeGen/MIR/X86/constant-pool-item-redefinition-error.mir
@@ -0,0 +1,27 @@
+# RUN: not llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s
+
+--- |
+
+ define double @test(double %a, float %b) {
+ entry:
+ %c = fadd double %a, 3.250000e+00
+ ret double %c
+ }
+
+...
+---
+name: test
+constants:
+ - id: 0
+ value: 'double 3.250000e+00'
+# CHECK: [[@LINE+1]]:18: redefinition of constant pool item '%const.0'
+ - id: 0
+ value: 'double 3.250000e+00'
+body:
+ - id: 0
+ name: entry
+ instructions:
+ - '%xmm0 = ADDSDrm killed %xmm0, %rip, 1, _, %const.0, _'
+ - 'RETQ %xmm0'
+...
+
OpenPOWER on IntegriCloud