2020-05-22 22:03:02 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
2020-08-31 07:17:43 +08:00
|
|
|
; RUN: opt -early-cse -earlycse-debug-hash -S < %s | FileCheck %s
|
2020-05-22 22:03:02 +08:00
|
|
|
|
|
|
|
declare void @func()
|
|
|
|
declare i32 @"personality_function"()
|
|
|
|
|
2021-03-05 04:12:45 +08:00
|
|
|
define i1 @test_trivial(i32 addrspace(1)* %in) gc "statepoint-example" {
|
|
|
|
; CHECK-LABEL: @test_trivial(
|
|
|
|
; CHECK-NEXT: entry:
|
2022-02-04 19:47:03 +08:00
|
|
|
; CHECK-NEXT: [[SAFEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(i32 addrspace(1)* [[IN:%.*]]) ]
|
2021-03-05 04:12:45 +08:00
|
|
|
; CHECK-NEXT: [[A:%.*]] = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)
|
|
|
|
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 addrspace(1)* [[A]], null
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP1]]
|
|
|
|
;
|
|
|
|
entry:
|
2022-02-04 19:47:03 +08:00
|
|
|
%safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(i32 addrspace(1)* %in)]
|
2021-03-05 04:12:45 +08:00
|
|
|
%a = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 0, i32 0)
|
|
|
|
%b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 0, i32 0)
|
|
|
|
%cmp1 = icmp eq i32 addrspace(1)* %a, null
|
|
|
|
%cmp2 = icmp eq i32 addrspace(1)* %b, null
|
|
|
|
%cmp = and i1 %cmp1, %cmp2
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
2021-03-06 02:04:07 +08:00
|
|
|
@G = external global i32
|
|
|
|
|
|
|
|
define i1 @test_readnone(i32 addrspace(1)* %in) gc "statepoint-example" {
|
|
|
|
; CHECK-LABEL: @test_readnone(
|
|
|
|
; CHECK-NEXT: entry:
|
2022-02-04 19:47:03 +08:00
|
|
|
; CHECK-NEXT: [[SAFEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(i32 addrspace(1)* [[IN:%.*]]) ]
|
2021-03-06 02:04:07 +08:00
|
|
|
; CHECK-NEXT: [[A:%.*]] = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)
|
|
|
|
; CHECK-NEXT: store i32 0, i32* @G, align 4
|
|
|
|
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 addrspace(1)* [[A]], null
|
2021-03-17 01:52:01 +08:00
|
|
|
; CHECK-NEXT: ret i1 [[CMP1]]
|
2021-03-06 02:04:07 +08:00
|
|
|
;
|
|
|
|
entry:
|
2022-02-04 19:47:03 +08:00
|
|
|
%safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(i32 addrspace(1)* %in)]
|
2021-03-06 02:04:07 +08:00
|
|
|
%a = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 0, i32 0)
|
|
|
|
store i32 0, i32* @G
|
|
|
|
%b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 0, i32 0)
|
|
|
|
%cmp1 = icmp eq i32 addrspace(1)* %a, null
|
|
|
|
%cmp2 = icmp eq i32 addrspace(1)* %b, null
|
|
|
|
%cmp = and i1 %cmp1, %cmp2
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
2021-03-05 04:12:45 +08:00
|
|
|
|
2020-05-22 22:03:02 +08:00
|
|
|
define i1 @test_call(i32 addrspace(1)* %in) gc "statepoint-example" {
|
|
|
|
; CHECK-LABEL: @test_call(
|
|
|
|
; CHECK-NEXT: entry:
|
2022-02-04 19:47:03 +08:00
|
|
|
; CHECK-NEXT: [[SAFEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(i32 addrspace(1)* [[IN:%.*]], i32 addrspace(1)* [[IN]]) ]
|
2020-06-06 05:48:52 +08:00
|
|
|
; CHECK-NEXT: [[BASE:%.*]] = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)
|
2022-02-04 19:47:03 +08:00
|
|
|
; CHECK-NEXT: [[SAFEPOINT_TOKEN2:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(i32 addrspace(1)* [[BASE]], i32 addrspace(1)* [[BASE]]) ]
|
2020-05-22 22:03:02 +08:00
|
|
|
; CHECK-NEXT: br label [[NEXT:%.*]]
|
|
|
|
; CHECK: next:
|
2020-06-06 05:48:52 +08:00
|
|
|
; CHECK-NEXT: [[BASE_RELOC:%.*]] = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token [[SAFEPOINT_TOKEN2]], i32 0, i32 0)
|
|
|
|
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 addrspace(1)* [[BASE_RELOC]], null
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP1]]
|
2020-05-22 22:03:02 +08:00
|
|
|
;
|
|
|
|
entry:
|
2022-02-04 19:47:03 +08:00
|
|
|
%safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(i32 addrspace(1)* %in, i32 addrspace(1)* %in)]
|
2020-06-06 05:48:52 +08:00
|
|
|
%base = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 0, i32 0)
|
|
|
|
%derived = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 0, i32 1)
|
2022-02-04 19:47:03 +08:00
|
|
|
%safepoint_token2 = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(i32 addrspace(1)* %base, i32 addrspace(1)* %derived)]
|
2020-05-22 22:03:02 +08:00
|
|
|
br label %next
|
|
|
|
|
|
|
|
next:
|
2020-06-06 05:48:52 +08:00
|
|
|
%base_reloc = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token2, i32 0, i32 0)
|
|
|
|
%derived_reloc = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token2, i32 0, i32 1)
|
2020-05-22 22:03:02 +08:00
|
|
|
%cmp1 = icmp eq i32 addrspace(1)* %base_reloc, null
|
|
|
|
%cmp2 = icmp eq i32 addrspace(1)* %derived_reloc, null
|
|
|
|
%cmp = and i1 %cmp1, %cmp2
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; Negative test: Check that relocates from different statepoints are not CSE'd
|
|
|
|
define i1 @test_two_calls(i32 addrspace(1)* %in1, i32 addrspace(1)* %in2) gc "statepoint-example" {
|
|
|
|
; CHECK-LABEL: @test_two_calls(
|
|
|
|
; CHECK-NEXT: entry:
|
2022-02-04 19:47:03 +08:00
|
|
|
; CHECK-NEXT: [[SAFEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(i32 addrspace(1)* [[IN1:%.*]], i32 addrspace(1)* [[IN2:%.*]]) ]
|
2020-06-06 05:48:52 +08:00
|
|
|
; CHECK-NEXT: [[IN1_RELOC1:%.*]] = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)
|
|
|
|
; CHECK-NEXT: [[IN2_RELOC1:%.*]] = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token [[SAFEPOINT_TOKEN]], i32 1, i32 1)
|
2022-02-04 19:47:03 +08:00
|
|
|
; CHECK-NEXT: [[SAFEPOINT_TOKEN2:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(i32 addrspace(1)* [[IN1_RELOC1]], i32 addrspace(1)* [[IN2_RELOC1]]) ]
|
2020-06-06 05:48:52 +08:00
|
|
|
; CHECK-NEXT: [[IN1_RELOC2:%.*]] = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token [[SAFEPOINT_TOKEN2]], i32 0, i32 1)
|
|
|
|
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 addrspace(1)* [[IN1_RELOC2]], null
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP1]]
|
2020-05-22 22:03:02 +08:00
|
|
|
;
|
|
|
|
entry:
|
2022-02-04 19:47:03 +08:00
|
|
|
%safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(i32 addrspace(1)* %in1, i32 addrspace(1)* %in2)]
|
2020-06-06 05:48:52 +08:00
|
|
|
%in1.reloc1 = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 0, i32 0)
|
|
|
|
%in2.reloc1 = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 1, i32 1)
|
2022-02-04 19:47:03 +08:00
|
|
|
%safepoint_token2 = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(i32 addrspace(1)* %in1.reloc1, i32 addrspace(1)* %in2.reloc1)]
|
2020-06-06 05:48:52 +08:00
|
|
|
%in1.reloc2 = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token2, i32 0, i32 1)
|
|
|
|
%in2.reloc2 = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token2, i32 0, i32 1)
|
2020-05-22 22:03:02 +08:00
|
|
|
%cmp1 = icmp eq i32 addrspace(1)* %in1.reloc2, null
|
|
|
|
%cmp2 = icmp eq i32 addrspace(1)* %in2.reloc2, null
|
|
|
|
%cmp = and i1 %cmp1, %cmp2
|
|
|
|
ret i1 %cmp
|
|
|
|
}
|
|
|
|
|
|
|
|
; Negative test: Check that relocates from normal and exceptional pathes are not be CSE'd
|
|
|
|
define i32 addrspace(1)* @test_invoke(i32 addrspace(1)* %in) gc "statepoint-example" personality i32 ()* @"personality_function" {
|
|
|
|
; CHECK-LABEL: @test_invoke(
|
2022-02-04 19:47:03 +08:00
|
|
|
; CHECK-NEXT: [[SAFEPOINT_TOKEN:%.*]] = invoke token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(i32 addrspace(1)* [[IN:%.*]]) ]
|
2020-05-22 22:03:02 +08:00
|
|
|
; CHECK-NEXT: to label [[INVOKE_NORMAL_DEST:%.*]] unwind label [[EXCEPTIONAL_RETURN:%.*]]
|
|
|
|
; CHECK: invoke_normal_dest:
|
2020-06-06 05:48:52 +08:00
|
|
|
; CHECK-NEXT: [[OUT:%.*]] = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)
|
2020-05-22 22:03:02 +08:00
|
|
|
; CHECK-NEXT: ret i32 addrspace(1)* [[OUT]]
|
|
|
|
; CHECK: exceptional_return:
|
|
|
|
; CHECK-NEXT: [[LANDING_PAD:%.*]] = landingpad token
|
|
|
|
; CHECK-NEXT: cleanup
|
2020-06-06 05:48:52 +08:00
|
|
|
; CHECK-NEXT: [[OUT1:%.*]] = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token [[LANDING_PAD]], i32 0, i32 0)
|
2020-05-22 22:03:02 +08:00
|
|
|
; CHECK-NEXT: ret i32 addrspace(1)* [[OUT1]]
|
|
|
|
;
|
2022-02-04 19:47:03 +08:00
|
|
|
%safepoint_token = invoke token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(i32 addrspace(1)* %in)]
|
2020-05-22 22:03:02 +08:00
|
|
|
to label %invoke_normal_dest unwind label %exceptional_return
|
|
|
|
|
|
|
|
invoke_normal_dest:
|
2020-06-06 05:48:52 +08:00
|
|
|
%out = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 0, i32 0)
|
2020-05-22 22:03:02 +08:00
|
|
|
ret i32 addrspace(1)* %out
|
|
|
|
|
|
|
|
exceptional_return:
|
|
|
|
%landing_pad = landingpad token
|
|
|
|
cleanup
|
2020-06-06 05:48:52 +08:00
|
|
|
%out1 = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %landing_pad, i32 0, i32 0)
|
2020-05-22 22:03:02 +08:00
|
|
|
ret i32 addrspace(1)* %out1
|
|
|
|
}
|
|
|
|
|
2021-03-05 04:12:45 +08:00
|
|
|
; negative test - neither dominates the other
|
|
|
|
define i1 @test_non_dominating(i1 %c, i32 addrspace(1)* %in) gc "statepoint-example" {
|
|
|
|
;
|
|
|
|
; CHECK-LABEL: @test_non_dominating(
|
|
|
|
; CHECK-NEXT: entry:
|
2022-02-04 19:47:03 +08:00
|
|
|
; CHECK-NEXT: [[SAFEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(i32 addrspace(1)* [[IN:%.*]]) ]
|
2021-03-05 04:12:45 +08:00
|
|
|
; CHECK-NEXT: br i1 [[C:%.*]], label [[TAKEN:%.*]], label [[UNTAKEN:%.*]]
|
|
|
|
; CHECK: taken:
|
|
|
|
; CHECK-NEXT: [[A:%.*]] = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)
|
|
|
|
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 addrspace(1)* [[A]], null
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP]]
|
|
|
|
; CHECK: untaken:
|
|
|
|
; CHECK-NEXT: [[B:%.*]] = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)
|
|
|
|
; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 addrspace(1)* [[B]], null
|
|
|
|
; CHECK-NEXT: ret i1 [[CMP2]]
|
|
|
|
;
|
|
|
|
entry:
|
2022-02-04 19:47:03 +08:00
|
|
|
%safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(i32 addrspace(1)* %in)]
|
2021-03-05 04:12:45 +08:00
|
|
|
br i1 %c, label %taken, label %untaken
|
|
|
|
taken:
|
|
|
|
%a = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 0, i32 0)
|
|
|
|
%cmp = icmp eq i32 addrspace(1)* %a, null
|
|
|
|
ret i1 %cmp
|
|
|
|
untaken:
|
|
|
|
%b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 0, i32 0)
|
|
|
|
%cmp2 = icmp eq i32 addrspace(1)* %b, null
|
|
|
|
ret i1 %cmp2
|
|
|
|
}
|
|
|
|
|
2020-05-22 22:03:02 +08:00
|
|
|
declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
|
|
|
|
declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token, i32, i32)
|