diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-03-21 10:58:47 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-03-21 10:58:47 +0000 |
commit | 3ffccb3802194e043cbf2b89c784de3e573b1bbf (patch) | |
tree | 3822c56c68fbb4896b680f02deacb536e3176eed /llvm/lib/Analysis/InstructionSimplify.cpp | |
parent | 1159250518c62bbbeaa7d7717acc2b0ed30d590d (diff) | |
download | bcm5719-llvm-3ffccb3802194e043cbf2b89c784de3e573b1bbf.tar.gz bcm5719-llvm-3ffccb3802194e043cbf2b89c784de3e573b1bbf.zip |
Teach instsimplify to gracefully degrade in the presence of instructions
not attched to a basic block or function. There are conservatively
correct answers in these cases, and this makes the analysis more useful
in contexts where we have a partially formed bit of IR.
I don't have any way to test this directly... suggestions welcome here,
but I'm not seeing anything sadly. I only found this using a subsequent
patch to the inliner which runs instsimplify on partially inlined
instructions, and even then only on a quite large program. I never got
a reasonable testcase out of it, and anything I do get is likely to be
quite fragile due to requiring an interaction of two different passes,
and the only result being a segfault if it goes wrong.
llvm-svn: 153176
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index f8d159dc438..72e33d18621 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -95,6 +95,12 @@ static bool ValueDominatesPHI(Value *V, PHINode *P, const DominatorTree *DT) { // Arguments and constants dominate all instructions. return true; + // If we are processing instructions (and/or basic blocks) that have not been + // fully added to a function, the parent nodes may still be null. Simply + // return the conservative answer in these cases. + if (!I->getParent() || !P->getParent() || !I->getParent()->getParent()) + return false; + // If we have a DominatorTree then do a precise test. if (DT) { if (!DT->isReachableFromEntry(P->getParent())) |