diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 7ff16dd95129..4f2210f10e4f 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -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/clang/test/CodeGenCXX/regparm.cpp b/clang/test/CodeGenCXX/regparm.cpp new file mode 100644 index 000000000000..f0ebd2be4167 --- /dev/null +++ b/clang/test/CodeGenCXX/regparm.cpp @@ -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) { +}