diff options
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp index bda7a46..9f3f2d6 100644 --- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp +++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp @@ -26,6 +26,7 @@ #include "llvm/IR/CFG.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/IRBuilder.h" +#include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/MDBuilder.h" #include "llvm/IR/PassManager.h" #include "llvm/InitializePasses.h" @@ -769,9 +770,21 @@ CHRScope * CHR::findScope(Region *R) { return nullptr; // If any of the basic blocks have address taken, we must skip this region // because we cannot clone basic blocks that have address taken. - for (BasicBlock *BB : R->blocks()) + for (BasicBlock *BB : R->blocks()) { if (BB->hasAddressTaken()) return nullptr; + // If we encounter llvm.coro.id, skip this region because if the basic block + // is cloned, we end up inserting a token type PHI node to the block with + // llvm.coro.begin. + // FIXME: This could lead to less optimal codegen, because the region is + // excluded, it can prevent CHR from merging adjacent regions into bigger + // scope and hoisting more branches. + for (Instruction &I : *BB) + if (auto *II = dyn_cast<IntrinsicInst>(&I)) + if (II->getIntrinsicID() == Intrinsic::coro_id) + return nullptr; + } + if (Exit) { // Try to find an if-then block (check if R is an if-then). // if (cond) { |