Skip to content

Commit 0636c93

Browse files
committed
[Attributor] Remove restriction on simplifying function pointers
Dropping this restriction seems to work fine (there are no assertion failures), so it appears that either the updater got smarter or the problematic cases are restricted elsewhere. If doing this still causes issues, then the place to address it would probably be https://github.com/llvm/llvm-project/blob/8f5bdaf481c3f4e6876a5ae0e4d7c6ed2042e6a6/llvm/lib/Transforms/IPO/Attributor.cpp#L1856-L1859, which already prevents replacement outside the SCC, so I'm not quite sure what this check is intended to avoid. Differential Revision: https://reviews.llvm.org/D120987
1 parent d231faf commit 0636c93

File tree

3 files changed

+26
-33
lines changed

3 files changed

+26
-33
lines changed

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5501,15 +5501,6 @@ struct AAValueSimplifyArgument final : AAValueSimplifyImpl {
55015501
Attribute::StructRet, Attribute::Nest, Attribute::ByVal},
55025502
/* IgnoreSubsumingPositions */ true))
55035503
indicatePessimisticFixpoint();
5504-
5505-
// FIXME: This is a hack to prevent us from propagating function poiner in
5506-
// the new pass manager CGSCC pass as it creates call edges the
5507-
// CallGraphUpdater cannot handle yet.
5508-
Value &V = getAssociatedValue();
5509-
if (V.getType()->isPointerTy() &&
5510-
V.getType()->getPointerElementType()->isFunctionTy() &&
5511-
!A.isModulePass())
5512-
indicatePessimisticFixpoint();
55135504
}
55145505

55155506
/// See AbstractAttribute::updateImpl(...).

