forked from OSchip/llvm-project
[FIX] Independent blocks with intrinsics handling
Also an old option was removed from some new test cases llvm-svn: 227057
This commit is contained in:
parent
40cb819c6f
commit
07e8a406d6
|
@ -21,6 +21,7 @@
|
|||
#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"
|
||||
|
@ -129,6 +130,7 @@ struct IndependentBlocks : public FunctionPass {
|
|||
|
||||
// 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);
|
||||
|
@ -141,6 +143,30 @@ struct IndependentBlocks : public FunctionPass {
|
|||
};
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -276,7 +302,7 @@ bool IndependentBlocks::eliminateDeadCode(const Region *R) {
|
|||
// 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())
|
||||
|
@ -368,6 +394,8 @@ bool IndependentBlocks::translateScalarToArray(Instruction *Inst,
|
|||
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())
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; RUN: opt %loadPolly -basicaa -polly-codegen-isl -polly-codegen-scev -S < %s | FileCheck %s
|
||||
; RUN: opt %loadPolly -basicaa -polly-codegen-isl -S < %s | FileCheck %s
|
||||
;
|
||||
; Verify that we remove the lifetime markers from the optimized SCoP.
|
||||
;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; RUN: opt %loadPolly -basicaa -polly-codegen-isl -polly-codegen-scev -S < %s | FileCheck %s
|
||||
; RUN: opt %loadPolly -basicaa -polly-codegen-isl -S < %s | FileCheck %s
|
||||
;
|
||||
; Verify that we remove the misc intrinsics from the optimized SCoP.
|
||||
;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; RUN: opt %loadPolly -basicaa -polly-detect -polly-codegen-scev -analyze < %s | FileCheck %s
|
||||
; RUN: opt %loadPolly -basicaa -polly-detect -analyze < %s | FileCheck %s
|
||||
;
|
||||
; Verify that we allow the lifetime markers for the tmp array.
|
||||
;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; RUN: opt %loadPolly -basicaa -polly-detect -polly-codegen-scev -analyze < %s | FileCheck %s
|
||||
; RUN: opt %loadPolly -basicaa -polly-detect -analyze < %s | FileCheck %s
|
||||
;
|
||||
; Verify that we allow the misc intrinsics.
|
||||
;
|
||||
|
|
Loading…
Reference in New Issue