[LLVMbugs] [Bug 4963] New: constant folding insertvalue loses packedness of struct
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sat Sep 12 14:25:27 PDT 2009
http://llvm.org/bugs/show_bug.cgi?id=4963
Summary: constant folding insertvalue loses packedness of struct
Product: new-bugs
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Keywords: miscompilation
Severity: normal
Priority: P2
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: tomas.l.olsen at gmail.com
CC: llvmbugs at cs.uiuc.edu
Consider the following:
D code using C binding (much like C):
auto i = LLVMInt32Type();
auto t = LLVMStructType(&i, 1, 1);
auto tmp = LLVMGetUndef(t);
LLVMDumpType(LLVMTypeOf(tmp));
uint idx = 0;
tmp = LLVMConstInsertValue(tmp, LLVMConstInt(i, 0, 0), &idx, 1);
LLVMDumpType(LLVMTypeOf(tmp));
Dumps:
<{ i32 }>
{ i32 }
This patch is against revision 79806, but it is also present in 2.6, it's a
pretty serious bug, and I think it should be fixed in 2.6 as well.
===================================================================
--- ../lib/VMCore/ConstantFold.cpp (revision 79806)
+++ ../lib/VMCore/ConstantFold.cpp (working copy)
@@ -520,8 +520,8 @@
UndefValue::get(MemberTy);
Ops[i] = const_cast<Constant*>(Op);
}
- if (isa<StructType>(AggTy))
- return ConstantStruct::get(Context, Ops);
+ if (const StructType* ST = dyn_cast<StructType>(AggTy))
+ return ConstantStruct::get(Context, Ops, ST->isPacked());
else
return ConstantArray::get(cast<ArrayType>(AggTy), Ops);
}
@@ -549,8 +549,8 @@
Constant::getNullValue(MemberTy);
Ops[i] = const_cast<Constant*>(Op);
}
- if (isa<StructType>(AggTy))
- return ConstantStruct::get(Context, Ops);
+ if (const StructType* ST = dyn_cast<StructType>(AggTy))
+ return ConstantStruct::get(Context, Ops, ST->isPacked());
else
return ConstantArray::get(cast<ArrayType>(AggTy), Ops);
}
@@ -566,8 +566,8 @@
Ops[i] = const_cast<Constant*>(Op);
}
Constant *C;
- if (isa<StructType>(Agg->getType()))
- C = ConstantStruct::get(Context, Ops);
+ if (const StructType* ST = dyn_cast<StructType>(Agg->getType()))
+ C = ConstantStruct::get(Context, Ops, ST->isPacked());
else
C = ConstantArray::get(cast<ArrayType>(Agg->getType()), Ops);
return C;
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list