summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Doerfert <johannes@jdoerfert.de>2019-10-31 20:03:13 -0500
committerJohannes Doerfert <johannes@jdoerfert.de>2019-11-02 00:26:15 -0500
commit0437bfcc8338ec79f1d209daf975b9555e51e4b1 (patch)
tree27f5f978273b07223d87c58e7b687da9a70f3ff9
parent0c7d4d7f3e26bed39ee4e2817ca5078ab111c05c (diff)
downloadbcm5719-llvm-0437bfcc8338ec79f1d209daf975b9555e51e4b1.tar.gz
bcm5719-llvm-0437bfcc8338ec79f1d209daf975b9555e51e4b1.zip
[Attributor][FIX] NoCapture is not a subsuming property
We cannot look at the subsuming positions and take their nocapture bit as shown with the two tests for which we derived nocapture on the call site argument and readonly on the argument of the second before.
-rw-r--r--llvm/lib/Transforms/IPO/Attributor.cpp17
-rw-r--r--llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll31
2 files changed, 43 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index a0677c194f1..6f0a4a85890 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -3131,7 +3131,16 @@ struct AANoCaptureImpl : public AANoCapture {
/// See AbstractAttribute::initialize(...).
void initialize(Attributor &A) override {
- AANoCapture::initialize(A);
+ if (hasAttr(getAttrKind(), /* IgnoreSubsumingPositions */ true)) {
+ indicateOptimisticFixpoint();
+ return;
+ }
+ Function *AnchorScope = getAnchorScope();
+ if (isFnInterfaceKind() &&
+ (!AnchorScope || !AnchorScope->hasExactDefinition())) {
+ indicatePessimisticFixpoint();
+ return;
+ }
// You cannot "capture" null in the default address space.
if (isa<ConstantPointerNull>(getAssociatedValue()) &&
@@ -3140,13 +3149,11 @@ struct AANoCaptureImpl : public AANoCapture {
return;
}
- const IRPosition &IRP = getIRPosition();
- const Function *F =
- getArgNo() >= 0 ? IRP.getAssociatedFunction() : IRP.getAnchorScope();
+ const Function *F = getArgNo() >= 0 ? getAssociatedFunction() : AnchorScope;
// Check what state the associated function can actually capture.
if (F)
- determineFunctionCaptureCapabilities(IRP, *F, *this);
+ determineFunctionCaptureCapabilities(getIRPosition(), *F, *this);
else
indicatePessimisticFixpoint();
}
diff --git a/llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll b/llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll
index 18a4f767147..ec7db076b36 100644
--- a/llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll
+++ b/llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll
@@ -437,4 +437,35 @@ entry:
ret i32* %call
}
+
+declare i32* @unknown_i32p(i32*)
+define void @nocapture_is_not_subsumed_1(i32* nocapture %b) {
+; CHECK-LABEL: define {{[^@]+}}@nocapture_is_not_subsumed_1
+; CHECK-SAME: (i32* nocapture [[B:%.*]])
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CALL:%.*]] = call i32* @unknown_i32p(i32* [[B:%.*]])
+; CHECK-NEXT: store i32 0, i32* [[CALL]]
+; CHECK-NEXT: ret void
+;
+entry:
+ %call = call i32* @unknown_i32p(i32* %b)
+ store i32 0, i32* %call
+ ret void
+}
+
+declare i32* @readonly_i32p(i32*) readonly
+define void @nocapture_is_not_subsumed_2(i32* nocapture %b) {
+; CHECK-LABEL: define {{[^@]+}}@nocapture_is_not_subsumed_2
+; CHECK-SAME: (i32* nocapture [[B:%.*]])
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CALL:%.*]] = call i32* @readonly_i32p(i32* readonly [[B:%.*]])
+; CHECK-NEXT: store i32 0, i32* [[CALL]]
+; CHECK-NEXT: ret void
+;
+entry:
+ %call = call i32* @readonly_i32p(i32* %b)
+ store i32 0, i32* %call
+ ret void
+}
+
attributes #0 = { noinline nounwind uwtable }
OpenPOWER on IntegriCloud