From 9579593784788024d58c09c9a251c78bc8c11b03 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Tue, 8 Nov 2016 19:18:20 +0000 Subject: [PATCH] [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 --- lib/Transforms/Utils/LibCallsShrinkWrap.cpp | 7 +++++-- test/Transforms/InstCombine/pr30929.ll | 11 +++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 test/Transforms/InstCombine/pr30929.ll diff --git a/lib/Transforms/Utils/LibCallsShrinkWrap.cpp b/lib/Transforms/Utils/LibCallsShrinkWrap.cpp index c9924984bb5..b59ddcffeff 100644 --- a/lib/Transforms/Utils/LibCallsShrinkWrap.cpp +++ b/lib/Transforms/Utils/LibCallsShrinkWrap.cpp @@ -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(); AU.addRequired(); } @@ -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(); + return PA; } } diff --git a/test/Transforms/InstCombine/pr30929.ll b/test/Transforms/InstCombine/pr30929.ll new file mode 100644 index 00000000000..2d19775f312 --- /dev/null +++ b/test/Transforms/InstCombine/pr30929.ll @@ -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) -- 2.40.0