Fix PR 24633 - Handle undef values when parsing standalone constants.
authorAlex Lorenz <arphaman@gmail.com>
Wed, 9 Sep 2015 13:44:33 +0000 (13:44 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Wed, 9 Sep 2015 13:44:33 +0000 (13:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247145 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/LLParser.cpp
test/CodeGen/MIR/X86/memory-operands.mir
unittests/AsmParser/AsmParserTest.cpp

index 8ec5c6a4aa676f3dedfc36e022f31fdef4011668..1f786e4093f609fe894ba344f7c9c8bd2f0854c7 100644 (file)
@@ -4228,6 +4228,7 @@ bool LLParser::parseConstantValue(Type *Ty, Constant *&C) {
   switch (ID.Kind) {
   case ValID::t_APSInt:
   case ValID::t_APFloat:
+  case ValID::t_Undef:
   case ValID::t_Constant:
   case ValID::t_ConstantStruct:
   case ValID::t_PackedConstantStruct: {
index 0f9b38feda2a92ba93af0445b6e9998ad67cc904..3c9463d2f313e2cf38c0fc7e2d71fd24fae1d784 100644 (file)
     store i32 %conv, i32* getelementptr inbounds ([50 x %st], [50 x %st]* @values, i64 0, i64 0, i32 0), align 16
     ret void
   }
+
+  define i8* @undef_value() {
+  entry:
+    %0 = load i8*, i8** undef, align 8
+    ret i8* %0
+  }
 ...
 ---
 name:            test
@@ -490,3 +496,13 @@ body: |
     MOV32mr killed %rax, 1, _, 0, _, %edi, implicit killed %rdi :: (store 4 into `i32* getelementptr inbounds ([50 x %st], [50 x %st]* @values, i64 0, i64 0, i32 0)`, align 16)
     RETQ
 ...
+---
+name:            undef_value
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+  ; CHECK-LABEL: name: undef_value
+  ; CHECK: %rax = MOV64rm undef %rax, 1, _, 0, _ :: (load 8 from `i8** undef`)
+    %rax = MOV64rm undef %rax, 1, _, 0, _ :: (load 8 from `i8** undef`)
+    RETQ %rax
+...
index ef16eb1cfb382efca4696dc590827cd2a6103f0d..4189310fda23b429968e2debdbbe94f3d11b0b84 100644 (file)
@@ -99,6 +99,10 @@ TEST(AsmParserTest, TypeAndConstantValueParsing) {
   ASSERT_TRUE(V);
   ASSERT_TRUE(isa<BlockAddress>(V));
 
+  V = parseConstantValue("i8** undef", Error, M);
+  ASSERT_TRUE(V);
+  ASSERT_TRUE(isa<UndefValue>(V));
+
   EXPECT_FALSE(parseConstantValue("duble 3.25", Error, M));
   EXPECT_EQ(Error.getMessage(), "expected type");