[llvm-commits] [llvm-gcc-4.0] r40622 - in /llvm-gcc-4.0/trunk/gcc: llvm-backend.cpp llvm-convert.cpp llvm-internal.h llvm-types.cpp
Christopher Lamb
christopher.lamb at gmail.com
Mon Jul 30 23:50:25 PDT 2007
Author: clamb
Date: Tue Jul 31 01:50:25 2007
New Revision: 40622
URL: http://llvm.org/viewvc/llvm-project?rev=40622&view=rev
Log:
Add support for scraping the function decl for restrict qualifiers to handle restrict function parameters for both C/C++. Thanks to Sheng Zhou for pointing the way...
Modified:
llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp
llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
llvm-gcc-4.0/trunk/gcc/llvm-internal.h
llvm-gcc-4.0/trunk/gcc/llvm-types.cpp
Modified: llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp?rev=40622&r1=40621&r2=40622&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp Tue Jul 31 01:50:25 2007
@@ -988,7 +988,7 @@
if (FnEntry == 0) {
unsigned CC;
const FunctionType *Ty =
- TheTypeConverter->ConvertFunctionType(TREE_TYPE(decl), NULL, CC);
+ TheTypeConverter->ConvertFunctionType(TREE_TYPE(decl), decl, NULL, CC);
FnEntry = new Function(Ty, Function::ExternalLinkage, Name, TheModule);
FnEntry->setCallingConv(CC);
Modified: llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp?rev=40622&r1=40621&r2=40622&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp Tue Jul 31 01:50:25 2007
@@ -514,8 +514,9 @@
} else {
// Otherwise, just get the type from the function itself.
FTy = TheTypeConverter->ConvertFunctionType(TREE_TYPE(FnDecl),
- static_chain,
- CallingConv);
+ FnDecl,
+ static_chain,
+ CallingConv);
}
// If we've already seen this function and created a prototype, and if the
@@ -2546,6 +2547,7 @@
unsigned CallingConv;
const Type *Ty = TheTypeConverter->ConvertFunctionType(function_type,
+ fndecl,
static_chain,
CallingConv);
Callee = CastToType(Instruction::BitCast, Callee, PointerType::get(Ty));
Modified: llvm-gcc-4.0/trunk/gcc/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-internal.h?rev=40622&r1=40621&r2=40622&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-internal.h (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-internal.h Tue Jul 31 01:50:25 2007
@@ -139,6 +139,7 @@
/// tree to an LLVM type. This does the same thing that ConvertType does, but
/// it also returns the function's LLVM calling convention.
const FunctionType *ConvertFunctionType(tree_node *type,
+ tree_node *decl,
tree_node *static_chain,
unsigned &CallingConv);
Modified: llvm-gcc-4.0/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-types.cpp?rev=40622&r1=40621&r2=40622&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-types.cpp Tue Jul 31 01:50:25 2007
@@ -785,7 +785,7 @@
return Ty;
unsigned CallingConv;
- return TypeDB.setType(type, ConvertFunctionType(type, NULL, CallingConv));
+ return TypeDB.setType(type, ConvertFunctionType(type, orig_type, NULL, CallingConv));
}
case ARRAY_TYPE: {
if (const Type *Ty = GET_TYPE_LLVM(type))
@@ -927,6 +927,7 @@
}
const FunctionType *TypeConverter::ConvertFunctionType(tree type,
+ tree decl,
tree static_chain,
unsigned &CallingConv) {
const Type *RetTy = 0;
@@ -979,6 +980,7 @@
// Loop over all of the arguments, adding them as we go.
tree Args = TYPE_ARG_TYPES(type);
+ tree DeclArgs = DECL_ARGUMENTS(decl);
for (; Args && TREE_VALUE(Args) != void_type_node; Args = TREE_CHAIN(Args)){
tree ArgTy = TREE_VALUE(Args);
if (!isPassedByInvisibleReference(ArgTy) &&
@@ -1012,8 +1014,11 @@
}
// Compute noalias attributes.
- if (TREE_CODE(ArgTy) == POINTER_TYPE || TREE_CODE(ArgTy) == REFERENCE_TYPE)
- if (TYPE_RESTRICT(ArgTy))
+ tree RestrictArgTy = (DeclArgs) ? DeclArgs->type.common.type : ArgTy;
+ RestrictArgTy = (RestrictArgTy) ? RestrictArgTy : ArgTy;
+ if (TREE_CODE(RestrictArgTy) == POINTER_TYPE ||
+ TREE_CODE(RestrictArgTy) == REFERENCE_TYPE)
+ if (TYPE_RESTRICT(RestrictArgTy))
Attributes |= ParamAttr::NoAlias;
#ifdef LLVM_TARGET_ENABLE_REGPARM
@@ -1026,6 +1031,9 @@
if (Attributes != ParamAttr::None)
Attrs.push_back(ParamAttrsWithIndex::get(ArgTypes.size(), Attributes));
+
+ if (DeclArgs)
+ DeclArgs = TREE_CHAIN(DeclArgs);
}
// If the argument list ends with a void type node, it isn't vararg.
More information about the llvm-commits
mailing list