diff options
| author | Richard Sandiford <rsandifo@linux.vnet.ibm.com> | 2013-12-04 09:59:57 +0000 | 
|---|---|---|
| committer | Richard Sandiford <rsandifo@linux.vnet.ibm.com> | 2013-12-04 09:59:57 +0000 | 
| commit | cdd86884a4fe5e879b6d1ac1034e5056a423f0ab (patch) | |
| tree | 1ac4d42b5d12f6777e9ed896742fe5bf7594a42d /clang/lib | |
| parent | 50ad48024123b88fc06c73ba2ef1f11c9bf0b90d (diff) | |
| download | bcm5719-llvm-cdd86884a4fe5e879b6d1ac1034e5056a423f0ab.tar.gz bcm5719-llvm-cdd86884a4fe5e879b6d1ac1034e5056a423f0ab.zip | |
[SystemZ] Fix handling of pass-by-pointer arguments
I'd misunderstood getIndirect() to mean that the argument should be passed
as a pointer at the ABI level, with the ByVal argument choosing caller-copy
semantics over no-caller-copy (callee-copy-on-write) semantics.  But
getIndirect(x) actually means that x is passed by pointer at the IR
level but (at least on all other targets I looked at) directly at the
ABI level.  getIndirect(x, false) selects a pointer to a caller-made
copy, which is what SystemZ was aiming for.
This fixes a miscompilation of c-index-test.  Structure arguments were being
passed by pointer, but no copy was being made, so a write in the callee
stomped over a caller's local variable.
llvm-svn: 196370
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 6 | 
1 files changed, 3 insertions, 3 deletions
| diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 3d0c9f16016..76acf871da2 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -4573,7 +4573,7 @@ ABIArgInfo SystemZABIInfo::classifyArgumentType(QualType Ty) const {    // Values that are not 1, 2, 4 or 8 bytes in size are passed indirectly.    uint64_t Size = getContext().getTypeSize(Ty);    if (Size != 8 && Size != 16 && Size != 32 && Size != 64) -    return ABIArgInfo::getIndirect(0); +    return ABIArgInfo::getIndirect(0, /*ByVal=*/false);    // Handle small structures.    if (const RecordType *RT = Ty->getAs<RecordType>()) { @@ -4581,7 +4581,7 @@ ABIArgInfo SystemZABIInfo::classifyArgumentType(QualType Ty) const {      // fail the size test above.      const RecordDecl *RD = RT->getDecl();      if (RD->hasFlexibleArrayMember()) -      return ABIArgInfo::getIndirect(0); +      return ABIArgInfo::getIndirect(0, /*ByVal=*/false);      // The structure is passed as an unextended integer, a float, or a double.      llvm::Type *PassTy; @@ -4598,7 +4598,7 @@ ABIArgInfo SystemZABIInfo::classifyArgumentType(QualType Ty) const {    // Non-structure compounds are passed indirectly.    if (isCompoundType(Ty)) -    return ABIArgInfo::getIndirect(0); +    return ABIArgInfo::getIndirect(0, /*ByVal=*/false);    return ABIArgInfo::getDirect(0);  } | 

