gollvm: update struct ret attribute construction

Additional fixes to call attribute creation code to use
AttrBuilder::addStructRetAttr instead of setting StructRet directly,
similar to the changes made in CL 274833 (this is needed since the
underlying LLVM code has become more strict about how these attrs are
set).

Updates golang/go#47570.

Change-Id: I02d0182c6a559a3ab09ff56e06db9698d2d78bff
Reviewed-on: https://go-review.googlesource.com/c/gollvm/+/340124
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
diff --git a/bridge/go-llvm-materialize.cpp b/bridge/go-llvm-materialize.cpp
index c72f526..d58391e 100644
--- a/bridge/go-llvm-materialize.cpp
+++ b/bridge/go-llvm-materialize.cpp
@@ -1328,7 +1328,7 @@
   const CABIParamInfo &returnInfo = state.oracle.returnInfo();
   if (returnInfo.disp() == ParmIndirect) {
     llvm::AttrBuilder ab;
-    ab.addAttribute(llvm::Attribute::StructRet);
+    ab.addStructRetAttr(state.calleeFcnType->resultType()->type());
     ab.addAttribute(llvm::Attribute::get(call->getContext(), "go_sret"));
     argAttrs[0] = llvm::AttributeSet::get(context_, ab);
   }
diff --git a/unittests/BackendCore/BackendCABIOracleTests.cpp b/unittests/BackendCore/BackendCABIOracleTests.cpp
index 454c216..87ae3ae 100644
--- a/unittests/BackendCore/BackendCABIOracleTests.cpp
+++ b/unittests/BackendCore/BackendCABIOracleTests.cpp
@@ -718,7 +718,7 @@
   DECLARE_EXPECTED_OUTPUT(exp, R"RAW_RESULT(
     %cast.0 = bitcast [2 x float]* %p0.addr to <2 x float>*
     %ld.0 = load <2 x float>, <2 x float>* %cast.0, align 8
-    call addrspace(0) void @foo([3 x double]* sret "go_sret" %sret.actual.0, i8* nest undef, <2 x float> %ld.0)
+    call addrspace(0) void @foo([3 x double]* sret([3 x double]) "go_sret" %sret.actual.0, i8* nest undef, <2 x float> %ld.0)
     %cast.1 = bitcast [3 x double]* %sret.formal.0 to i8*
     %cast.2 = bitcast [3 x double]* %sret.actual.0 to i8*
     call addrspace(0) void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %cast.1, i8* align 8 %cast.2, i64 24, i1 false)