Only promote args when function attributes are compatible
authorTom Stellard <tstellar@redhat.com>
Wed, 16 Jan 2019 05:15:31 +0000 (05:15 +0000)
committerTom Stellard <tstellar@redhat.com>
Wed, 16 Jan 2019 05:15:31 +0000 (05:15 +0000)
commit3d36e5c3e6cf8ed0ce68fd9e123654ddcfbaf7a3
tree1bbe5cb162902e1881dd291f94874d67f76966b4
parenta5b0e5585b1d5734b7cad533d7b4ba53b1c4a030
Only promote args when function attributes are compatible

Summary:
Check to make sure that the caller and the callee have compatible
function arguments before promoting arguments.  This uses the same
TargetTransformInfo queries that are used to determine if attributes
are compatible for inlining.

The goal here is to avoid breaking ABI when a called function's ABI
depends on a target feature that is not enabled in the caller.

This is a very conservative fix for PR37358.  Ideally we would have a more
sophisticated check for ABI compatiblity rather than checking if the
attributes are compatible for inlining.

Reviewers: echristo, chandlerc, eli.friedman, craig.topper

Reviewed By: echristo, chandlerc

Subscribers: nikic, xbolva00, rkruppe, alexcrichton, llvm-commits

Differential Revision: https://reviews.llvm.org/D53554

llvm-svn: 351296
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/lib/Analysis/TargetTransformInfo.cpp
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/test/Transforms/ArgumentPromotion/X86/attributes.ll [new file with mode: 0644]