]> granicus.if.org Git - clang/commitdiff
Take into account the pointer to an aggregate that is passed as a hidden
authorAkira Hatanaka <ahatanaka@mips.com>
Thu, 12 Jan 2012 01:10:09 +0000 (01:10 +0000)
committerAkira Hatanaka <ahatanaka@mips.com>
Thu, 12 Jan 2012 01:10:09 +0000 (01:10 +0000)
argument when Offset is initialized.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147986 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TargetInfo.cpp
test/CodeGen/mips64-padding-arg.c

index 317cb44ce0da85920c05aaba481bb9281bea67d5..e9f88b7aaf1655d3f91db3559c501b2704f47b09 100644 (file)
@@ -3248,8 +3248,12 @@ ABIArgInfo MipsABIInfo::classifyReturnType(QualType RetTy) const {
 }
 
 void MipsABIInfo::computeInfo(CGFunctionInfo &FI) const {
-  FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
-  uint64_t Offset = 0;
+  ABIArgInfo &RetInfo = FI.getReturnInfo();
+  RetInfo = classifyReturnType(FI.getReturnType());
+
+  // Check if a pointer to an aggregate is passed as a hidden argument.  
+  uint64_t Offset = RetInfo.isIndirect() ? 8 : 0;
+
   for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
        it != ie; ++it)
     it->info = classifyArgumentType(it->type, Offset);
index 3958807974f1ce618e0753b7637433886078c75d..faafd5e63cbe244e46bda19bc8e1ef2274dce5d6 100644 (file)
@@ -29,3 +29,15 @@ void foo3(int a0, long double a1) {
   foo4(1, 2, a0, a1);
 }
 
+// Insert padding after hidden argument.
+//
+// CHECK: define void @foo5(%struct.S0* noalias nocapture sret %agg.result, i64, fp128 %a0)
+// CHECK: call void @foo6(%struct.S0* sret %tmp, i32 1, i32 2, i64 undef, fp128 %a0)
+// CHECK: declare void @foo6(%struct.S0* sret, i32, i32, i64, fp128)
+
+extern S0 foo6(int, int, long double);
+
+S0 foo5(long double a0) {
+  foo6(1, 2, a0);
+}
+