[PATCH] D127202: [InlineFunction] Handle early exit during getUnderlyingObjects due to MaxLookup
ChenZheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 24 05:31:03 PDT 2022
shchenz updated this revision to Diff 439710.
shchenz marked 2 inline comments as done.
shchenz added a comment.
address @nikic comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127202/new/
https://reviews.llvm.org/D127202
Files:
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/test/Transforms/Coroutines/coro-retcon-opaque-ptr.ll
llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
llvm/test/Transforms/Coroutines/coro-retcon.ll
llvm/test/Transforms/Inline/inline-noalias-unidentify-object.ll
Index: llvm/test/Transforms/Inline/inline-noalias-unidentify-object.ll
===================================================================
--- llvm/test/Transforms/Inline/inline-noalias-unidentify-object.ll
+++ llvm/test/Transforms/Inline/inline-noalias-unidentify-object.ll
@@ -14,7 +14,7 @@
; CHECK-NEXT: [[P_6_I:%.*]] = getelementptr i8, ptr [[P_5_I]], i64 1
; CHECK-NEXT: [[P_7_I:%.*]] = getelementptr i8, ptr [[P_6_I]], i64 1
; CHECK-NEXT: [[P_8_ALIAS_I:%.*]] = getelementptr i8, ptr [[P_7_I]], i64 1
-; CHECK-NEXT: store i32 42, ptr [[P_8_ALIAS_I]], align 4, !noalias !0
+; CHECK-NEXT: store i32 42, ptr [[P_8_ALIAS_I]], align 4
; CHECK-NEXT: ret i32 [[V_I]]
;
%v = call i32 @callee(ptr %p)
Index: llvm/test/Transforms/Coroutines/coro-retcon.ll
===================================================================
--- llvm/test/Transforms/Coroutines/coro-retcon.ll
+++ llvm/test/Transforms/Coroutines/coro-retcon.ll
@@ -36,8 +36,8 @@
; CHECK-LABEL: @main(
; CHECK-NEXT: entry:
; CHECK-NEXT: call void @print(i32 4)
-; CHECK-NEXT: call void @print(i32 5), !noalias !0
-; CHECK-NEXT: call void @print(i32 6), !noalias !3
+; CHECK-NEXT: call void @print(i32 5)
+; CHECK-NEXT: call void @print(i32 6)
; CHECK-NEXT: ret i32 0
;
entry:
Index: llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
===================================================================
--- llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
+++ llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
@@ -66,7 +66,7 @@
; CHECK-NEXT: [[N_VAL3_RELOAD_ADDR11_I5:%.*]] = getelementptr inbounds [[F_FRAME]], %f.Frame* [[FRAMEPTR_I2]], i64 0, i32 1
; CHECK-NEXT: [[N_VAL3_RELOAD12_I6:%.*]] = load i32, i32* [[N_VAL3_RELOAD_ADDR11_I5]], align 4, !noalias !6
; CHECK-NEXT: [[SUM7_I7:%.*]] = add i32 [[N_VAL3_RELOAD12_I6]], [[INPUT_RELOAD14_I4]]
-; CHECK-NEXT: call void @print(i32 [[SUM7_I7]]), !noalias !6
+; CHECK-NEXT: call void @print(i32 [[SUM7_I7]])
; CHECK-NEXT: [[TMP5:%.*]] = bitcast %f.Frame* [[FRAMEPTR_I2]] to i8*
; CHECK-NEXT: call void @deallocate(i8* [[TMP5]]), !noalias !6
; CHECK-NEXT: ret i32 0
Index: llvm/test/Transforms/Coroutines/coro-retcon-opaque-ptr.ll
===================================================================
--- llvm/test/Transforms/Coroutines/coro-retcon-opaque-ptr.ll
+++ llvm/test/Transforms/Coroutines/coro-retcon-opaque-ptr.ll
@@ -34,8 +34,8 @@
; CHECK-LABEL: @main(
; CHECK-NEXT: entry:
; CHECK-NEXT: call void @print(i32 4)
-; CHECK-NEXT: call void @print(i32 5), !noalias !0
-; CHECK-NEXT: call void @print(i32 6), !noalias !3
+; CHECK-NEXT: call void @print(i32 5)
+; CHECK-NEXT: call void @print(i32 6)
; CHECK-NEXT: ret i32 0
;
entry:
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
===================================================================
--- llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1079,7 +1079,8 @@
// Figure out if we're derived from anything that is not a noalias
// argument.
- bool RequiresNoCaptureBefore = false, UsesAliasingPtr = false;
+ bool RequiresNoCaptureBefore = false, UsesAliasingPtr = false,
+ UsesUnknownObject = false;
for (const Value *V : ObjSet) {
// Is this value a constant that cannot be derived from any pointer
// value (we need to exclude constant expressions, for example, that
@@ -1100,14 +1101,24 @@
UsesAliasingPtr = true;
}
- // If this is not some identified function-local object (which cannot
- // directly alias a noalias argument), or some other argument (which,
- // by definition, also cannot alias a noalias argument), then we could
- // alias a noalias argument that has been captured).
- if (!isa<Argument>(V) && !isIdentifiedFunctionLocal(V))
+ if (isEscapeSource(V)) {
+ // An escape source can only alias with a noalias argument if it has
+ // been captured beforehand.
RequiresNoCaptureBefore = true;
+ } else if (!isa<Argument>(V) && !isIdentifiedObject(V)) {
+ // If this is neither an escape source, nor some identified object
+ // (which cannot directly alias a noalias argument), nor some other
+ // argument (which, by definition, also cannot alias a noalias
+ // argument), conservatively do not make any assumptions.
+ UsesUnknownObject = true;
+ }
}
+ // Nothing we can do if the used underlying object cannot be reliably
+ // determined.
+ if (UsesUnknownObject)
+ continue;
+
// A function call can always get captured noalias pointers (via other
// parameters, globals, etc.).
if (IsFuncCall && !IsArgMemOnlyCall)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127202.439710.patch
Type: text/x-patch
Size: 4861 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220624/3317d380/attachment.bin>
More information about the llvm-commits
mailing list