When an argument has 'byval' attribute and should be passed on the stack according calling convention,
a stack copy would be emitted twice. This will cause the real value will be put into stack where the pointer should be passed.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
4042 | Why do we need a new variable? Can we just pass isByVal to the function? |
llvm/lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
4042 | Yes, we can. I thought it will reduce readability, so I add a new variable. |
llvm/lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
3774 | Let me check below 2 rule is right or not.
On linux, the VA.getLocInfo() is CCValAssign::Full, and on windows is the VA.getLocInfo() is CCValAssign::Indirect. So I think we can just check the VA.getLocInfo(). If VA.getLocInfo() is CCValAssign::Indirect, we can NOT copy object. Instead we just restore the pointer. |
llvm/lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
3774 | The hasCopy should just be isByVal with no inversion and the Flags.isByVal() should be removed and replaced with isByVal. isByVal replaced the version in Flags. Or what Yuanke said might work. |
Let me check below 2 rule is right or not.
On linux, the VA.getLocInfo() is CCValAssign::Full, and on windows is the VA.getLocInfo() is CCValAssign::Indirect.
So I think we can just check the VA.getLocInfo(). If VA.getLocInfo() is CCValAssign::Indirect, we can NOT copy object. Instead we just restore the pointer.
(Flags.isByVal() && VA.getLocInfo() != CCValAssign::Indirect)