Skip to content

Commit e41e595

Browse files
committed
Merge from mainline.
Honour ByVal parameter attribute for name decoration. llvm-svn: 46214
1 parent c1dde53 commit e41e595

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

llvm/lib/Target/X86/X86AsmPrinter.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "llvm/Constants.h"
2626
#include "llvm/Module.h"
2727
#include "llvm/DerivedTypes.h"
28+
#include "llvm/ParameterAttributes.h"
2829
#include "llvm/Type.h"
2930
#include "llvm/Assembly/Writer.h"
3031
#include "llvm/Support/Mangler.h"
@@ -48,11 +49,19 @@ static X86MachineFunctionInfo calculateFunctionInfo(const Function *F,
4849
return Info;
4950
}
5051

52+
unsigned argNum = 1;
5153
for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end();
52-
AI != AE; ++AI)
54+
AI != AE; ++AI, ++argNum) {
55+
const Type* Ty = AI->getType();
56+
57+
// 'Dereference' type in case of byval parameter attribute
58+
if (F->paramHasAttr(argNum, ParamAttr::ByVal))
59+
Ty = cast<PointerType>(Ty)->getElementType();
60+
5361
// Size should be aligned to DWORD boundary
54-
Size += ((TD->getABITypeSize(AI->getType()) + 3)/4)*4;
55-
62+
Size += ((TD->getABITypeSize(Ty) + 3)/4)*4;
63+
}
64+
5665
// We're not supporting tooooo huge arguments :)
5766
Info.setBytesToPopOnReturn((unsigned int)Size);
5867
return Info;

0 commit comments

Comments
 (0)