[llvm-branch-commits] [cfe-branch] r196371 - Merging r196370:

Richard Sandiford rsandifo at linux.vnet.ibm.com
Wed Dec 4 02:02:36 PST 2013


Author: rsandifo
Date: Wed Dec  4 04:02:36 2013
New Revision: 196371

URL: http://llvm.org/viewvc/llvm-project?rev=196371&view=rev
Log:
Merging r196370:
------------------------------------------------------------------------
r196370 | rsandifo | 2013-12-04 09:59:57 +0000 (Wed, 04 Dec 2013) | 14 lines

[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.

------------------------------------------------------------------------

Modified:
    cfe/branches/release_34/   (props changed)
    cfe/branches/release_34/lib/CodeGen/TargetInfo.cpp
    cfe/branches/release_34/test/CodeGen/systemz-inline-asm.c

Propchange: cfe/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec  4 04:02:36 2013
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195249,195268,195283,195303,195326,195329,195367,195384,195409,195420,195422,195501,195547,195556,195558,195587,195620,195635,195669,195687,195693,195710,195713,195716,195756,195760,195768,195777,195789,195792,195804,195827,195843-195844,195877,195887-195888,195897,195903,195905-195906,195932,195936-195943,195970,195983,196045,196048,196050,196058,196114-196115,196153,196206,196215
+/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195249,195268,195283,195303,195326,195329,195367,195384,195409,195420,195422,195501,195547,195556,195558,195587,195620,195635,195669,195687,195693,195710,195713,195716,195756,195760,195768,195777,195789,195792,195804,195827,195843-195844,195877,195887-195888,195897,195903,195905-195906,195932,195936-195943,195970,195983,196045,196048,196050,196058,196114-196115,196153,196206,196215,196370
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_34/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/CodeGen/TargetInfo.cpp?rev=196371&r1=196370&r2=196371&view=diff
==============================================================================
--- cfe/branches/release_34/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/branches/release_34/lib/CodeGen/TargetInfo.cpp Wed Dec  4 04:02:36 2013
@@ -4573,7 +4573,7 @@ ABIArgInfo SystemZABIInfo::classifyArgum
   // 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::classifyArgum
     // 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::classifyArgum
 
   // Non-structure compounds are passed indirectly.
   if (isCompoundType(Ty))
-    return ABIArgInfo::getIndirect(0);
+    return ABIArgInfo::getIndirect(0, /*ByVal=*/false);
 
   return ABIArgInfo::getDirect(0);
 }

Modified: cfe/branches/release_34/test/CodeGen/systemz-inline-asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/test/CodeGen/systemz-inline-asm.c?rev=196371&r1=196370&r2=196371&view=diff
==============================================================================
--- cfe/branches/release_34/test/CodeGen/systemz-inline-asm.c (original)
+++ cfe/branches/release_34/test/CodeGen/systemz-inline-asm.c Wed Dec  4 04:02:36 2013
@@ -123,7 +123,7 @@ double test_f64(double f, double g) {
 long double test_f128(long double f, long double g) {
   asm("axbr %0, %2" : "=f" (f) : "0" (f), "f" (g));
   return f;
-// CHECK: define void @test_f128(fp128* noalias nocapture sret [[DEST:%.*]], fp128* byval nocapture readonly, fp128* byval nocapture readonly)
+// CHECK: define void @test_f128(fp128* noalias nocapture sret [[DEST:%.*]], fp128* nocapture readonly, fp128* nocapture readonly)
 // CHECK: %f = load fp128* %0
 // CHECK: %g = load fp128* %1
 // CHECK: [[RESULT:%.*]] = tail call fp128 asm "axbr $0, $2", "=f,0,f"(fp128 %f, fp128 %g)





More information about the llvm-branch-commits mailing list