[llvm] r294098 - [IPCP] Don't propagate return value for naked functions.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 4 11:44:15 PST 2017
Author: davide
Date: Sat Feb 4 13:44:14 2017
New Revision: 294098
URL: http://llvm.org/viewvc/llvm-project?rev=294098&view=rev
Log:
[IPCP] Don't propagate return value for naked functions.
This is pretty much the same change made in SCCP.
Modified:
llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp
llvm/trunk/test/Transforms/IPConstantProp/naked-return.ll
Modified: llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp?rev=294098&r1=294097&r2=294098&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/IPConstantPropagation.cpp Sat Feb 4 13:44:14 2017
@@ -136,7 +136,13 @@ static bool PropagateConstantReturn(Func
// 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());
Modified: llvm/trunk/test/Transforms/IPConstantProp/naked-return.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IPConstantProp/naked-return.ll?rev=294098&r1=294097&r2=294098&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IPConstantProp/naked-return.ll (original)
+++ llvm/trunk/test/Transforms/IPConstantProp/naked-return.ll Sat Feb 4 13:44:14 2017
@@ -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"
More information about the llvm-commits
mailing list