summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp6
-rw-r--r--llvm/test/Transforms/CallSiteSplitting/callsite-split-or-phi.ll29
2 files changed, 34 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp b/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
index ce1c83d29aa..dac52a6e3b7 100644
--- a/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
+++ b/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
@@ -97,8 +97,12 @@ static void setConstantInArgument(CallSite CS, Value *Op,
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;
}
}
diff --git a/llvm/test/Transforms/CallSiteSplitting/callsite-split-or-phi.ll b/llvm/test/Transforms/CallSiteSplitting/callsite-split-or-phi.ll
index 44ad9af81a1..d5f31f9ac91 100644
--- a/llvm/test/Transforms/CallSiteSplitting/callsite-split-or-phi.ll
+++ b/llvm/test/Transforms/CallSiteSplitting/callsite-split-or-phi.ll
@@ -532,3 +532,32 @@ End:
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
+}
OpenPOWER on IntegriCloud