From 0aabe661a4315def30ddb2b4dbf290b513ffb747 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Thu, 20 Feb 2014 23:00:15 +0000 Subject: [PATCH] =?UTF-8?q?Make=20sure=20that=20value=20handle=20users=20s?= =?UTF-8?q?ee=20the=20transformation=20of=20an=20indirect=20call=20to=20a?= =?UTF-8?q?=20direct=20call.=20This=20is=20important=20for=20the=20CallGra?= =?UTF-8?q?ph=20iteration.=20Patch=20by=20Bj=C3=B6rn=20Steinbrink!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201822 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../InstCombine/InstCombineCalls.cpp | 2 ++ .../InstCombine/cast-call-combine.ll | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 test/Transforms/InstCombine/cast-call-combine.ll diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp index 9e8d1bc3bd6..fe8c1b0baf6 100644 --- a/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -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 index 00000000000..be70a8763ea --- /dev/null +++ b/test/Transforms/InstCombine/cast-call-combine.ll @@ -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 +} +