[llvm-commits] [gcc-plugin] r83261 - in /gcc-plugin/trunk: llvm-convert.cpp llvm-debug.cpp llvm-types.cpp
Duncan Sands
baldrick at free.fr
Sat Oct 3 07:25:31 PDT 2009
Author: baldrick
Date: Sat Oct 3 09:25:31 2009
New Revision: 83261
URL: http://llvm.org/viewvc/llvm-project?rev=83261&view=rev
Log:
If a structure field is at a variable offset from the start of
a structure, then DECL_FIELD_OFFSET will be NULL. So test for
NULL rather than the tree code not being an integer constant.
GCC clears out the field offset as part of its policy of freeing
language specific data.
Modified:
gcc-plugin/trunk/llvm-convert.cpp
gcc-plugin/trunk/llvm-debug.cpp
gcc-plugin/trunk/llvm-types.cpp
Modified: gcc-plugin/trunk/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-convert.cpp?rev=83261&r1=83260&r2=83261&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-convert.cpp (original)
+++ gcc-plugin/trunk/llvm-convert.cpp Sat Oct 3 09:25:31 2009
@@ -5712,9 +5712,9 @@
/// getFieldOffsetInBits - Return the offset (in bits) of a FIELD_DECL in a
/// structure.
static unsigned getFieldOffsetInBits(tree Field) {
- assert(DECL_FIELD_BIT_OFFSET(Field) != 0 && DECL_FIELD_OFFSET(Field) != 0);
+ assert(DECL_FIELD_BIT_OFFSET(Field) != 0);
unsigned Result = TREE_INT_CST_LOW(DECL_FIELD_BIT_OFFSET(Field));
- if (TREE_CODE(DECL_FIELD_OFFSET(Field)) == INTEGER_CST)
+ if (DECL_FIELD_OFFSET(Field))
Result += TREE_INT_CST_LOW(DECL_FIELD_OFFSET(Field))*8;
return Result;
}
Modified: gcc-plugin/trunk/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-debug.cpp?rev=83261&r1=83260&r2=83261&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-debug.cpp (original)
+++ gcc-plugin/trunk/llvm-debug.cpp Sat Oct 3 09:25:31 2009
@@ -647,8 +647,7 @@
if (TREE_CODE(Member) == FIELD_DECL) {
- if (DECL_FIELD_OFFSET(Member) == 0 ||
- TREE_CODE(DECL_FIELD_OFFSET(Member)) != INTEGER_CST)
+ if (DECL_FIELD_OFFSET(Member) == 0)
// FIXME: field with variable position, skip it for now.
continue;
Modified: gcc-plugin/trunk/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-types.cpp?rev=83261&r1=83260&r2=83261&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-types.cpp (original)
+++ gcc-plugin/trunk/llvm-types.cpp Sat Oct 3 09:25:31 2009
@@ -446,9 +446,9 @@
/// getFieldOffsetInBits - Return the offset (in bits) of a FIELD_DECL in a
/// structure.
static uint64_t getFieldOffsetInBits(tree Field) {
- assert(DECL_FIELD_BIT_OFFSET(Field) != 0 && DECL_FIELD_OFFSET(Field) != 0);
+ assert(DECL_FIELD_BIT_OFFSET(Field) != 0);
uint64_t Result = getInt64(DECL_FIELD_BIT_OFFSET(Field), true);
- if (TREE_CODE(DECL_FIELD_OFFSET(Field)) == INTEGER_CST)
+ if (DECL_FIELD_OFFSET(Field))
Result += getInt64(DECL_FIELD_OFFSET(Field), true)*8;
return Result;
}
@@ -591,7 +591,7 @@
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
if (TREE_CODE(Field) != FIELD_DECL) continue;
- if (TREE_CODE(DECL_FIELD_OFFSET(Field)) != INTEGER_CST)
+ if (!DECL_FIELD_OFFSET(Field))
return true;
uint64_t FieldBitOffset = getFieldOffsetInBits(Field);
@@ -1641,8 +1641,7 @@
/// false.
bool TypeConverter::DecodeStructFields(tree Field,
StructTypeConversionInfo &Info) {
- if (TREE_CODE(Field) != FIELD_DECL ||
- TREE_CODE(DECL_FIELD_OFFSET(Field)) != INTEGER_CST)
+ if (TREE_CODE(Field) != FIELD_DECL || !DECL_FIELD_OFFSET(Field))
return true;
// Handle bit-fields specially.
@@ -1938,8 +1937,7 @@
// offset.
unsigned CurFieldNo = 0;
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field))
- if (TREE_CODE(Field) == FIELD_DECL &&
- TREE_CODE(DECL_FIELD_OFFSET(Field)) == INTEGER_CST) {
+ if (TREE_CODE(Field) == FIELD_DECL && DECL_FIELD_OFFSET(Field)) {
uint64_t FieldOffsetInBits = getFieldOffsetInBits(Field);
tree FieldType = getDeclaredType(Field);
const Type *FieldTy = ConvertType(FieldType);
More information about the llvm-commits
mailing list