[PATCH] D26381: LibcallsShrinkWrap doesn't preserve the CFG

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 7 19:52:26 PST 2016


davide updated this revision to Diff 77137.
davide added a comment.

Renamed test file.


https://reviews.llvm.org/D26381

Files:
  lib/Transforms/Utils/LibCallsShrinkWrap.cpp
  test/Transforms/InstCombine/pr30929.ll


Index: test/Transforms/InstCombine/pr30929.ll
===================================================================
--- /dev/null
+++ test/Transforms/InstCombine/pr30929.ll
@@ -0,0 +1,8 @@
+; RUN: opt -instcombine -libcalls-shrinkwrap -gvn
+
+define void @main() {
+  %_tmp31 = call float @acosf(float 2.000000e+00)
+  ret void
+}
+
+declare float @acosf(float)
Index: lib/Transforms/Utils/LibCallsShrinkWrap.cpp
===================================================================
--- lib/Transforms/Utils/LibCallsShrinkWrap.cpp
+++ 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 @@
 }
 
 void LibCallsShrinkWrapLegacyPass::getAnalysisUsage(AnalysisUsage &AU) const {
-  AU.setPreservesCFG();
+  AU.addPreserved<GlobalsAAWrapperPass>();
   AU.addRequired<TargetLibraryInfoWrapperPass>();
 }
 
@@ -561,6 +562,8 @@
   bool Changed = runImpl(F, TLI);
   if (!Changed)
     return PreservedAnalyses::all();
-  return PreservedAnalyses::none();
+  auto PA = PreservedAnalyses();
+  PA.preserve<GlobalsAA>();
+  return PA;
 }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26381.77137.patch
Type: text/x-patch
Size: 1322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161108/c0e12c18/attachment.bin>


More information about the llvm-commits mailing list