[llvm-commits] [llvm] r46645 - in /llvm/trunk: lib/Transforms/IPO/ArgumentPromotion.cpp test/Transforms/ArgumentPromotion/2008-02-01-ReturnAttrs.ll
Duncan Sands
baldrick at free.fr
Fri Feb 1 12:37:17 PST 2008
Author: baldrick
Date: Fri Feb 1 14:37:16 2008
New Revision: 46645
URL: http://llvm.org/viewvc/llvm-project?rev=46645&view=rev
Log:
Don't drop function/call return attributes like 'nounwind'.
Added:
llvm/trunk/test/Transforms/ArgumentPromotion/2008-02-01-ReturnAttrs.ll
Modified:
llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=46645&r1=46644&r2=46645&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Fri Feb 1 14:37:16 2008
@@ -404,6 +404,10 @@
ParamAttrsVector ParamAttrsVec;
const ParamAttrsList *PAL = F->getParamAttrs();
+ // Add any return attributes.
+ if (unsigned attrs = PAL ? PAL->getParamAttrs(0) : 0)
+ ParamAttrsVec.push_back(ParamAttrsWithIndex::get(0, attrs));
+
unsigned ArgIndex = 1;
for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
++I, ++ArgIndex) {
@@ -491,6 +495,10 @@
Instruction *Call = CS.getInstruction();
PAL = CS.getParamAttrs();
+ // Add any return attributes.
+ if (unsigned attrs = PAL ? PAL->getParamAttrs(0) : 0)
+ ParamAttrsVec.push_back(ParamAttrsWithIndex::get(0, attrs));
+
// Loop over the operands, inserting GEP and loads in the caller as
// appropriate.
CallSite::arg_iterator AI = CS.arg_begin();
Added: llvm/trunk/test/Transforms/ArgumentPromotion/2008-02-01-ReturnAttrs.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ArgumentPromotion/2008-02-01-ReturnAttrs.ll?rev=46645&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/ArgumentPromotion/2008-02-01-ReturnAttrs.ll (added)
+++ llvm/trunk/test/Transforms/ArgumentPromotion/2008-02-01-ReturnAttrs.ll Fri Feb 1 14:37:16 2008
@@ -0,0 +1,15 @@
+; RUN: llvm-as < %s | opt -argpromotion | llvm-dis | grep nounwind | count 2
+
+define internal i32 @deref(i32* %x) nounwind {
+entry:
+ %tmp2 = load i32* %x, align 4 ; <i32> [#uses=1]
+ ret i32 %tmp2
+}
+
+define i32 @f(i32 %x) {
+entry:
+ %x_addr = alloca i32 ; <i32*> [#uses=2]
+ store i32 %x, i32* %x_addr, align 4
+ %tmp1 = call i32 @deref( i32* %x_addr ) nounwind ; <i32> [#uses=1]
+ ret i32 %tmp1
+}
More information about the llvm-commits
mailing list