[LibcallsShrinkWrap] This pass doesn't preserve the CFG.

For example, it invalidates the domtree, causing assertions
in later passes which need dominator infos. Make it preserve
GlobalsAA, as suggested by Eli.

Differential Revision:  https://reviews.llvm.org/D26381

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286271 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Davide Italiano 2016-11-08 19:18:20 +00:00
parent e481b32815
commit 9579593784
2 changed files with 16 additions and 2 deletions

View File

@ -29,6 +29,7 @@
#include "llvm/Transforms/Utils/LibCallsShrinkWrap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constants.h"
@ -529,7 +530,7 @@ bool LibCallsShrinkWrap::perform(CallInst *CI) {
}
void LibCallsShrinkWrapLegacyPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesCFG();
AU.addPreserved<GlobalsAAWrapperPass>();
AU.addRequired<TargetLibraryInfoWrapperPass>();
}
@ -561,6 +562,8 @@ PreservedAnalyses LibCallsShrinkWrapPass::run(Function &F,
bool Changed = runImpl(F, TLI);
if (!Changed)
return PreservedAnalyses::all();
return PreservedAnalyses::none();
auto PA = PreservedAnalyses();
PA.preserve<GlobalsAA>();
return PA;
}
}

View File

@ -0,0 +1,11 @@
; We need this pipeline because to trigger dominator info verification
; we have to compute the dominator before libcalls-shrinkwrap and
; have a pass which requires the dominator tree after.
; RUN: opt -domtree -libcalls-shrinkwrap -instcombine -verify-dom-info %s
define void @main() {
%_tmp31 = call float @acosf(float 2.000000e+00)
ret void
}
declare float @acosf(float)