[llvm-commits] [123995] Fix PR1170 and test/CFrontend/2007-02-16-VariableSizeStructArg.c
clattner at apple.com
clattner at apple.com
Fri Feb 16 21:42:57 PST 2007
Revision: 123995
Author: clattner
Date: 2007-02-16 21:42:55 -0800 (Fri, 16 Feb 2007)
Log Message:
-----------
Fix PR1170 and test/CFrontend/2007-02-16-VariableSizeStructArg.c
Modified Paths:
--------------
apple-local/branches/llvm/gcc/llvm-abi.h
apple-local/branches/llvm/gcc/llvm-types.cpp
Modified: apple-local/branches/llvm/gcc/llvm-abi.h
===================================================================
--- apple-local/branches/llvm/gcc/llvm-abi.h 2007-02-17 05:05:31 UTC (rev 123994)
+++ apple-local/branches/llvm/gcc/llvm-abi.h 2007-02-17 05:42:55 UTC (rev 123995)
@@ -96,6 +96,10 @@
default:
return 0;
case RECORD_TYPE:
+ // If this record has variable length, reject it.
+ if (TREE_CODE(TYPE_SIZE(type)) != INTEGER_CST)
+ return 0;
+
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field))
if (TREE_CODE(Field) == FIELD_DECL) {
if (!FoundField)
@@ -108,7 +112,8 @@
tree Domain = TYPE_DOMAIN(type);
if (!Domain || !TYPE_MIN_VALUE(Domain) || !TYPE_MAX_VALUE(Domain))
return 0;
- if (TREE_CODE(TYPE_MIN_VALUE(Domain)) != INTEGER_CST ||
+ if (TREE_CODE(TYPE_SIZE(type)) != INTEGER_CST ||
+ TREE_CODE(TYPE_MIN_VALUE(Domain)) != INTEGER_CST ||
TREE_CODE(TYPE_MAX_VALUE(Domain)) != INTEGER_CST)
return 0;
if (TREE_INT_CST_LOW(TYPE_MAX_VALUE(Domain)) !=
@@ -194,7 +199,7 @@
void HandleArgument(tree type) {
const Type *Ty = ConvertType(type);
- if (TREE_ADDRESSABLE(type)) { // Constructible object, pass by-ref
+ if (isPassedByInvisibleReference(type)) { // variable size -> by-ref.
C.HandleScalarArgument(PointerType::get(Ty), type);
} else if (Ty->isFirstClassType()) {
C.HandleScalarArgument(Ty, type);
Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-types.cpp 2007-02-17 05:05:31 UTC (rev 123994)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp 2007-02-17 05:42:55 UTC (rev 123995)
@@ -212,7 +212,7 @@
bool isPassedByInvisibleReference(tree Type) {
// FIXME: Search for TREE_ADDRESSABLE in calls.c, and see if there are other
// cases that make arguments automatically passed in by reference.
- return TREE_ADDRESSABLE(Type);
+ return TREE_ADDRESSABLE(Type) || TREE_CODE(TYPE_SIZE(Type)) != INTEGER_CST;
}
/// GetTypeName - Return a fully qualified (with namespace prefixes) name for
More information about the llvm-commits
mailing list