[CodeGen] Fixing inconsistent ABI mangling of vlaues in SelectionDAGBuilder
authorLucas Prates <lucas.prates@arm.com>
Thu, 17 Sep 2020 17:07:35 +0000 (18:07 +0100)
committerLucas Prates <lucas.prates@arm.com>
Mon, 21 Sep 2020 09:05:34 +0000 (10:05 +0100)
commit53d238a961d14eae46f6f2b296ce48026c7bd0a1
tree48fc5e709a4a87e554f091683c60f5d3386e0c8b
parent702f06ad14ac61d364b773e5a1f4d8b0b0214553
[CodeGen] Fixing inconsistent ABI mangling of vlaues in SelectionDAGBuilder

SelectionDAGBuilder was inconsistently mangling values based on ABI
Calling Conventions when getting them through copyFromRegs in
SelectionDAGBuilder, causing duplicate value type convertions for
function arguments. The checking for the mangling requirement was based
on the value's originating instruction and was performed outside of, and
inspite of, the regular Calling Convention Lowering.

The issue could be observed in a scenario such as:

```
%arg1 = load half, half* %const, align 2
%arg2 = call fastcc half @someFunc()
call fastcc void @otherFunc(half %arg1, half %arg2)
; Here, %arg2 was incorrectly mangled twice, as the CallConv data from
; the call to @someFunc() was taken into consideration for the check
; when getting the value for processing the call to @otherFunc(...),
; after the proper convertion had taken place when lowering the return
; value of the first call.
```

This patch fixes the issue by disregarding the Calling Convention
information for such copyFromRegs, making sure the ABI mangling is
properly contanined in the Calling Convention Lowering.

This fixes Bugzilla #47454.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D87844
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/CodeGen/ARM/pr47454.ll [new file with mode: 0644]