diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-08-25 23:58:48 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-08-25 23:58:48 +0000 |
commit | e6e88f99b35f2fde5008e36f0d93f5231564b7d8 (patch) | |
tree | 96c5d1a42c544a0e1613d2b03508b1ad747c7849 /llvm/lib/Transforms/IPO/ArgumentPromotion.cpp | |
parent | 7b967f147714c2d0fa573b9de48f131cb5559551 (diff) | |
download | llvm-e6e88f99b35f2fde5008e36f0d93f5231564b7d8.zip llvm-e6e88f99b35f2fde5008e36f0d93f5231564b7d8.tar.gz llvm-e6e88f99b35f2fde5008e36f0d93f5231564b7d8.tar.bz2 |
ArgPromotion: Don't touch variadic functions
Adding, removing, or changing non-pack parameters can change the ABI
classification of pack parameters. Clang and other frontends encode the
classification in the IR of the call site, but the callee side
determines it dynamically based on the number of registers consumed so
far. Changing the prototype affects the number of registers consumed
would break such code.
Dead argument elimination performs a similar task and already has a
similar check to avoid this problem.
Patch by Thomas Jablin!
llvm-svn: 216421
Diffstat (limited to 'llvm/lib/Transforms/IPO/ArgumentPromotion.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/ArgumentPromotion.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp index 7c40ecd..d2f407b 100644 --- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -156,6 +156,13 @@ CallGraphNode *ArgPromotion::PromoteArguments(CallGraphNode *CGN) { isSelfRecursive = true; } + // Don't promote arguments for variadic functions. Adding, removing, or + // changing non-pack parameters can change the classification of pack + // parameters. Frontends encode that classification at the call site in the + // IR, while in the callee the classification is determined dynamically based + // on the number of registers consumed so far. + if (F->isVarArg()) return nullptr; + // Check to see which arguments are promotable. If an argument is promotable, // add it to ArgsToPromote. SmallPtrSet<Argument*, 8> ArgsToPromote; |