From 9f829f1cc4799e27ef02904b1bbdfd12a2a01424 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 30 Mar 2012 00:02:55 +0000 Subject: If we have a VLA that has a "use" in a metadata node that's then used here but it has no other uses, then we have a problem. E.g., int foo (const int *x) { char a[*x]; return 0; } If we assign 'a' a vreg and fast isel later on has to use the selection DAG isel, it will want to copy the value to the vreg. However, there are no uses, which goes counter to what selection DAG isel expects. llvm-svn: 153705 --- llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/SelectionDAG/FastISel.cpp') diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp index 4db10b75868..5de66670b2f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -599,7 +599,18 @@ bool FastISel::SelectCall(const User *I) { if (!Reg) Reg = lookUpRegForValue(Address); - if (!Reg && isa(Address) && + // If we have a VLA that has a "use" in a metadata node that's then used + // here but it has no other uses, then we have a problem. E.g., + // + // int foo (const int *x) { + // char a[*x]; + // return 0; + // } + // + // If we assign 'a' a vreg and fast isel later on has to use the selection + // DAG isel, it will want to copy the value to the vreg. However, there are + // no uses, which goes counter to what selection DAG isel expects. + if (!Reg && !Address->use_empty() && isa(Address) && (!isa(Address) || !FuncInfo.StaticAllocaMap.count(cast(Address)))) Reg = FuncInfo.InitializeRegForValue(Address); -- cgit v1.2.3