On Oct 24, 2007, at 5:04 PM, Chris Lattner wrote: > On Oct 24, 2007, at 9:40 AM, Dale Johannesen wrote: > >> Author: johannes >> URL: http://llvm.org/viewvc/llvm-project?rev=43294&view=rev >> Log: >> Mark the sret bit correctly for functions defined >> with empty parameter list (treated as "K&R" style >> internally, although it's equally valid and >> semantically identical in ANSI for definitions.) >> gcc.c-torture/execute/20020920-1.c > > Nifty! Does this fix http://llvm.org/bugs/show_bug.cgi?id=1397 ?
Yes. At least the originally reported problem, the bug seems to have metastasized a bit. > Can you please add a testcase to llvm/test/CFrontend that checks for > this? OK. Although I think the pointer to the gcc testsuite should be sufficient, really. > Thanks Dale, > > -Chris > >> >> Modified: >> llvm-gcc-4.0/trunk/gcc/llvm-types.cpp >> >> 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=43294&r1=43293&r2=43294&view=diff >> >> ===================================================================== >> = >> ======== >> --- llvm-gcc-4.0/trunk/gcc/llvm-types.cpp (original) >> +++ llvm-gcc-4.0/trunk/gcc/llvm-types.cpp Wed Oct 24 11:40:18 2007 >> @@ -947,6 +947,12 @@ >> >> ABIConverter.HandleReturnType(ReturnType); >> >> + // If this is a struct-return function, the dest loc is passed >> in as a >> + // pointer. Mark that pointer as structret. >> + ParamAttrsVector Attrs; >> + if (ABIConverter.isStructReturn()) >> + Attrs.push_back(ParamAttrsWithIndex::get(ArgTys.size(), >> + ParamAttr::StructRet)); >> if (static_chain) >> // Pass the static chain as the first parameter. >> ABIConverter.HandleArgument(TREE_TYPE(static_chain)); >> @@ -954,7 +960,11 @@ >> for (; Args && TREE_TYPE(Args) != void_type_node; Args = >> TREE_CHAIN(Args)) >> ABIConverter.HandleArgument(TREE_TYPE(Args)); >> >> - return GetFunctionType(RetTy, ArgTys, false, 0); >> + ParamAttrsList *PAL = 0; >> + if (!Attrs.empty()) >> + PAL = ParamAttrsList::get(Attrs); >> + >> + return GetFunctionType(RetTy, ArgTys, false, PAL); >> } >> >> const FunctionType *TypeConverter::ConvertFunctionType(tree type, >> >> >> _______________________________________________ >> llvm-commits mailing list >> [email protected] >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits _______________________________________________ llvm-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
