[llvm] r362918 - Do not derive no-recurse attribute if function does not have exact definition.

Vivek Pandya via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 9 21:16:04 PDT 2019


Author: vivekvpandya
Date: Sun Jun  9 21:16:04 2019
New Revision: 362918

URL: http://llvm.org/viewvc/llvm-project?rev=362918&view=rev
Log:
Do not derive no-recurse attribute if function does not have exact definition.
This is fix for https://bugs.llvm.org/show_bug.cgi?id=41336

Reviewers: jdoerfert
Reviewed by: jdoerfert

Differential Revision: https://reviews.llvm.org/D63045

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

Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=362918&r1=362917&r2=362918&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Sun Jun  9 21:16:04 2019
@@ -1300,7 +1300,7 @@ static bool addNoRecurseAttrs(const SCCN
     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

Modified: llvm/trunk/test/Transforms/FunctionAttrs/arg_returned.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/arg_returned.ll?rev=362918&r1=362917&r2=362918&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionAttrs/arg_returned.ll (original)
+++ llvm/trunk/test/Transforms/FunctionAttrs/arg_returned.ll Sun Jun  9 21:16:04 2019
@@ -308,17 +308,11 @@ define i32* @calls_unknown_fn(i32* %r) #
 ;
 ; 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 @@ attributes #0 = { noinline nounwind uwta
 ; 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 #




More information about the llvm-commits mailing list