diff options
author | Tim Northover <tnorthover@apple.com> | 2019-05-30 18:48:23 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2019-05-30 18:48:23 +0000 |
commit | b7141207a483d39b99c2b4da4eb3bb591eca9e1a (patch) | |
tree | 17be3c9e9f0ba7f9493e2279d5df0e029533d910 /llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | |
parent | 7fecdf36cc5b41dc5ad85d58c6e3b97b4fce6d00 (diff) | |
download | bcm5719-llvm-b7141207a483d39b99c2b4da4eb3bb591eca9e1a.tar.gz bcm5719-llvm-b7141207a483d39b99c2b4da4eb3bb591eca9e1a.zip |
Reapply: IR: add optional type to 'byval' function parameters
When we switch to opaque pointer types we will need some way to describe
how many bytes a 'byval' parameter should occupy on the stack. This adds
a (for now) optional extra type parameter.
If present, the type must match the pointee type of the argument.
The original commit did not remap byval types when linking modules, which broke
LTO. This version fixes that.
Note to front-end maintainers: if this causes test failures, it's probably
because the "byval" attribute is printed after attributes without any parameter
after this change.
llvm-svn: 362128
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/CallLowering.cpp')
-rw-r--r-- | llvm/lib/CodeGen/GlobalISel/CallLowering.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp index f144b18aa63..93727406a08 100644 --- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp @@ -87,7 +87,10 @@ void CallLowering::setArgFlags(CallLowering::ArgInfo &Arg, unsigned OpIdx, if (Arg.Flags.isByVal() || Arg.Flags.isInAlloca()) { Type *ElementTy = cast<PointerType>(Arg.Ty)->getElementType(); - Arg.Flags.setByValSize(DL.getTypeAllocSize(ElementTy)); + + auto Ty = Attrs.getAttribute(OpIdx, Attribute::ByVal).getValueAsType(); + Arg.Flags.setByValSize(DL.getTypeAllocSize(Ty ? Ty : ElementTy)); + // For ByVal, alignment should be passed from FE. BE will guess if // this info is not there but there are cases it cannot get right. unsigned FrameAlign; |