[PATCH] D63045: Do not derive no-recurse attribute if function does not have exact definition.

Vivek Pandya via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 8 04:15:42 PDT 2019


vivekvpandya created this revision.
vivekvpandya added a reviewer: jdoerfert.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

This is fix for https://bugs.llvm.org/show_bug.cgi?id=41336


https://reviews.llvm.org/D63045

Files:
  llvm/lib/Transforms/IPO/FunctionAttrs.cpp
  llvm/test/Transforms/FunctionAttrs/arg_returned.ll


Index: llvm/test/Transforms/FunctionAttrs/arg_returned.ll
===================================================================
--- llvm/test/Transforms/FunctionAttrs/arg_returned.ll
+++ llvm/test/Transforms/FunctionAttrs/arg_returned.ll
@@ -308,17 +308,11 @@
 ;
 ; Verify the maybe-redefined function is not annotated:
 ;
-; CHECK: Function Attrs: noinline norecurse nounwind uwtable
+; CHECK: Function Attrs: noinline nounwind uwtable
 ; CHECK: define linkonce_odr i32* @maybe_redefined_fn(i32* %r)
-; FIXME: We should not derive norecurse for potentially redefined functions!
-;        Function Attrs: noinline nounwind uwtable
-;        define linkonce_odr i32* @maybe_redefined_fn(i32* %r)
 ;
-; CHECK: Function Attrs: noinline norecurse nounwind uwtable
+; CHECK: Function Attrs: noinline nounwind uwtable
 ; CHECK: define i32* @calls_maybe_redefined_fn(i32* returned %r)
-; FIXME: We should not derive norecurse for potentially redefined functions!
-;        Function Attrs: noinline nounwind uwtable
-;        define i32* @calls_maybe_redefined_fn(i32* returned %r)
 define linkonce_odr i32* @maybe_redefined_fn(i32* %r) #0 {
 entry:
   ret i32* %r
@@ -586,5 +580,4 @@
 ; CHECK-DAG: attributes #{{[0-9]*}} = { noinline nounwind readnone uwtable }
 ; CHECK-DAG: attributes #{{[0-9]*}} = { noinline nounwind readonly uwtable }
 ; CHECK-DAG: attributes #{{[0-9]*}} = { noinline nounwind uwtable }
-; CHECK-DAG: attributes #{{[0-9]*}} = { noinline norecurse nounwind uwtable }
 ; CHECK-NOT: attributes #
Index: llvm/lib/Transforms/IPO/FunctionAttrs.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -1300,7 +1300,7 @@
     return false;
 
   Function *F = *SCCNodes.begin();
-  if (!F || F->isDeclaration() || F->doesNotRecurse())
+  if (!F || !F->hasExactDefinition() || F->doesNotRecurse())
     return false;
 
   // If all of the calls in F are identifiable and are to norecurse functions, F


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63045.203681.patch
Type: text/x-patch
Size: 2015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190608/ff2e2ad1/attachment.bin>


More information about the llvm-commits mailing list