[llvm-commits] [llvm] r168147 - in /llvm/trunk: lib/VMCore/Constants.cpp test/Transforms/GlobalOpt/blockaddress.ll
Nick Lewycky
nicholas at mxc.ca
Fri Nov 16 03:04:04 PST 2012
Hans Wennborg wrote:
> Author: hans
> Date: Fri Nov 16 04:33:25 2012
> New Revision: 168147
>
> URL: http://llvm.org/viewvc/llvm-project?rev=168147&view=rev
> Log:
> Constant::IsThreadDependent(): Use dyn_cast<Constant> 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.
Oh, right. My apologies. :(
> This should fix the dragonegg-x86_64-linux-gcc-4.6-test build which
> broke in r168037.
>
> Added:
> llvm/trunk/test/Transforms/GlobalOpt/blockaddress.ll
> Modified:
> llvm/trunk/lib/VMCore/Constants.cpp
>
> Modified: llvm/trunk/lib/VMCore/Constants.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=168147&r1=168146&r2=168147&view=diff
> ==============================================================================
> --- llvm/trunk/lib/VMCore/Constants.cpp (original)
> +++ llvm/trunk/lib/VMCore/Constants.cpp Fri Nov 16 04:33:25 2012
> @@ -261,7 +261,9 @@
> }
>
> for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I) {
> - const Constant *D = cast<Constant>(C->getOperand(I));
> + const Constant *D = dyn_cast<Constant>(C->getOperand(I));
> + if (!D)
> + continue;
> if (Visited.insert(D))
> WorkList.push_back(D);
> }
>
> Added: llvm/trunk/test/Transforms/GlobalOpt/blockaddress.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/blockaddress.ll?rev=168147&view=auto
> ==============================================================================
> --- llvm/trunk/test/Transforms/GlobalOpt/blockaddress.ll (added)
> +++ llvm/trunk/test/Transforms/GlobalOpt/blockaddress.ll Fri Nov 16 04:33:25 2012
> @@ -0,0 +1,20 @@
> +; RUN: opt< %s -globalopt -S | FileCheck %s
> +
> + at 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
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list