diff options
author | Wei Wang <apollo.mobility@gmail.com> | 2022-04-25 14:00:41 -0700 |
---|---|---|
committer | Wei Wang <apollo.mobility@gmail.com> | 2022-04-27 10:27:25 -0700 |
commit | 26a0d53b15447e011dc1a8de1f035e4aecd1083c (patch) | |
tree | ed3183aeb2b771aebdfe0c7e292ca371db61c3b9 /llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp | |
parent | ccd047cba4f15cd95e8e3895f823757c5988b192 (diff) | |
download | llvm-26a0d53b15447e011dc1a8de1f035e4aecd1083c.zip llvm-26a0d53b15447e011dc1a8de1f035e4aecd1083c.tar.gz llvm-26a0d53b15447e011dc1a8de1f035e4aecd1083c.tar.bz2 |
[CHR] Skip region containing llvm.coro.id
When a block containing llvm.coro.id is cloned during CHR, it inserts an invalid
PHI node with token type to the beginning of the block containing llvm.coro.begin.
To avoid such case, we exclude regions with llvm.coro.id.
Reviewed By: ChuanqiXu
Differential Revision: https://reviews.llvm.org/D124418
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) { |