summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2015-09-01 18:06:46 +0000
committerHans Wennborg <hans@hanshq.net>2015-09-01 18:06:46 +0000
commitdada1d20ba7ad2795793946d9f570eeb05e21f58 (patch)
treef7215eb99e1cc24e26292f6cbb647d8c0c0cfcd8 /llvm/lib/Transforms
parent761844be66264da401587e7d763183ed8187674f (diff)
downloadbcm5719-llvm-dada1d20ba7ad2795793946d9f570eeb05e21f58.tar.gz
bcm5719-llvm-dada1d20ba7ad2795793946d9f570eeb05e21f58.zip
DeadArgElim: don't eliminate arguments from naked functions
Differential Revision: http://reviews.llvm.org/D12534 llvm-svn: 246564
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index d0447640259..64c5ab9cb1b 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -198,6 +198,13 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
if (Fn.hasAddressTaken())
return false;
+ // Don't touch naked functions. The assembly might be using an argument, or
+ // otherwise rely on the frame layout in a way that this analysis will not
+ // see.
+ if (Fn.hasFnAttribute(Attribute::Naked)) {
+ return false;
+ }
+
// Okay, we know we can transform this function if safe. Scan its body
// looking for calls marked musttail or calls to llvm.vastart.
for (Function::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) {
@@ -345,6 +352,12 @@ bool DAE::RemoveDeadArgumentsFromCallers(Function &Fn)
if (Fn.hasLocalLinkage() && !Fn.getFunctionType()->isVarArg())
return false;
+ // Don't touch naked functions. The assembly might be using an argument, or
+ // otherwise rely on the frame layout in a way that this analysis will not
+ // see.
+ if (Fn.hasFnAttribute(Attribute::Naked))
+ return false;
+
if (Fn.use_empty())
return false;
@@ -543,6 +556,14 @@ void DAE::SurveyFunction(const Function &F) {
return;
}
+ // Don't touch naked functions. The assembly might be using an argument, or
+ // otherwise rely on the frame layout in a way that this analysis will not
+ // see.
+ if (F.hasFnAttribute(Attribute::Naked)) {
+ MarkLive(F);
+ return;
+ }
+
unsigned RetCount = NumRetVals(&F);
// Assume all return values are dead
typedef SmallVector<Liveness, 5> RetVals;
OpenPOWER on IntegriCloud