[PATCH RFC 1/1] utils: Fix segfault in flattencfg

Jan Vesely jan.vesely at rutgers.edu
Mon Aug 4 15:24:03 PDT 2014


---

Not sure if it's the right fix. Looks more like ductaping over some bigger problem.
Fixes segfault I hit with mad_sat libclc patch

 lib/Transforms/Utils/FlattenCFG.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/Transforms/Utils/FlattenCFG.cpp b/lib/Transforms/Utils/FlattenCFG.cpp
index 51ead40..ce49a40 100644
--- a/lib/Transforms/Utils/FlattenCFG.cpp
+++ b/lib/Transforms/Utils/FlattenCFG.cpp
@@ -241,6 +241,8 @@ bool FlattenCFGOpt::FlattenParallelAndOr(BasicBlock *BB, IRBuilder<> &Builder,
     while (1) {
       BranchInst *BI = dyn_cast<BranchInst>(CurrBlock->getTerminator());
       CmpInst *CI = dyn_cast<CmpInst>(BI->getCondition());
+      if (!CI)
+        break;
       CmpInst::Predicate Predicate = CI->getPredicate();
       // Canonicalize icmp_ne -> icmp_eq, fcmp_one -> fcmp_oeq
       if ((Predicate == CmpInst::ICMP_NE) || (Predicate == CmpInst::FCMP_ONE)) {
-- 
1.9.3




More information about the llvm-commits mailing list