<div dir="ltr">Committed in r201822. Thanks for the patch!</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 10 February 2014 11:08, Björn Steinbrink <span dir="ltr"><<a href="mailto:bsteinbr@gmail.com" target="_blank">bsteinbr@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">In transformConstExprCastCall, if the replaced call has no users, we<br>
currently don't call ReplaceInstUsesWith, which means that ValueHandlers<br>
aren't notified about the replacement, but only about the removal of the<br>
old call.<br>
<br>
This means that we can't immediately detect the devirtualization of such<br>
calls when updating the call graph in the CGSCC pass, because the old<br>
CallSite got invalidated. If some other change then fools the simple<br>
counting logic, we fail to re-run the pass on the current function,<br>
missing further optimization possibilities opened up by the<br>
devirtualized call.<br>
<br>
</div>As a fix, we should manually perform the notifications if there are<br>
ValueHandlers present.<br>
---<br>
 lib/Transforms/InstCombine/InstCombineCalls.cpp  |  2 ++<br>
 test/Transforms/InstCombine/cast-call-combine.ll | 22 ++++++++++++++++++++++<br>
 2 files changed, 24 insertions(+)<br>
<div class=""> create mode 100644 test/Transforms/InstCombine/cast-call-combine.ll<br>
<br>
diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp<br>
</div>index 8e308ec..cba88ff 100644<br>
--- a/lib/Transforms/InstCombine/InstCombineCalls.cpp<br>
+++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp<br>
@@ -1227,6 +1227,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {<br>
<br>
   if (!Caller->use_empty())<br>
     ReplaceInstUsesWith(*Caller, NV);<br>
+  else if (Caller->hasValueHandle())<br>
+    ValueHandleBase::ValueIsRAUWd(Caller, NV);<br>
<br>
   EraseInstFromFunction(*Caller);<br>
   return true;<br>
<div class="HOEnZb"><div class="h5">diff --git a/test/Transforms/InstCombine/cast-call-combine.ll b/test/Transforms/InstCombine/cast-call-combine.ll<br>
new file mode 100644<br>
index 0000000..4eb2478<br>
--- /dev/null<br>
+++ b/test/Transforms/InstCombine/cast-call-combine.ll<br>
@@ -0,0 +1,22 @@<br>
+; RUN: opt < %s -always-inline -instcombine -S | FileCheck %s<br>
+<br>
+define internal void @foo(i16*) alwaysinline {<br>
+  ret void<br>
+}<br>
+<br>
+define void @bar() noinline noreturn {<br>
+  unreachable<br>
+}<br>
+<br>
+define void @test() {<br>
+  br i1 false, label %then, label %else<br>
+<br>
+then:<br>
+  call void @bar()<br>
+  unreachable<br>
+<br>
+else:<br>
+  ; CHECK-NOT: call<br>
+  call void bitcast (void (i16*)* @foo to void (i8*)*) (i8* null)<br>
+  ret void<br>
+}<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
1.9.0.rc3<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>