[IPCP] Don't propagate return value for naked functions.

This is pretty much the same change made in SCCP.

llvm-svn: 294098
This commit is contained in:
Davide Italiano 2017-02-04 19:44:14 +00:00
parent d29bcbbb3b
commit ec49313b11
2 changed files with 8 additions and 1 deletions

View File

@ -136,7 +136,13 @@ static bool PropagateConstantReturn(Function &F) {
// For more details, see GlobalValue::mayBeDerefined.
if (!F.isDefinitionExact())
return false;
// Don't touch naked functions. The may contain asm returning
// value we don't see, so we may end up interprocedurally propagating
// the return value incorrectly.
if (F.hasFnAttribute(Attribute::Naked))
return false;
// Check to see if this function returns a constant.
SmallVector<Value *,4> RetVals;
StructType *STy = dyn_cast<StructType>(F.getReturnType());

View File

@ -1,4 +1,5 @@
; RUN: opt -ipsccp -S %s | FileCheck %s
; RUN: opt -ipconstprop -S %s | FileCheck %s
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc19.0.24215"