From: Hans Wennborg Date: Fri, 16 Nov 2012 10:33:25 +0000 (+0000) Subject: Constant::IsThreadDependent(): Use dyn_cast instead of cast X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=18aa124075859c5b1fd97cf39bd5bef1763acc4b;p=platform%2Fupstream%2Fllvm.git Constant::IsThreadDependent(): Use dyn_cast instead of cast It turns out that the operands of a Constant are not always themselves Constant. For example, one of the operands of BlockAddress is BasicBlock, which is not a Constant. This should fix the dragonegg-x86_64-linux-gcc-4.6-test build which broke in r168037. llvm-svn: 168147 --- diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index eae96ef..935f6b2 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -261,7 +261,9 @@ bool Constant::isThreadDependent() const { } for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I) { - const Constant *D = cast(C->getOperand(I)); + const Constant *D = dyn_cast(C->getOperand(I)); + if (!D) + continue; if (Visited.insert(D)) WorkList.push_back(D); } diff --git a/llvm/test/Transforms/GlobalOpt/blockaddress.ll b/llvm/test/Transforms/GlobalOpt/blockaddress.ll new file mode 100644 index 0000000..13da762 --- /dev/null +++ b/llvm/test/Transforms/GlobalOpt/blockaddress.ll @@ -0,0 +1,20 @@ +; RUN: opt < %s -globalopt -S | FileCheck %s + +@x = internal global i8* zeroinitializer + +define void @f() { +; CHECK: @f + +; Check that we don't hit an assert in Constant::IsThreadDependent() +; when storing this blockaddress into a global. + + store i8* blockaddress(@g, %here), i8** @x, align 8 + ret void +} + +define void @g() { +; CHECK: @g + +here: + ret void +}