[PATCH] D45608: [CallSiteSplit] Make sure we remove nonnull if the parameter turns out to be a constant.
Xin Tong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 23 13:12:37 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330641: [CallSiteSplit] Make sure we remove nonnull if the parameter turns out to be a… (authored by trentxintong, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D45608
Files:
llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp
llvm/trunk/test/Transforms/CallSiteSplitting/callsite-split-or-phi.ll
Index: llvm/trunk/test/Transforms/CallSiteSplitting/callsite-split-or-phi.ll
===================================================================
--- llvm/trunk/test/Transforms/CallSiteSplitting/callsite-split-or-phi.ll
+++ llvm/trunk/test/Transforms/CallSiteSplitting/callsite-split-or-phi.ll
@@ -532,3 +532,32 @@
declare void @dummy(i32*, i32)
declare void @dummy2(i32, i32)
+
+; Make sure we remove the non-nullness on constant paramater.
+;
+;CHECK-LABEL: @caller2
+;CHECK-LABEL: Top1.split:
+;CHECK: call i32 @callee(i32* inttoptr (i64 4643 to i32*)
+define void @caller2(i32 %c, i32* %a_elt, i32* %b_elt) {
+entry:
+ br label %Top0
+
+Top0:
+ %tobool1 = icmp eq i32* %a_elt, inttoptr (i64 4643 to i32*)
+ br i1 %tobool1, label %Top1, label %NextCond
+
+Top1:
+ %tobool2 = icmp ne i32* %a_elt, null
+ br i1 %tobool2, label %CallSiteBB, label %NextCond
+
+NextCond:
+ %cmp = icmp ne i32* %b_elt, null
+ br i1 %cmp, label %CallSiteBB, label %End
+
+CallSiteBB:
+ call i32 @callee(i32* %a_elt, i32 %c, i32 %c)
+ br label %End
+
+End:
+ ret void
+}
Index: llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp
+++ llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp
@@ -97,8 +97,12 @@
Constant *ConstValue) {
unsigned ArgNo = 0;
for (auto &I : CS.args()) {
- if (&*I == Op)
+ if (&*I == Op) {
+ // It is possible we have already added the non-null attribute to the
+ // parameter by using an earlier constraining condition.
+ CS.removeParamAttr(ArgNo, Attribute::NonNull);
CS.setArgument(ArgNo, ConstValue);
+ }
++ArgNo;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45608.143629.patch
Type: text/x-patch
Size: 1753 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180423/6b69d045/attachment.bin>
More information about the llvm-commits
mailing list