From: Alex Bradbury Date: Wed, 11 Oct 2017 13:48:45 +0000 (+0000) Subject: [TargetLowering] Correctly track NumFixedArgs field of CallLoweringInfo X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a951eff6275ed7f66448d265de5abcc1ca669e29;p=llvm [TargetLowering] Correctly track NumFixedArgs field of CallLoweringInfo The NumFixedArgs field of CallLoweringInfo is used by TargetLowering::LowerCallTo to determine whether a given argument is passed using the vararg calling convention or not (specifically, to set IsFixed for each ISD::OutputArg). Firstly, CallLoweringInfo::setLibCallee and CallLoweringInfo::setCallee both incorrectly set NumFixedArgs based on the _previous_ args list. Secondly, TargetLowering::LowerCallTo failed to increment NumFixedArgs when modifying the argument list so a pointer is passed for the return value. If your backend uses the IsFixed property or directly accesses NumFixedArgs, it is _possible_ this change could result in codegen changes (although the previous behaviour would have been incorrect). No such cases have been identified during code review for any in-tree architecture. Differential Revision: https://reviews.llvm.org/D37898 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315457 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index ea3e3f7b049..d35acdfc92e 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -2907,7 +2907,7 @@ public: RetTy = ResultType; Callee = Target; CallConv = CC; - NumFixedArgs = Args.size(); + NumFixedArgs = ArgsList.size(); Args = std::move(ArgsList); DAG.getTargetLoweringInfo().markLibCallAttributes( @@ -2920,7 +2920,7 @@ public: RetTy = ResultType; Callee = Target; CallConv = CC; - NumFixedArgs = Args.size(); + NumFixedArgs = ArgsList.size(); Args = std::move(ArgsList); return *this; } diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index df49b0474f3..75641e05648 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -8077,6 +8077,7 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const { Entry.IsSwiftError = false; Entry.Alignment = Align; CLI.getArgs().insert(CLI.getArgs().begin(), Entry); + CLI.NumFixedArgs += 1; CLI.RetTy = Type::getVoidTy(CLI.RetTy->getContext()); // sret demotion isn't compatible with tail-calls, since the sret argument