Make sure that value handle users see the transformation of an indirect call to a...
authorNick Lewycky <nicholas@mxc.ca>
Thu, 20 Feb 2014 23:00:15 +0000 (23:00 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Thu, 20 Feb 2014 23:00:15 +0000 (23:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201822 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineCalls.cpp
test/Transforms/InstCombine/cast-call-combine.ll [new file with mode: 0644]

index 9e8d1bc3bd6a1682a0cde3c95606ae65d175d64e..fe8c1b0baf6e1626ce738f8babbaf9711155fa4e 100644 (file)
@@ -1212,6 +1212,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
 
   if (!Caller->use_empty())
     ReplaceInstUsesWith(*Caller, NV);
+  else if (Caller->hasValueHandle())
+    ValueHandleBase::ValueIsRAUWd(Caller, NV);
 
   EraseInstFromFunction(*Caller);
   return true;
diff --git a/test/Transforms/InstCombine/cast-call-combine.ll b/test/Transforms/InstCombine/cast-call-combine.ll
new file mode 100644 (file)
index 0000000..be70a87
--- /dev/null
@@ -0,0 +1,23 @@
+; RUN: opt < %s -always-inline -instcombine -S | FileCheck %s
+
+define internal void @foo(i16*) alwaysinline {
+  ret void
+}
+
+define void @bar() noinline noreturn {
+  unreachable
+}
+
+define void @test() {
+  br i1 false, label %then, label %else
+
+then:
+  call void @bar()
+  unreachable
+
+else:
+  ; CHECK-NOT: call
+  call void bitcast (void (i16*)* @foo to void (i8*)*) (i8* null)
+  ret void
+}
+