[llvm-commits] [dragonegg] r155228 - in /dragonegg/branches/release_31: include/dragonegg/Internals.h include/dragonegg/Trees.h src/Aliasing.cpp src/Backend.cpp src/Constants.cpp src/Convert.cpp src/Debug.cpp src/DefaultABI.cpp src/Trees.cpp src/Types.cpp test/compilator/local/c/ test/compilator/local/c/2012-04-20-PointerBIT_AND_EXPR.c
Duncan Sands
baldrick at free.fr
Fri Apr 20 13:21:51 PDT 2012
Author: baldrick
Date: Fri Apr 20 15:21:50 2012
New Revision: 155228
URL: http://llvm.org/viewvc/llvm-project?rev=155228&view=rev
Log:
Port improved gcc-4.7 support from mainline, up to mainline revision 155055.
Added:
dragonegg/branches/release_31/test/compilator/local/c/
dragonegg/branches/release_31/test/compilator/local/c/2012-04-20-PointerBIT_AND_EXPR.c
Modified:
dragonegg/branches/release_31/include/dragonegg/Internals.h
dragonegg/branches/release_31/include/dragonegg/Trees.h
dragonegg/branches/release_31/src/Aliasing.cpp
dragonegg/branches/release_31/src/Backend.cpp
dragonegg/branches/release_31/src/Constants.cpp
dragonegg/branches/release_31/src/Convert.cpp
dragonegg/branches/release_31/src/Debug.cpp
dragonegg/branches/release_31/src/DefaultABI.cpp
dragonegg/branches/release_31/src/Trees.cpp
dragonegg/branches/release_31/src/Types.cpp
Modified: dragonegg/branches/release_31/include/dragonegg/Internals.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_31/include/dragonegg/Internals.h?rev=155228&r1=155227&r2=155228&view=diff
==============================================================================
--- dragonegg/branches/release_31/include/dragonegg/Internals.h (original)
+++ dragonegg/branches/release_31/include/dragonegg/Internals.h Fri Apr 20 15:21:50 2012
@@ -328,15 +328,13 @@
/// of the types involved. This is an inferred cast.
Value *CastToAnyType (Value *V, bool VSigned, Type *Ty, bool TySigned);
- /// CastToUIntType - Cast the specified value to the specified type assuming
- /// that V's type and Ty are integral types. This arbitrates between BitCast,
- /// Trunc and ZExt.
- Value *CastToUIntType(Value *V, Type *Ty);
-
- /// CastToSIntType - Cast the specified value to the specified type assuming
- /// that V's type and Ty are integral types. This arbitrates between BitCast,
- /// Trunc and SExt.
- Value *CastToSIntType(Value *V, Type *Ty);
+ /// CastFromSameSizeInteger - Cast an integer (or vector of integer) value to
+ /// the given scalar (resp. vector of scalar) type of the same bitwidth.
+ Value *CastFromSameSizeInteger(Value *V, Type *Ty);
+
+ /// CastToSameSizeInteger - Cast the specified scalar (or vector of scalar)
+ /// value to an integer (resp. vector of integer) of the same bit width.
+ Value *CastToSameSizeInteger(Value *V);
/// CastToFPType - Cast the specified value to the specified type assuming
/// that V's type and Ty are floating point types. This arbitrates between
Modified: dragonegg/branches/release_31/include/dragonegg/Trees.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_31/include/dragonegg/Trees.h?rev=155228&r1=155227&r2=155228&view=diff
==============================================================================
--- dragonegg/branches/release_31/include/dragonegg/Trees.h (original)
+++ dragonegg/branches/release_31/include/dragonegg/Trees.h Fri Apr 20 15:21:50 2012
@@ -43,6 +43,7 @@
FLOAT_TYPE, // A scalar, complex or vector floating point type.
INTEGRAL_TYPE, // A enumeral, boolean or integer type.
RECORD_OR_UNION_TYPE, // A record, union or qualified union type.
+ TYPE, // Any type.
};
/// isa - Return true if the given tree has the specified code.
@@ -61,6 +62,8 @@
return INTEGRAL_TYPE_P(t);
case RECORD_OR_UNION_TYPE:
return RECORD_OR_UNION_TYPE_P(t);
+ case TYPE:
+ return TYPE_P(t);
}
}
Modified: dragonegg/branches/release_31/src/Aliasing.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_31/src/Aliasing.cpp?rev=155228&r1=155227&r2=155228&view=diff
==============================================================================
--- dragonegg/branches/release_31/src/Aliasing.cpp (original)
+++ dragonegg/branches/release_31/src/Aliasing.cpp Fri Apr 20 15:21:50 2012
@@ -141,7 +141,8 @@
// Create metadata describing the new node hanging off root. The name doesn't
// matter much but needs to be unique for the compilation unit.
- tree type = TYPE_CANONICAL(TYPE_MAIN_VARIANT(TYPE_P(t) ? t : TREE_TYPE(t)));
+ tree type =
+ TYPE_CANONICAL(TYPE_MAIN_VARIANT(isa<TYPE>(t) ? t : TREE_TYPE(t)));
std::string TreeName = ("alias set " + Twine(alias_set) + ": " +
getDescriptiveName(type)).str();
MDBuilder MDHelper(Context);
Modified: dragonegg/branches/release_31/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_31/src/Backend.cpp?rev=155228&r1=155227&r2=155228&view=diff
==============================================================================
--- dragonegg/branches/release_31/src/Backend.cpp (original)
+++ dragonegg/branches/release_31/src/Backend.cpp Fri Apr 20 15:21:50 2012
@@ -145,7 +145,8 @@
/// set_decl_llvm - Remember the LLVM value for a GCC declaration.
Value *set_decl_llvm(tree t, Value *V) {
- assert(HAS_RTL_P(t) && "Expected a declaration with RTL!");
+ assert((isa<CONST_DECL>(t) || HAS_RTL_P(t)) &&
+ "Expected a declaration with RTL!");
assert((!V || isa<GlobalValue>(V)) && "Expected a global value!");
setCachedValue(t, V);
return V;
@@ -153,7 +154,8 @@
/// get_decl_llvm - Retrieve the LLVM value for a GCC declaration, or NULL.
Value *get_decl_llvm(tree t) {
- assert(HAS_RTL_P(t) && "Expected a declaration with RTL!");
+ assert((isa<CONST_DECL>(t) || HAS_RTL_P(t)) &&
+ "Expected a declaration with RTL!");
Value *V = getCachedValue(t);
return V ? V->stripPointerCasts() : 0;
}
@@ -1083,8 +1085,9 @@
// Global register variable with asm name, e.g.:
// register unsigned long esp __asm__("ebp");
- if (!isa<FUNCTION_DECL>(decl) && DECL_REGISTER(decl)) {
- // This just verifies that the variable is ok. The actual "load/store"
+ if (!isa<FUNCTION_DECL>(decl) && !isa<CONST_DECL>(decl) &&
+ DECL_REGISTER(decl)) {
+ // This just verifies that the variable is ok. The actual "load/store"
// code paths handle accesses to the variable.
ValidateRegisterVariable(decl);
return NULL;
@@ -2253,6 +2256,8 @@
pass_info.pos_op = PASS_POS_REPLACE;
register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
+ // Leave pass_ipa_tm.
+
// Leave pass_ipa_lower_emutls. ???
// Leave pass_ipa_whole_program_visibility. ???
@@ -2289,12 +2294,14 @@
pass_info.pos_op = PASS_POS_REPLACE;
register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
+#if (GCC_MINOR < 7)
// Turn off pass_ipa_type_escape.
pass_info.pass = &pass_simple_ipa_null.pass;
pass_info.reference_pass_name = "type-escape-var";
pass_info.ref_pass_instance_number = 0;
pass_info.pos_op = PASS_POS_REPLACE;
register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
+#endif
// Turn off pass_ipa_pta.
pass_info.pass = &pass_simple_ipa_null.pass;
@@ -2303,12 +2310,14 @@
pass_info.pos_op = PASS_POS_REPLACE;
register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
+#if (GCC_MINOR < 7)
// Turn off pass_ipa_struct_reorg.
pass_info.pass = &pass_simple_ipa_null.pass;
pass_info.reference_pass_name = "ipa_struct_reorg";
pass_info.ref_pass_instance_number = 0;
pass_info.pos_op = PASS_POS_REPLACE;
register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
+#endif
}
// Replace the LTO gimple pass with a pass that converts same-body aliases and
@@ -2342,56 +2351,58 @@
NULL);
if (!EnableGCCOptimizations) {
- // Disable pass_lower_eh_dispatch, which runs after LLVM conversion.
+ // Disable pass_lower_eh_dispatch.
pass_info.pass = &pass_gimple_null.pass;
pass_info.reference_pass_name = "ehdisp";
pass_info.ref_pass_instance_number = 0;
pass_info.pos_op = PASS_POS_REPLACE;
register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
- // Disable pass_all_optimizations, which runs after LLVM conversion.
+ // Disable pass_all_optimizations.
pass_info.pass = &pass_gimple_null.pass;
pass_info.reference_pass_name = "*all_optimizations";
pass_info.ref_pass_instance_number = 0;
pass_info.pos_op = PASS_POS_REPLACE;
register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
- // Disable pass_lower_complex_O0, which runs after LLVM conversion.
+ // Leave pass_tm_init.
+
+ // Disable pass_lower_complex_O0.
pass_info.pass = &pass_gimple_null.pass;
pass_info.reference_pass_name = "cplxlower0";
pass_info.ref_pass_instance_number = 0;
pass_info.pos_op = PASS_POS_REPLACE;
register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
- // Disable pass_cleanup_eh, which runs after LLVM conversion.
+ // Disable pass_cleanup_eh.
pass_info.pass = &pass_gimple_null.pass;
pass_info.reference_pass_name = "ehcleanup";
pass_info.ref_pass_instance_number = 0;
pass_info.pos_op = PASS_POS_REPLACE;
register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
- // Disable pass_lower_resx, which runs after LLVM conversion.
+ // Disable pass_lower_resx.
pass_info.pass = &pass_gimple_null.pass;
pass_info.reference_pass_name = "resx";
pass_info.ref_pass_instance_number = 0;
pass_info.pos_op = PASS_POS_REPLACE;
register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
- // Disable pass_nrv, which runs after LLVM conversion.
+ // Disable pass_nrv.
pass_info.pass = &pass_gimple_null.pass;
pass_info.reference_pass_name = "nrv";
pass_info.ref_pass_instance_number = 0;
pass_info.pos_op = PASS_POS_REPLACE;
register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
- // Disable pass_mudflap_2, which runs after LLVM conversion.
+ // Disable pass_mudflap_2. ???
pass_info.pass = &pass_gimple_null.pass;
pass_info.reference_pass_name = "mudflap2";
pass_info.ref_pass_instance_number = 0;
pass_info.pos_op = PASS_POS_REPLACE;
register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
- // Disable pass_cleanup_cfg_post_optimizing, which runs after LLVM conversion.
+ // Disable pass_cleanup_cfg_post_optimizing.
pass_info.pass = &pass_gimple_null.pass;
pass_info.reference_pass_name = "optimized";
pass_info.ref_pass_instance_number = 0;
Modified: dragonegg/branches/release_31/src/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_31/src/Constants.cpp?rev=155228&r1=155227&r2=155228&view=diff
==============================================================================
--- dragonegg/branches/release_31/src/Constants.cpp (original)
+++ dragonegg/branches/release_31/src/Constants.cpp Fri Apr 20 15:21:50 2012
@@ -1147,14 +1147,11 @@
// Record all interesting fields so they can easily be visited backwards.
SmallVector<tree, 16> Fields;
for (tree field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
- assert(isa<FIELD_DECL>(field) && "Lang data not freed?");
+ if (!isa<FIELD_DECL>(field)) continue;
// Ignore fields with variable or unknown position since they cannot be
// default initialized.
if (!OffsetIsLLVMCompatible(field))
continue;
- // Skip fields that are known not to be present.
- if (isa<QUAL_UNION_TYPE>(type) && integer_zerop(DECL_QUALIFIER(field)))
- continue;
Fields.push_back(field);
}
@@ -1384,7 +1381,8 @@
/// ConvertInitializerImpl - Implementation of ConvertInitializer.
static Constant *ConvertInitializerImpl(tree exp, TargetFolder &Folder) {
- assert(!HAS_RTL_P(exp) && "Cache collision with decl_llvm!");
+ assert(!isa<CONST_DECL>(exp) && !HAS_RTL_P(exp) &&
+ "Cache collision with decl_llvm!");
// If we already converted the initializer then return the cached copy.
if (Constant *C = cast_or_null<Constant>(getCachedValue(exp)))
@@ -1611,6 +1609,23 @@
return TheTreeToLLVM->AddressOfLABEL_DECL(exp);
}
+#if (GCC_MINOR > 5)
+/// AddressOfMEM_REF - Return the address of a memory reference.
+static Constant *AddressOfMEM_REF(tree exp, TargetFolder &Folder) {
+ // The address is the first operand offset in bytes by the second.
+ Constant *Addr = getAsRegister(TREE_OPERAND(exp, 0), Folder);
+ if (integer_zerop(TREE_OPERAND(exp, 1)))
+ return Addr;
+
+ // Convert to a byte pointer and displace by the offset.
+ Addr = Folder.CreateBitCast(Addr, GetUnitPointerType(Context));
+ APInt Delta = getIntegerValue(TREE_OPERAND(exp, 1));
+ Constant *Offset = ConstantInt::get(Context, Delta);
+ // The address is always inside the referenced object, so "inbounds".
+ return Folder.CreateInBoundsGetElementPtr(Addr, Offset);
+}
+#endif
+
/// AddressOfImpl - Implementation of AddressOf.
static Constant *AddressOfImpl(tree exp, TargetFolder &Folder) {
Constant *Addr;
@@ -1651,6 +1666,11 @@
case LABEL_DECL:
Addr = AddressOfLABEL_DECL(exp, Folder);
break;
+#if (GCC_MINOR > 5)
+ case MEM_REF:
+ Addr = AddressOfMEM_REF(exp, Folder);
+ break;
+#endif
}
// Ensure that the address has the expected type. It is simpler to do this
Modified: dragonegg/branches/release_31/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_31/src/Convert.cpp?rev=155228&r1=155227&r2=155228&view=diff
==============================================================================
--- dragonegg/branches/release_31/src/Convert.cpp (original)
+++ dragonegg/branches/release_31/src/Convert.cpp Fri Apr 20 15:21:50 2012
@@ -621,6 +621,7 @@
/// isLocalDecl - Whether this declaration is local to the current function.
static bool isLocalDecl(tree decl) {
+ if (isa<CONST_DECL>(decl)) return false;
assert(HAS_RTL_P(decl) && "Expected a declaration with RTL!");
return
// GCC bug workaround: RESULT_DECL may not have DECL_CONTEXT set in thunks.
@@ -1781,7 +1782,53 @@
return Builder.CreateCast(opc, V, DestTy);
}
-/// CastToFPType - Cast the specified value to the specified type assuming
+/// CastFromSameSizeInteger - Cast an integer (or vector of integer) value to
+/// the given scalar (resp. vector of scalar) type of the same bitwidth.
+Value *TreeToLLVM::CastFromSameSizeInteger(Value *V, Type *Ty) {
+ Type *OrigTy = V->getType();
+ Type *OrigEltTy = OrigTy->getScalarType();
+ assert(OrigEltTy->isIntegerTy() && "Expected an integer type!");
+ Type *EltTy = Ty->getScalarType();
+ if (EltTy->isIntegerTy()) {
+ // Already an integer/vector of integer - nothing to do.
+ assert(OrigTy == Ty && "Integer type not same size!");
+ return V;
+ }
+ if (EltTy->isPointerTy()) {
+ // A pointer/vector of pointer - use inttoptr.
+ assert(OrigEltTy->getPrimitiveSizeInBits() ==
+ TD.getPointerSizeInBits() && "Pointer type not same size!");
+ return Builder.CreateIntToPtr(V, Ty);
+ }
+ // Everything else.
+ assert(Ty->isFPOrFPVectorTy() && "Expected a floating point type!");
+ return Builder.CreateBitCast(V, Ty); // Will catch any size mismatch.
+}
+
+/// CastToSameSizeInteger - Cast the specified scalar (or vector of scalar)
+/// value to an integer (resp. vector of integer) of the same bit width.
+Value *TreeToLLVM::CastToSameSizeInteger(Value *V) {
+ Type *OrigTy = V->getType();
+ Type *OrigEltTy = OrigTy->getScalarType();
+ if (OrigEltTy->isIntegerTy())
+ // Already an integer/vector of integer - nothing to do.
+ return V;
+ unsigned VecElts = isa<VectorType>(OrigTy) ?
+ cast<VectorType>(OrigTy)->getNumElements() : 0;
+ if (OrigEltTy->isPointerTy()) {
+ // A pointer/vector of pointer - form a (vector of) pointer sized integers.
+ Type *NewEltTy = TD.getIntPtrType(Context);
+ Type *NewTy = VecElts ? VectorType::get(NewEltTy, VecElts) : NewEltTy;
+ return Builder.CreatePtrToInt(V, NewTy);
+ }
+ // Everything else.
+ assert(OrigTy->isFPOrFPVectorTy() && "Expected a floating point type!");
+ unsigned BitWidth = OrigEltTy->getPrimitiveSizeInBits();
+ Type *NewEltTy = IntegerType::get(Context, BitWidth);
+ Type *NewTy = VecElts ? VectorType::get(NewEltTy, VecElts) : NewEltTy;
+ return Builder.CreateBitCast(V, NewTy);
+}
+
/// that the value and type are floating point.
Value *TreeToLLVM::CastToFPType(Value *V, Type* Ty) {
unsigned SrcBits = V->getType()->getPrimitiveSizeInBits();
@@ -1894,7 +1941,7 @@
Type *Ty = ConvertType(type);
unsigned TotalCost = 0;
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
- assert(isa<FIELD_DECL>(Field) && "Lang data not freed?");
+ if (!isa<FIELD_DECL>(Field)) continue;
// If the field has no size, for example because it is a C-style variable
// length array, then just give up.
if (!DECL_SIZE(Field))
@@ -1956,6 +2003,7 @@
// Copy each field in turn.
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
+ if (!isa<FIELD_DECL>(Field)) continue;
// Ignore fields of size zero.
if (integer_zerop(DECL_SIZE(Field)))
continue;
@@ -2053,6 +2101,7 @@
// Zero each field in turn.
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
+ if (!isa<FIELD_DECL>(Field)) continue;
// Ignore fields of size zero.
if (integer_zerop(DECL_SIZE(Field)))
continue;
@@ -2336,7 +2385,7 @@
static Constant *ConvertTypeInfo(tree type) {
// TODO: Once pass_ipa_free_lang is made a default pass, remove the call to
// lookup_type_for_runtime below.
- if (TYPE_P (type))
+ if (isa<TYPE>(type))
type = lookup_type_for_runtime (type);
STRIP_NOPS(type);
if (isa<ADDR_EXPR>(type))
@@ -7114,15 +7163,24 @@
}
Value *TreeToLLVM::EmitReg_BIT_AND_EXPR(tree op0, tree op1) {
- return Builder.CreateAnd(EmitRegister(op0), EmitRegister(op1));
+ Value *LHS = CastToSameSizeInteger(EmitRegister(op0));
+ Value *RHS = CastToSameSizeInteger(EmitRegister(op1));
+ Value *Res = Builder.CreateAnd(LHS, RHS);
+ return CastFromSameSizeInteger(Res, getRegType(TREE_TYPE(op0)));
}
Value *TreeToLLVM::EmitReg_BIT_IOR_EXPR(tree op0, tree op1) {
- return Builder.CreateOr(EmitRegister(op0), EmitRegister(op1));
+ Value *LHS = CastToSameSizeInteger(EmitRegister(op0));
+ Value *RHS = CastToSameSizeInteger(EmitRegister(op1));
+ Value *Res = Builder.CreateOr(LHS, RHS);
+ return CastFromSameSizeInteger(Res, getRegType(TREE_TYPE(op0)));
}
Value *TreeToLLVM::EmitReg_BIT_XOR_EXPR(tree op0, tree op1) {
- return Builder.CreateXor(EmitRegister(op0), EmitRegister(op1));
+ Value *LHS = CastToSameSizeInteger(EmitRegister(op0));
+ Value *RHS = CastToSameSizeInteger(EmitRegister(op1));
+ Value *Res = Builder.CreateXor(LHS, RHS);
+ return CastFromSameSizeInteger(Res, getRegType(TREE_TYPE(op0)));
}
Value *TreeToLLVM::EmitReg_COMPLEX_EXPR(tree op0, tree op1) {
@@ -8145,6 +8203,16 @@
void TreeToLLVM::RenderGIMPLE_ASSIGN(gimple stmt) {
tree lhs = gimple_assign_lhs(stmt);
+
+#if (GCC_MINOR > 6)
+ // Assigning a right-hand side with TREE_CLOBBER_P says that the left-hand
+ // side is dead from this point on.
+ // TODO: Consider outputting an llvm.lifetime.end intrinsic to indicate this.
+ if (get_gimple_rhs_class(gimple_expr_code(stmt)) == GIMPLE_SINGLE_RHS &&
+ TREE_CLOBBER_P(gimple_assign_rhs1(stmt)))
+ return;
+#endif
+
if (isa<AGGREGATE_TYPE>(TREE_TYPE(lhs))) {
assert(get_gimple_rhs_class(gimple_expr_code(stmt)) == GIMPLE_SINGLE_RHS &&
"Aggregate type but rhs not simple!");
Modified: dragonegg/branches/release_31/src/Debug.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_31/src/Debug.cpp?rev=155228&r1=155227&r2=155228&view=diff
==============================================================================
--- dragonegg/branches/release_31/src/Debug.cpp (original)
+++ dragonegg/branches/release_31/src/Debug.cpp Fri Apr 20 15:21:50 2012
@@ -92,7 +92,7 @@
static uint64_t NodeSizeInBits(tree Node) {
if (isa<ERROR_MARK>(Node)) {
return BITS_PER_WORD;
- } else if (TYPE_P(Node)) {
+ } else if (isa<TYPE>(Node)) {
if (TYPE_SIZE(Node) == NULL_TREE)
return 0;
else if (isInt64(TYPE_SIZE(Node), true))
@@ -115,7 +115,7 @@
/// regardless of whether the node is a TYPE or DECL.
static uint64_t NodeAlignInBits(tree Node) {
if (isa<ERROR_MARK>(Node)) return BITS_PER_WORD;
- if (TYPE_P(Node)) return TYPE_ALIGN(Node);
+ if (isa<TYPE>(Node)) return TYPE_ALIGN(Node);
if (DECL_P(Node)) return DECL_ALIGN(Node);
return BITS_PER_WORD;
}
@@ -135,7 +135,7 @@
if (DECL_P(Node)) {
Name = DECL_NAME(Node);
- } else if (TYPE_P(Node)) {
+ } else if (isa<TYPE>(Node)) {
Name = TYPE_NAME(Node);
}
@@ -164,12 +164,12 @@
if (DECL_P(Node)) {
Name = DECL_NAME(Node);
- } else if (TYPE_P(Node)) {
+ } else if (isa<TYPE>(Node)) {
Name = TYPE_NAME(Node);
}
if (Name) {
- if (TYPE_STUB_DECL(Name)) {
+ if (isa<TYPE>(Name) && TYPE_STUB_DECL(Name)) {
tree Stub = TYPE_STUB_DECL(Name);
Location = expand_location(DECL_SOURCE_LOCATION(Stub));
} else if (DECL_P(Name)) {
@@ -178,7 +178,7 @@
}
if (!Location.line) {
- if (UseStub && TYPE_STUB_DECL(Node)) {
+ if (UseStub && isa<TYPE>(Node) && TYPE_STUB_DECL(Node)) {
tree Stub = TYPE_STUB_DECL(Node);
Location = expand_location(DECL_SOURCE_LOCATION(Stub));
} else if (DECL_P(Node)) {
@@ -291,7 +291,7 @@
unsigned VIndex = 0;
DIType ContainingType;
if (DECL_VINDEX (FnDecl) &&
- DECL_CONTEXT (FnDecl) && TYPE_P((DECL_CONTEXT (FnDecl)))) { // Workaround GCC PR42653
+ DECL_CONTEXT (FnDecl) && isa<TYPE>((DECL_CONTEXT (FnDecl)))) { // Workaround GCC PR42653
if (host_integerp (DECL_VINDEX (FnDecl), 0))
VIndex = tree_low_cst (DECL_VINDEX (FnDecl), 0);
Virtuality = dwarf::DW_VIRTUALITY_virtual;
@@ -344,7 +344,7 @@
if (MDNode *R = dyn_cast_or_null<MDNode>(&*I->second))
return DIDescriptor(R);
- if (TYPE_P (Node)) {
+ if (isa<TYPE>(Node)) {
DIType Ty = getOrCreateType(Node);
return DIDescriptor(Ty);
} else if (DECL_P (Node)) {
Modified: dragonegg/branches/release_31/src/DefaultABI.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_31/src/DefaultABI.cpp?rev=155228&r1=155227&r2=155228&view=diff
==============================================================================
--- dragonegg/branches/release_31/src/DefaultABI.cpp (original)
+++ dragonegg/branches/release_31/src/DefaultABI.cpp Fri Apr 20 15:21:50 2012
@@ -320,22 +320,12 @@
tree MaxElt = 0;
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
if (isa<FIELD_DECL>(Field)) {
- // Skip fields that are known not to be present.
- if (isa<QUAL_UNION_TYPE>(type) &&
- integer_zerop(DECL_QUALIFIER(Field)))
- continue;
-
tree SizeTree = TYPE_SIZE(TREE_TYPE(Field));
unsigned Size = ((unsigned)TREE_INT_CST_LOW(SizeTree)+7)/8;
if (Size > MaxSize) {
MaxSize = Size;
MaxElt = Field;
}
-
- // Skip remaining fields if this one is known to be present.
- if (isa<QUAL_UNION_TYPE>(type) &&
- integer_onep(DECL_QUALIFIER(Field)))
- break;
}
}
Modified: dragonegg/branches/release_31/src/Trees.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_31/src/Trees.cpp?rev=155228&r1=155227&r2=155228&view=diff
==============================================================================
--- dragonegg/branches/release_31/src/Trees.cpp (original)
+++ dragonegg/branches/release_31/src/Trees.cpp Fri Apr 20 15:21:50 2012
@@ -91,7 +91,7 @@
}
// Handle types of all kinds.
- if (TYPE_P(t)) {
+ if (isa<TYPE>(t)) {
// If the type comes with a name then use it.
const std::string &TypeName = getDescriptiveName(TYPE_NAME(t));
if (!TypeName.empty()) {
Modified: dragonegg/branches/release_31/src/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_31/src/Types.cpp?rev=155228&r1=155227&r2=155228&view=diff
==============================================================================
--- dragonegg/branches/release_31/src/Types.cpp (original)
+++ dragonegg/branches/release_31/src/Types.cpp Fri Apr 20 15:21:50 2012
@@ -102,6 +102,7 @@
switch (TREE_CODE(type_ref)) {
default:
+ debug_tree(type_ref);
llvm_unreachable("Unexpected tree kind!");
case ARRAY_TYPE:
case COMPLEX_TYPE:
@@ -116,7 +117,9 @@
case FIELD_DECL:
// Here type_ref is a field of the record or union type being iterated
// over. Move on to the next field.
- type_ref = TREE_CHAIN(type_ref);
+ do
+ type_ref = TREE_CHAIN(type_ref);
+ while (type_ref && !isa<FIELD_DECL>(type_ref));
break;
case FUNCTION_TYPE:
@@ -171,7 +174,10 @@
case UNION_TYPE:
// The contained types are the types of the record's fields. Use the
// first FIELD_DECL as the "pointer" to the first contained type.
- return ContainedTypeIterator(TYPE_FIELDS(type));
+ for (tree field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field))
+ if (isa<FIELD_DECL>(field))
+ return ContainedTypeIterator(field);
+ return end();
case FUNCTION_TYPE:
case METHOD_TYPE:
@@ -1092,14 +1098,11 @@
// Record all interesting fields so they can easily be visited backwards.
SmallVector<tree, 16> Fields;
for (tree field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
- assert(isa<FIELD_DECL>(field) && "Lang data not freed?");
+ if (!isa<FIELD_DECL>(field)) continue;
// Ignore fields with variable or unknown position since they cannot be
// represented by the LLVM type system.
if (!OffsetIsLLVMCompatible(field))
continue;
- // Skip fields that are known not to be present.
- if (isa<QUAL_UNION_TYPE>(type) && integer_zerop(DECL_QUALIFIER(field)))
- continue;
Fields.push_back(field);
}
Added: dragonegg/branches/release_31/test/compilator/local/c/2012-04-20-PointerBIT_AND_EXPR.c
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_31/test/compilator/local/c/2012-04-20-PointerBIT_AND_EXPR.c?rev=155228&view=auto
==============================================================================
--- dragonegg/branches/release_31/test/compilator/local/c/2012-04-20-PointerBIT_AND_EXPR.c (added)
+++ dragonegg/branches/release_31/test/compilator/local/c/2012-04-20-PointerBIT_AND_EXPR.c Fri Apr 20 15:21:50 2012
@@ -0,0 +1,8 @@
+testvacld (int n, ...)
+{
+ __builtin_va_list ap;
+ __builtin_va_start (ap, n);
+ _Complex long double t =
+ __builtin_va_arg (ap, _Complex long double);
+ __builtin_va_end (ap);
+}
More information about the llvm-commits
mailing list