[PowerPC] Fix calls to non-function objects
authorHal Finkel <hfinkel@anl.gov>
Mon, 12 Jan 2015 04:34:47 +0000 (04:34 +0000)
committerHal Finkel <hfinkel@anl.gov>
Mon, 12 Jan 2015 04:34:47 +0000 (04:34 +0000)
commitb6bb7db62bdf0d2eae01075f9e9863903f4fd281
tree02baf97afb978e36825f1947f0598511fe6bac32
parentdc5a2dabfe3dddce050556f215a7162dbb144f05
[PowerPC] Fix calls to non-function objects

Looking at r225438 inspired me to see how the PowerPC backend handled the
situation (calling a bitcasted TLS global), and it turns out we also produced
an error (cannot select ...). What it means to "call" something that is not a
function is implementation and platform specific, but in the name of doing
something (besides crashing), this makes sure we do what GCC does (treat all
such calls as calls through a function pointer -- meaning that the pointer is
assumed, as is the convention on PPC, to point to a function descriptor
structure holding the actual code address along with the function's TOC pointer
and environment pointer). As GCC does, we now do the same for calling regular
(non-TLS) non-function globals too.

I'm not sure whether this is the most useful way to define the behavior, but at
least we won't be alone.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225617 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/PPCISelLowering.cpp
test/CodeGen/PowerPC/ppc64-nonfunc-calls.ll [new file with mode: 0644]