[PATCH] D76378: [Attributor] Make use of analysis in the MustBeExecutedExplorer
Shinji Okumura via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 18 11:57:39 PDT 2020
okura created this revision.
okura added reviewers: jdoerfert, uenoku, sstefan1, baziotis.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This commit was made to settle this issue on GitHub <https://github.com/llvm/llvm-project/issues/175>.
I added analysis getters for LoopInfo, DominatorTree, and PostDominatorTree. And I added a test to show an improvement of the deduction of `dereferenceable` attribute.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76378
Files:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/test/Transforms/Attributor/dereferenceable-2.ll
Index: llvm/test/Transforms/Attributor/dereferenceable-2.ll
===================================================================
--- llvm/test/Transforms/Attributor/dereferenceable-2.ll
+++ llvm/test/Transforms/Attributor/dereferenceable-2.ll
@@ -354,3 +354,47 @@
store double 0.000000e+00, double* %arg-cast
ret void
}
+
+; Make use of MustBeExecuted Explorer
+;
+; [CFG]
+; entry
+; / \
+; l1 l2
+; | X |
+; l3 l4
+; \ /
+; l5
+; / \
+; l6 l7
+; \ /
+; end
+; According to the above CFG, we can see that instructions in l5 Block must be executed.
+; Therefore, %p must be dereferenced.
+;
+; CHECK: define i32 @require_cfg_analysis(i32 %c, i32* dereferenceable(4) %p)
+define i32 @require_cfg_analysis(i32 %c, i32* %p) {
+ %tobool1 = icmp eq i32 %c, 0
+ br i1 %tobool1, label %l1, label %l2
+l1:
+ %tobool2 = icmp eq i32 %c, 1
+ br i1 %tobool2, label %l3, label %l4
+l2:
+ %tobool3 = icmp eq i32 %c, 2
+ br i1 %tobool3, label %l3, label %l4
+l3:
+ br label %l5
+l4:
+ br label %l5
+l5:
+ %tobool4 = icmp eq i32 %c, 4
+ br i1 %tobool4, label %l6, label %l7
+l6:
+ store i32 0, i32* %p
+ br label %end
+l7:
+ store i32 1, i32* %p
+ br label %end
+end:
+ ret i32 1
+}
Index: llvm/include/llvm/Transforms/IPO/Attributor.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/Attributor.h
+++ llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -105,7 +105,9 @@
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/InlineCost.h"
#include "llvm/Analysis/LazyCallGraph.h"
+#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/MustExecute.h"
+#include "llvm/Analysis/PostDominators.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/IR/CallSite.h"
@@ -560,7 +562,20 @@
SetVector<Function *> *CGSCC)
: DL(M.getDataLayout()),
Explorer(/* ExploreInterBlock */ true, /* ExploreCFGForward */ true,
- /* ExploreCFGBackward */ true),
+ /* ExploreCFGBackward */ true,
+ // LIGetter
+ [](const Function &F) {
+ return new LoopInfo(
+ *(new DominatorTree(const_cast<Function &>(F))));
+ },
+ // DTGetter
+ [](const Function &F) {
+ return new DominatorTree(const_cast<Function &>(F));
+ },
+ // PDTGetter
+ [](const Function &F) {
+ return new PostDominatorTree(const_cast<Function &>(F));
+ }),
AG(AG), CGSCC(CGSCC) {}
/// A map type from opcodes to instructions with this opcode.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76378.251141.patch
Type: text/x-patch
Size: 2766 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200318/e38dc0ea/attachment.bin>
More information about the llvm-commits
mailing list