]> granicus.if.org Git - clang/commitdiff
Add inreg attributes to reference arguments.
authorRafael Espindola <rafael.espindola@gmail.com>
Sun, 27 Nov 2011 18:35:39 +0000 (18:35 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sun, 27 Nov 2011 18:35:39 +0000 (18:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145189 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCall.cpp
test/CodeGenCXX/regparm.cpp [new file with mode: 0644]

index 7ff16dd95129265c8d4e484470874af47c931c76..4f2210f10e4f9c40e76afd08402d57b0f218b546 100644 (file)
@@ -831,7 +831,8 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
       // FALL THROUGH
     case ABIArgInfo::Direct:
       if (RegParm > 0 &&
-          (ParamType->isIntegerType() || ParamType->isPointerType())) {
+          (ParamType->isIntegerType() || ParamType->isPointerType() ||
+           ParamType->isReferenceType())) {
         RegParm -=
         (Context.getTypeSize(ParamType) + PointerWidth - 1) / PointerWidth;
         if (RegParm >= 0)
diff --git a/test/CodeGenCXX/regparm.cpp b/test/CodeGenCXX/regparm.cpp
new file mode 100644 (file)
index 0000000..f0ebd2b
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+
+
+// CHECK: _Z3fooRi(i32* inreg
+void __attribute__ ((regparm (1)))  foo(int &a) {
+}