#include "llvm/Analysis/PostDominators.h"
#include "llvm/Analysis/RegionInfo.h"
#include "llvm/Analysis/ValueTracking.h"
+#include "llvm/IR/IntrinsicInst.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
// Split the exit block to hold load instructions.
bool splitExitBlock(Region *R);
+ bool isIgnoredIntrinsic(Instruction *Inst);
bool onlyUsedInRegion(Instruction *Inst, const Region *R);
bool translateScalarToArray(BasicBlock *BB, const Region *R);
bool translateScalarToArray(Instruction *Inst, const Region *R);
};
}
+bool IndependentBlocks::isIgnoredIntrinsic(Instruction *Inst) {
+ if (auto *IT = dyn_cast<IntrinsicInst>(Inst)) {
+ switch (IT->getIntrinsicID()) {
+ // Lifetime markers are supported/ignored.
+ case llvm::Intrinsic::lifetime_start:
+ case llvm::Intrinsic::lifetime_end:
+ // Invariant markers are supported/ignored.
+ case llvm::Intrinsic::invariant_start:
+ case llvm::Intrinsic::invariant_end:
+ // Some misc annotations are supported/ignored.
+ case llvm::Intrinsic::var_annotation:
+ case llvm::Intrinsic::ptr_annotation:
+ case llvm::Intrinsic::annotation:
+ case llvm::Intrinsic::donothing:
+ case llvm::Intrinsic::assume:
+ case llvm::Intrinsic::expect:
+ return true;
+ default:
+ break;
+ }
+ }
+ return false;
+}
+
bool IndependentBlocks::isSafeToMove(Instruction *Inst) {
if (Inst->mayReadFromMemory() || Inst->mayWriteToMemory())
return false;
// Find all trivially dead instructions.
for (BasicBlock *BB : R->blocks())
for (Instruction &Inst : *BB)
- if (isInstructionTriviallyDead(&Inst))
+ if (!isIgnoredIntrinsic(&Inst) && isInstructionTriviallyDead(&Inst))
WorkList.push_back(&Inst);
if (WorkList.empty())
const Region *R) {
if (canSynthesize(Inst, LI, SE, R) && onlyUsedInRegion(Inst, R))
return false;
+ if (isIgnoredIntrinsic(Inst))
+ return false;
SmallVector<Instruction *, 4> LoadInside, LoadOutside;
for (User *U : Inst->users())