[llvm-commits] [llvm-gcc-4.2] r97989 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
Dale Johannesen
dalej at apple.com
Tue Mar 9 10:19:45 PST 2010
On Mar 8, 2010, at 11:06 PMPST, Duncan Sands wrote:
> Hi Dan,
>
>> // If this function returns via a shadow argument, the dest loc is passed
>> - // in as a pointer. Mark that pointer as struct-ret and noalias.
>> + // in as a pointer. Mark that pointer as struct-ret.
>> + //
>> + // It's tempting to want NoAlias here too, however even though llvm-gcc
>> + // itself currently always passes a dedicated alloca as the actual argument,
>> + // this isn't mandated by the ABI. There are other compilers which don't
>> + // always pass a dedicated alloca. Using NoAlias here would make code which
>> + // isn't interoperable with that of other compilers.
>> if (ABIConverter.isShadowReturn())
>> Attrs.push_back(AttributeWithIndex::get(ArgTys.size(),
>> - Attribute::StructRet | Attribute::NoAlias));
>> + Attribute::StructRet));
>
> what does the ABI say exactly? Is it really valid to pass something which may
> get "accidentally" altered when the callee (for example) writes to a global or
> to some other argument?
The ABI does NOT say that the shadow return value must be a dedicated stack-allocated object, and therefore it doesn't have to be if we see the same result under the as-if rule. I also have seen other compilers do this (not just clang). I believe it's safe in some circumstances, but you have to be careful.
More information about the llvm-commits
mailing list