llvm/test/Transforms/Attributor/liveness.ll

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,16 +2281,16 @@ define void @call_via_pointer_with_dead_args(i32* %a, i32* %b, void (i32*, i32*,
22812281
call void %fp(i32* %a, i32* %b, i32* %a, i64 -1, i32** null)
22822282
ret void
22832283
}
2284-
; FIXME: We have to prevent the propagation of %fp in the new pm CGSCC pass until the CallGraphUpdater can handle the new call edge.
2284+
22852285
define internal void @call_via_pointer_with_dead_args_internal_a(i32* %a, i32* %b, void (i32*, i32*, i32*, i64, i32**)* %fp) {
22862286
; NOT_CGSCC_NPM-LABEL: define {{[^@]+}}@call_via_pointer_with_dead_args_internal_a
22872287
; NOT_CGSCC_NPM-SAME: (i32* [[A:%.*]], i32* noundef nonnull align 128 dereferenceable(4) [[B:%.*]]) {
22882288
; NOT_CGSCC_NPM-NEXT: call void @called_via_pointer(i32* [[A]], i32* nonnull align 128 dereferenceable(4) [[B]], i32* [[A]], i64 -1, i32** null)
22892289
; NOT_CGSCC_NPM-NEXT: ret void
22902290
;
22912291
; IS__CGSCC____-LABEL: define {{[^@]+}}@call_via_pointer_with_dead_args_internal_a
2292-
; IS__CGSCC____-SAME: (i32* [[A:%.*]], i32* noundef nonnull align 128 dereferenceable(4) [[B:%.*]], void (i32*, i32*, i32*, i64, i32**)* nocapture nofree noundef nonnull [[FP:%.*]]) {
2293-
; IS__CGSCC____-NEXT: call void [[FP]](i32* [[A]], i32* nonnull align 128 dereferenceable(4) [[B]], i32* [[A]], i64 -1, i32** null)
2292+
; IS__CGSCC____-SAME: (i32* [[A:%.*]], i32* noalias nocapture nofree nonnull readnone align 128 dereferenceable(4) [[B:%.*]]) {
2293+
; IS__CGSCC____-NEXT: call void @called_via_pointer(i32* [[A]], i32* noalias nocapture nofree nonnull readnone align 128 dereferenceable(4) undef, i32* noalias nocapture nofree readnone undef, i64 undef, i32** noalias nocapture nofree readnone align 4294967296 undef)
22942294
; IS__CGSCC____-NEXT: ret void
22952295
;
22962296
call void %fp(i32* %a, i32* %b, i32* %a, i64 -1, i32** null)
@@ -2303,8 +2303,8 @@ define internal void @call_via_pointer_with_dead_args_internal_b(i32* %a, i32* %
23032303
; NOT_CGSCC_NPM-NEXT: ret void
23042304
;
23052305
; IS__CGSCC____-LABEL: define {{[^@]+}}@call_via_pointer_with_dead_args_internal_b
2306-
; IS__CGSCC____-SAME: (i32* [[A:%.*]], i32* noundef nonnull align 128 dereferenceable(4) [[B:%.*]], void (i32*, i32*, i32*, i64, i32**)* nocapture nofree noundef nonnull [[FP:%.*]]) {
2307-
; IS__CGSCC____-NEXT: call void [[FP]](i32* [[A]], i32* nonnull align 128 dereferenceable(4) [[B]], i32* [[A]], i64 -1, i32** null)
2306+
; IS__CGSCC____-SAME: (i32* [[A:%.*]], i32* noalias nocapture nofree nonnull readnone align 128 dereferenceable(4) [[B:%.*]]) {
2307+
; IS__CGSCC____-NEXT: call void @called_via_pointer_internal_2(i32* [[A]])
23082308
; IS__CGSCC____-NEXT: ret void
23092309
;
23102310
call void %fp(i32* %a, i32* %b, i32* %a, i64 -1, i32** null)
@@ -2327,12 +2327,10 @@ define void @call_via_pointer_with_dead_args_caller(i32* %a, i32* %b) {
23272327
; IS__CGSCC____-SAME: (i32* [[A:%.*]], i32* [[B:%.*]]) {
23282328
; IS__CGSCC____-NEXT: [[PTR1:%.*]] = alloca i32, align 128
23292329
; IS__CGSCC____-NEXT: [[PTR2:%.*]] = alloca i32, align 128
2330-
; IS__CGSCC____-NEXT: [[PTR3:%.*]] = alloca i32, align 128
2331-
; IS__CGSCC____-NEXT: [[PTR4:%.*]] = alloca i32, align 128
23322330
; IS__CGSCC____-NEXT: call void @call_via_pointer_with_dead_args(i32* [[A]], i32* noundef nonnull align 128 dereferenceable(4) [[PTR1]], void (i32*, i32*, i32*, i64, i32**)* nocapture nofree noundef nonnull @called_via_pointer)
23332331
; IS__CGSCC____-NEXT: call void @call_via_pointer_with_dead_args(i32* [[A]], i32* noundef nonnull align 128 dereferenceable(4) [[PTR2]], void (i32*, i32*, i32*, i64, i32**)* nocapture nofree noundef nonnull @called_via_pointer_internal_1)
2334-
; IS__CGSCC____-NEXT: call void @call_via_pointer_with_dead_args_internal_a(i32* [[B]], i32* noundef nonnull align 128 dereferenceable(4) [[PTR3]], void (i32*, i32*, i32*, i64, i32**)* nocapture nofree noundef nonnull @called_via_pointer)
2335-
; IS__CGSCC____-NEXT: call void @call_via_pointer_with_dead_args_internal_b(i32* [[B]], i32* noundef nonnull align 128 dereferenceable(4) [[PTR4]], void (i32*, i32*, i32*, i64, i32**)* nocapture nofree noundef nonnull @called_via_pointer_internal_2)
2332+
; IS__CGSCC____-NEXT: call void @call_via_pointer_with_dead_args_internal_a(i32* [[B]], i32* noalias nocapture nofree nonnull readnone align 128 dereferenceable(4) undef)
2333+
; IS__CGSCC____-NEXT: call void @call_via_pointer_with_dead_args_internal_b(i32* [[B]], i32* noalias nocapture nofree nonnull readnone align 128 dereferenceable(4) undef)
23362334
; IS__CGSCC____-NEXT: ret void
23372335
;
23382336
%ptr1 = alloca i32, align 128
@@ -2373,12 +2371,19 @@ entry:
23732371
}
23742372
; FIXME: Figure out why the MODULE has the unused arguments still
23752373
define internal void @called_via_pointer_internal_2(i32* %a, i32* %b, i32* %c, i64 %d, i32** %e) {
2376-
; CHECK-LABEL: define {{[^@]+}}@called_via_pointer_internal_2
2377-
; CHECK-SAME: (i32* [[A:%.*]], i32* nocapture nofree readnone [[B:%.*]], i32* nocapture nofree readnone [[C:%.*]], i64 [[D:%.*]], i32** nocapture nofree readnone [[E:%.*]]) {
2378-
; CHECK-NEXT: entry:
2379-
; CHECK-NEXT: tail call void @use_i32p(i32* [[A]])
2380-
; CHECK-NEXT: tail call void @use_i32p(i32* [[A]])
2381-
; CHECK-NEXT: ret void
2374+
; NOT_CGSCC_NPM-LABEL: define {{[^@]+}}@called_via_pointer_internal_2
2375+
; NOT_CGSCC_NPM-SAME: (i32* [[A:%.*]], i32* nocapture nofree readnone [[B:%.*]], i32* nocapture nofree readnone [[C:%.*]], i64 [[D:%.*]], i32** nocapture nofree readnone [[E:%.*]]) {
2376+
; NOT_CGSCC_NPM-NEXT: entry:
2377+
; NOT_CGSCC_NPM-NEXT: tail call void @use_i32p(i32* [[A]])
2378+
; NOT_CGSCC_NPM-NEXT: tail call void @use_i32p(i32* [[A]])
2379+
; NOT_CGSCC_NPM-NEXT: ret void
2380+
;
2381+
; IS__CGSCC____-LABEL: define {{[^@]+}}@called_via_pointer_internal_2
2382+
; IS__CGSCC____-SAME: (i32* [[A:%.*]]) {
2383+
; IS__CGSCC____-NEXT: entry:
2384+
; IS__CGSCC____-NEXT: tail call void @use_i32p(i32* [[A]])
2385+
; IS__CGSCC____-NEXT: tail call void @use_i32p(i32* [[A]])
2386+
; IS__CGSCC____-NEXT: ret void
23822387
;
23832388
entry:
23842389
tail call void @use_i32p(i32* %a)

llvm/test/Transforms/Attributor/value-simplify.ll

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -903,22 +903,19 @@ define void @test_callee_is_undef(void (i32)* %fn) {
903903
;
904904
; IS__CGSCC____-LABEL: define {{[^@]+}}@test_callee_is_undef
905905
; IS__CGSCC____-SAME: (void (i32)* nocapture nofree [[FN:%.*]]) {
906-
; IS__CGSCC____-NEXT: unreachable
906+
; IS__CGSCC____-NEXT: call void @callee_is_undef()
907+
; IS__CGSCC____-NEXT: call void @unknown_calle_arg_is_undef(void (i32)* nocapture nofree noundef nonnull [[FN]])
908+
; IS__CGSCC____-NEXT: ret void
907909
;
908910
call void @callee_is_undef(void ()* undef)
909911
call void @unknown_calle_arg_is_undef(void (i32)* %fn, i32 undef)
910912
ret void
911913
}
912914
define internal void @callee_is_undef(void ()* %fn) {
913915
;
914-
; IS__TUNIT____-LABEL: define {{[^@]+}}@callee_is_undef() {
915-
; IS__TUNIT____-NEXT: call void undef()
916-
; IS__TUNIT____-NEXT: ret void
917-
;
918-
; IS__CGSCC____-LABEL: define {{[^@]+}}@callee_is_undef
919-
; IS__CGSCC____-SAME: (void ()* nocapture nofree noundef nonnull align 4294967296 [[FN:%.*]]) {
920-
; IS__CGSCC____-NEXT: call void [[FN]]()
921-
; IS__CGSCC____-NEXT: ret void
916+
; CHECK-LABEL: define {{[^@]+}}@callee_is_undef() {
917+
; CHECK-NEXT: call void undef()
918+
; CHECK-NEXT: ret void
922919
;
923920
call void %fn()
924921
ret void

0 commit comments

Comments
 (0)