summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2019-01-17 02:15:05 +0000
committerVedant Kumar <vsk@apple.com>2019-01-17 02:15:05 +0000
commita9906c1e5e990e37cf46d7522e22e1dd25ce35bc (patch)
tree09e6adc4860da9ae5fca3c553e5d7593e3b33bd6 /llvm/lib
parent3cfcc94c099140cade96d0d799f017f95eb20bd9 (diff)
downloadbcm5719-llvm-a9906c1e5e990e37cf46d7522e22e1dd25ce35bc.tar.gz
bcm5719-llvm-a9906c1e5e990e37cf46d7522e22e1dd25ce35bc.zip
[MergeFunc] Prevent silent miscompile of vararg functions
The function merging pass miscompiles identical vararg functions. The forwarding thunk it emits doesn't forward the full variable-length list of arguments. Disable merging for vararg functions for now. I've filed llvm.org/PR40345 to track the issue. rdar://47326238 llvm-svn: 351411
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/MergeFunctions.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
index 11efe95b10d..26b204f61cb 100644
--- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
@@ -383,6 +383,12 @@ bool MergeFunctions::doSanityCheck(std::vector<WeakTrackingVH> &Worklist) {
}
#endif
+/// Check whether \p F is eligible for function merging.
+static bool isEligibleForMerging(Function &F) {
+ return !F.isDeclaration() && !F.hasAvailableExternallyLinkage() &&
+ !F.isVarArg();
+}
+
bool MergeFunctions::runOnModule(Module &M) {
if (skipModule(M))
return false;
@@ -394,7 +400,7 @@ bool MergeFunctions::runOnModule(Module &M) {
std::vector<std::pair<FunctionComparator::FunctionHash, Function *>>
HashedFuncs;
for (Function &Func : M) {
- if (!Func.isDeclaration() && !Func.hasAvailableExternallyLinkage()) {
+ if (isEligibleForMerging(Func)) {
HashedFuncs.push_back({FunctionComparator::functionHash(Func), &Func});
}
}
OpenPOWER on IntegriCloud