[NVPTX] Fix a segfault for bitcasted calls with byval params
authorLuke Drummond <luke.drummond@codeplay.com>
Fri, 23 Sep 2022 15:50:51 +0000 (16:50 +0100)
committerLuke Drummond <luke.drummond@codeplay.com>
Tue, 11 Oct 2022 14:12:25 +0000 (15:12 +0100)
commit940fa35ece5294a115a2fdba89ef6c095d90df0f
treee14dac98c88ac8019aeac1acf03a90d670f14b91
parentc7ddbd62d811524726e6f8e293ab1576c5b289f3
[NVPTX] Fix a segfault for bitcasted calls with byval params

`getFunctionParamOptimizedAlign` was being passed a null function
argument when getting the callee of a bitcasted function symbol. This is
because `CallBase::getCalledFunction` does not look through bitcasts.

There is already code to handle this case in
`NVPTXTargetLowering::getArgumentAlignment`, which is now hoisted into
an NVPTX util.

The alignment computation now gracefully handles computing alignment of
virtual functions with a check for null.
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
llvm/lib/Target/NVPTX/NVPTXUtilities.cpp
llvm/lib/Target/NVPTX/NVPTXUtilities.h
llvm/test/CodeGen/NVPTX/call_bitcast_byval.ll [new file with mode: 0644]