<div dir="ltr"><div>Please see PR28610:<br><a href="https://llvm.org/bugs/show_bug.cgi?id=28610">https://llvm.org/bugs/show_bug.cgi?id=28610</a><br></div>for a possible small test case.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jul 17, 2016 at 9:23 PM, NAKAMURA Takumi via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: chapuni<br>
Date: Sun Jul 17 22:23:25 2016<br>
New Revision: 275756<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=275756&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=275756&view=rev</a><br>
Log:<br>
Revert r275678, "Revert "Revert r275027 - Let FuncAttrs infer the 'returned' argument attribute""<br>
<br>
This reverts also r275029, "Update Clang tests after adding inference for the returned argument attribute"<br>
<br>
It broke LTO build. Seems miscompilation.<br>
<br>
Modified:<br>
llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp<br>
llvm/trunk/test/Transforms/FunctionAttrs/2009-01-02-LocalStores.ll<br>
llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll<br>
llvm/trunk/test/Transforms/FunctionAttrs/readattrs.ll<br>
<br>
Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=275756&r1=275755&r2=275756&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=275756&r1=275755&r2=275756&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Sun Jul 17 22:23:25 2016<br>
@@ -42,7 +42,6 @@ using namespace llvm;<br>
STATISTIC(NumReadNone, "Number of functions marked readnone");<br>
STATISTIC(NumReadOnly, "Number of functions marked readonly");<br>
STATISTIC(NumNoCapture, "Number of arguments marked nocapture");<br>
-STATISTIC(NumReturned, "Number of arguments marked returned");<br>
STATISTIC(NumReadNoneArg, "Number of arguments marked readnone");<br>
STATISTIC(NumReadOnlyArg, "Number of arguments marked readonly");<br>
STATISTIC(NumNoAlias, "Number of function returns marked noalias");<br>
@@ -484,53 +483,6 @@ determinePointerReadAttrs(Argument *A,<br>
return IsRead ? Attribute::ReadOnly : Attribute::ReadNone;<br>
}<br>
<br>
-/// Deduce returned attributes for the SCC.<br>
-static bool addArgumentReturnedAttrs(const SCCNodeSet &SCCNodes) {<br>
- bool Changed = false;<br>
-<br>
- AttrBuilder B;<br>
- B.addAttribute(Attribute::Returned);<br>
-<br>
- // Check each function in turn, determining if an argument is always returned.<br>
- for (Function *F : SCCNodes) {<br>
- // We can infer and propagate function attributes only when we know that the<br>
- // definition we'll get at link time is *exactly* the definition we see now.<br>
- // For more details, see GlobalValue::mayBeDerefined.<br>
- if (!F->hasExactDefinition())<br>
- continue;<br>
-<br>
- if (F->getReturnType()->isVoidTy())<br>
- continue;<br>
-<br>
- auto FindRetArg = [&]() -> Value * {<br>
- Value *RetArg = nullptr;<br>
- for (BasicBlock &BB : *F)<br>
- if (auto *Ret = dyn_cast<ReturnInst>(BB.getTerminator())) {<br>
- // Note that stripPointerCasts should look through functions with<br>
- // returned arguments.<br>
- Value *RetVal = Ret->getReturnValue()->stripPointerCasts();<br>
- if (RetVal->getType() == F->getReturnType() && isa<Argument>(RetVal)) {<br>
- if (!RetArg)<br>
- RetArg = RetVal;<br>
- else if (RetArg != RetVal)<br>
- return nullptr;<br>
- }<br>
- }<br>
-<br>
- return RetArg;<br>
- };<br>
-<br>
- if (Value *RetArg = FindRetArg()) {<br>
- auto *A = cast<Argument>(RetArg);<br>
- A->addAttr(AttributeSet::get(F->getContext(), A->getArgNo() + 1, B));<br>
- ++NumReturned;<br>
- Changed = true;<br>
- }<br>
- }<br>
-<br>
- return Changed;<br>
-}<br>
-<br>
/// Deduce nocapture attributes for the SCC.<br>
static bool addArgumentAttrs(const SCCNodeSet &SCCNodes) {<br>
bool Changed = false;<br>
@@ -1072,7 +1024,6 @@ PreservedAnalyses PostOrderFunctionAttrs<br>
}<br>
<br>
bool Changed = false;<br>
- Changed |= addArgumentReturnedAttrs(SCCNodes);<br>
Changed |= addReadAttrs(SCCNodes, AARGetter);<br>
Changed |= addArgumentAttrs(SCCNodes);<br>
<br>
@@ -1138,7 +1089,6 @@ static bool runImpl(CallGraphSCC &SCC, A<br>
SCCNodes.insert(F);<br>
}<br>
<br>
- Changed |= addArgumentReturnedAttrs(SCCNodes);<br>
Changed |= addReadAttrs(SCCNodes, AARGetter);<br>
Changed |= addArgumentAttrs(SCCNodes);<br>
<br>
<br>
Modified: llvm/trunk/test/Transforms/FunctionAttrs/2009-01-02-LocalStores.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/2009-01-02-LocalStores.ll?rev=275756&r1=275755&r2=275756&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/2009-01-02-LocalStores.ll?rev=275756&r1=275755&r2=275756&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/FunctionAttrs/2009-01-02-LocalStores.ll (original)<br>
+++ llvm/trunk/test/Transforms/FunctionAttrs/2009-01-02-LocalStores.ll Sun Jul 17 22:23:25 2016<br>
@@ -14,7 +14,7 @@ define i32* @b(i32 *%q) {<br>
ret i32* %tmp<br>
}<br>
<br>
-; CHECK: define i32* @c(i32* readnone returned %r)<br>
+; CHECK: define i32* @c(i32* readnone %r)<br>
@g = global i32 0<br>
define i32* @c(i32 *%r) {<br>
%a = icmp eq i32* %r, null<br>
<br>
Modified: llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll?rev=275756&r1=275755&r2=275756&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll?rev=275756&r1=275755&r2=275756&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll (original)<br>
+++ llvm/trunk/test/Transforms/FunctionAttrs/nocapture.ll Sun Jul 17 22:23:25 2016<br>
@@ -1,7 +1,7 @@<br>
; RUN: opt < %s -functionattrs -S | FileCheck %s<br>
@g = global i32* null ; <i32**> [#uses=1]<br>
<br>
-; CHECK: define i32* @c1(i32* readnone returned %q)<br>
+; CHECK: define i32* @c1(i32* readnone %q)<br>
define i32* @c1(i32* %q) {<br>
ret i32* %q<br>
}<br>
@@ -140,7 +140,7 @@ define void @test1_1(i8* %x1_1, i8* %y1_<br>
ret void<br>
}<br>
<br>
-; CHECK: define i8* @test1_2(i8* nocapture readnone %x1_2, i8* returned %y1_2)<br>
+; CHECK: define i8* @test1_2(i8* nocapture readnone %x1_2, i8* %y1_2)<br>
define i8* @test1_2(i8* %x1_2, i8* %y1_2) {<br>
call void @test1_1(i8* %x1_2, i8* %y1_2)<br>
store i32* null, i32** @g<br>
@@ -168,7 +168,7 @@ define void @test4_1(i8* %x4_1) {<br>
ret void<br>
}<br>
<br>
-; CHECK: define i8* @test4_2(i8* nocapture readnone %x4_2, i8* readnone returned %y4_2, i8* nocapture readnone %z4_2)<br>
+; CHECK: define i8* @test4_2(i8* nocapture readnone %x4_2, i8* readnone %y4_2, i8* nocapture readnone %z4_2)<br>
define i8* @test4_2(i8* %x4_2, i8* %y4_2, i8* %z4_2) {<br>
call void @test4_1(i8* null)<br>
store i32* null, i32** @g<br>
<br>
Modified: llvm/trunk/test/Transforms/FunctionAttrs/readattrs.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/readattrs.ll?rev=275756&r1=275755&r2=275756&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/readattrs.ll?rev=275756&r1=275755&r2=275756&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/FunctionAttrs/readattrs.ll (original)<br>
+++ llvm/trunk/test/Transforms/FunctionAttrs/readattrs.ll Sun Jul 17 22:23:25 2016<br>
@@ -11,7 +11,7 @@ define void @test1_2(i8* %x1_2, i8* %y1_<br>
ret void<br>
}<br>
<br>
-; CHECK: define i8* @test2(i8* readnone returned %p)<br>
+; CHECK: define i8* @test2(i8* readnone %p)<br>
define i8* @test2(i8* %p) {<br>
store i32 0, i32* @x<br>
ret i8* %p<br>
@@ -53,7 +53,7 @@ define void @test7_1(i32* inalloca %a) {<br>
ret void<br>
}<br>
<br>
-; CHECK: define i32* @test8_1(i32* readnone returned %p)<br>
+; CHECK: define i32* @test8_1(i32* readnone %p)<br>
define i32* @test8_1(i32* %p) {<br>
entry:<br>
ret i32* %p<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>