forked from OSchip/llvm-project
[LowerConstantIntrinsics] Make TLI a required dependency
The way the pass is actually used in the optimization pipeline, TLI will be available, but this is not the case when running just -lower-constant-intrinsics in tests, which ends up being quite confusing. Require TLI unconditionally, as we usually do.
This commit is contained in:
parent
32306b9cf7
commit
ab2284a643
|
@ -94,7 +94,7 @@ static bool replaceConditionalBranchesOnConstant(Instruction *II,
|
|||
return HasDeadBlocks;
|
||||
}
|
||||
|
||||
static bool lowerConstantIntrinsics(Function &F, const TargetLibraryInfo *TLI,
|
||||
static bool lowerConstantIntrinsics(Function &F, const TargetLibraryInfo &TLI,
|
||||
DominatorTree *DT) {
|
||||
Optional<DomTreeUpdater> DTU;
|
||||
if (DT)
|
||||
|
@ -138,7 +138,7 @@ static bool lowerConstantIntrinsics(Function &F, const TargetLibraryInfo *TLI,
|
|||
IsConstantIntrinsicsHandled++;
|
||||
break;
|
||||
case Intrinsic::objectsize:
|
||||
NewValue = lowerObjectSizeCall(II, DL, TLI, true);
|
||||
NewValue = lowerObjectSizeCall(II, DL, &TLI, true);
|
||||
ObjectSizeIntrinsicsHandled++;
|
||||
break;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ static bool lowerConstantIntrinsics(Function &F, const TargetLibraryInfo *TLI,
|
|||
|
||||
PreservedAnalyses
|
||||
LowerConstantIntrinsicsPass::run(Function &F, FunctionAnalysisManager &AM) {
|
||||
if (lowerConstantIntrinsics(F, AM.getCachedResult<TargetLibraryAnalysis>(F),
|
||||
if (lowerConstantIntrinsics(F, AM.getResult<TargetLibraryAnalysis>(F),
|
||||
AM.getCachedResult<DominatorTreeAnalysis>(F))) {
|
||||
PreservedAnalyses PA;
|
||||
PA.preserve<DominatorTreeAnalysis>();
|
||||
|
@ -176,8 +176,8 @@ public:
|
|||
}
|
||||
|
||||
bool runOnFunction(Function &F) override {
|
||||
auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
|
||||
const TargetLibraryInfo *TLI = TLIP ? &TLIP->getTLI(F) : nullptr;
|
||||
const TargetLibraryInfo &TLI =
|
||||
getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
|
||||
DominatorTree *DT = nullptr;
|
||||
if (auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>())
|
||||
DT = &DTWP->getDomTree();
|
||||
|
@ -185,6 +185,7 @@ public:
|
|||
}
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.addRequired<TargetLibraryInfoWrapperPass>();
|
||||
AU.addPreserved<GlobalsAAWrapperPass>();
|
||||
AU.addPreserved<DominatorTreeWrapperPass>();
|
||||
}
|
||||
|
@ -194,6 +195,7 @@ public:
|
|||
char LowerConstantIntrinsics::ID = 0;
|
||||
INITIALIZE_PASS_BEGIN(LowerConstantIntrinsics, "lower-constant-intrinsics",
|
||||
"Lower constant intrinsics", false, false)
|
||||
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
|
||||
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
|
||||
INITIALIZE_PASS_END(LowerConstantIntrinsics, "lower-constant-intrinsics",
|
||||
"Lower constant intrinsics", false, false)
|
||||
|
|
|
@ -144,7 +144,7 @@ declare i8* @malloc(i64)
|
|||
define i64 @test_objectsize_malloc() {
|
||||
; CHECK-LABEL: @test_objectsize_malloc(
|
||||
; CHECK-NEXT: [[PTR:%.*]] = call i8* @malloc(i64 16)
|
||||
; CHECK-NEXT: ret i64 -1
|
||||
; CHECK-NEXT: ret i64 16
|
||||
;
|
||||
%ptr = call i8* @malloc(i64 16)
|
||||
%objsize = call i64 @llvm.objectsize.i64(i8* %ptr, i1 false, i1 true, i1 true)
|
||||
|
|
Loading…
Reference in New Issue