[llvm] r286271 - [LibcallsShrinkWrap] This pass doesn't preserve the CFG.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 8 11:18:21 PST 2016
Author: davide
Date: Tue Nov 8 13:18:20 2016
New Revision: 286271
URL: http://llvm.org/viewvc/llvm-project?rev=286271&view=rev
Log:
[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
Added:
llvm/trunk/test/Transforms/InstCombine/pr30929.ll
Modified:
llvm/trunk/lib/Transforms/Utils/LibCallsShrinkWrap.cpp
Modified: llvm/trunk/lib/Transforms/Utils/LibCallsShrinkWrap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LibCallsShrinkWrap.cpp?rev=286271&r1=286270&r2=286271&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LibCallsShrinkWrap.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LibCallsShrinkWrap.cpp Tue Nov 8 13:18:20 2016
@@ -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(CallIns
}
void LibCallsShrinkWrapLegacyPass::getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesCFG();
+ AU.addPreserved<GlobalsAAWrapperPass>();
AU.addRequired<TargetLibraryInfoWrapperPass>();
}
@@ -561,6 +562,8 @@ PreservedAnalyses LibCallsShrinkWrapPass
bool Changed = runImpl(F, TLI);
if (!Changed)
return PreservedAnalyses::all();
- return PreservedAnalyses::none();
+ auto PA = PreservedAnalyses();
+ PA.preserve<GlobalsAA>();
+ return PA;
}
}
Added: llvm/trunk/test/Transforms/InstCombine/pr30929.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/pr30929.ll?rev=286271&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/pr30929.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/pr30929.ll Tue Nov 8 13:18:20 2016
@@ -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)
More information about the llvm-commits
mailing list