If the function being inlined has a higher stack protection level than the
authorBill Wendling <isanbard@gmail.com>
Fri, 21 Nov 2008 00:06:32 +0000 (00:06 +0000)
committerBill Wendling <isanbard@gmail.com>
Fri, 21 Nov 2008 00:06:32 +0000 (00:06 +0000)
inlining function, then increase the stack protection level on the inlining
function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59757 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/Inliner.cpp

index 418b2b70cb66a96afc059b52a3371efc0ab4a3fe..bf0925c2e2f23c6f4874c6d8cf1a691de8ac7e0c 100644 (file)
@@ -56,6 +56,15 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG,
   Function *Callee = CS.getCalledFunction();
   if (!InlineFunction(CS, &CG, &TD)) return false;
 
+  // If the inlined function had a higher stack protection level than the
+  // calling function, then bump up the caller's stack protection level.
+  Function *Caller = CS.getCaller();
+  if (Callee->hasFnAttr(Attribute::StackProtectReq))
+    Caller->addFnAttr(Attribute::StackProtectReq);
+  else if (Callee->hasFnAttr(Attribute::StackProtect) &&
+           !Caller->hasFnAttr(Attribute::StackProtectReq))
+    Caller->addFnAttr(Attribute::StackProtect);
+
   // If we inlined the last possible call site to the function, delete the
   // function body now.
   if (Callee->use_empty() && Callee->hasInternalLinkage() &&