forked from OSchip/llvm-project
Fix PR 24633 - Handle undef values when parsing standalone constants.
llvm-svn: 247145
This commit is contained in:
parent
d511726ce9
commit
b9a68dbcae
|
@ -4228,6 +4228,7 @@ bool LLParser::parseConstantValue(Type *Ty, Constant *&C) {
|
||||||
switch (ID.Kind) {
|
switch (ID.Kind) {
|
||||||
case ValID::t_APSInt:
|
case ValID::t_APSInt:
|
||||||
case ValID::t_APFloat:
|
case ValID::t_APFloat:
|
||||||
|
case ValID::t_Undef:
|
||||||
case ValID::t_Constant:
|
case ValID::t_Constant:
|
||||||
case ValID::t_ConstantStruct:
|
case ValID::t_ConstantStruct:
|
||||||
case ValID::t_PackedConstantStruct: {
|
case ValID::t_PackedConstantStruct: {
|
||||||
|
|
|
@ -180,6 +180,12 @@
|
||||||
store i32 %conv, i32* getelementptr inbounds ([50 x %st], [50 x %st]* @values, i64 0, i64 0, i32 0), align 16
|
store i32 %conv, i32* getelementptr inbounds ([50 x %st], [50 x %st]* @values, i64 0, i64 0, i32 0), align 16
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define i8* @undef_value() {
|
||||||
|
entry:
|
||||||
|
%0 = load i8*, i8** undef, align 8
|
||||||
|
ret i8* %0
|
||||||
|
}
|
||||||
...
|
...
|
||||||
---
|
---
|
||||||
name: test
|
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)
|
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
|
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
|
||||||
|
...
|
||||||
|
|
|
@ -99,6 +99,10 @@ TEST(AsmParserTest, TypeAndConstantValueParsing) {
|
||||||
ASSERT_TRUE(V);
|
ASSERT_TRUE(V);
|
||||||
ASSERT_TRUE(isa<BlockAddress>(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_FALSE(parseConstantValue("duble 3.25", Error, M));
|
||||||
EXPECT_EQ(Error.getMessage(), "expected type");
|
EXPECT_EQ(Error.getMessage(), "expected type");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue