diff options
| author | Reid Kleckner <rnk@google.com> | 2017-07-28 00:58:35 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2017-07-28 00:58:35 +0000 |
| commit | 07a5d4372e5025211976645b766319204814ca39 (patch) | |
| tree | eea84846170e33fa52de55cd3133cb7bbfe60e6a /llvm/lib/Target | |
| parent | bdfd1228f67c9aa047348751ebec3d1513d1a338 (diff) | |
| download | bcm5719-llvm-07a5d4372e5025211976645b766319204814ca39.tar.gz bcm5719-llvm-07a5d4372e5025211976645b766319204814ca39.zip | |
[X86] Fix latent bug in sibcall eligibility logic
The X86 tail call eligibility logic was correct when it was written, but
the addition of inalloca and argument copy elision broke its
assumptions. It was assuming that fixed stack objects were immutable.
Currently, we aim to emit a tail call if no arguments have to be
re-arranged in memory. This code would trace the outgoing argument
values back to check if they are loads from an incoming stack object.
If the stack argument is immutable, then we won't need to store it back
to the stack when we tail call.
Fortunately, stack objects track their mutability, so we can just make
the obvious check to fix the bug.
This was http://crbug.com/749826
llvm-svn: 309343
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index bcf7874a406..a0fd72dd6a9 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -3983,6 +3983,13 @@ bool MatchingStackOffset(SDValue Arg, unsigned Offset, ISD::ArgFlagsTy Flags, if (Offset != MFI.getObjectOffset(FI)) return false; + // If this is not byval, check that the argument stack object is immutable. + // inalloca and argument copy elision can create mutable argument stack + // objects. Byval objects can be mutated, but a byval call intends to pass the + // mutated memory. + if (!Flags.isByVal() && !MFI.isImmutableObjectIndex(FI)) + return false; + if (VA.getLocVT().getSizeInBits() > Arg.getValueSizeInBits()) { // If the argument location is wider than the argument type, check that any // extension flags match. |

