aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIl-Capitano <csanad.hajdu@arm.com>2024-04-02 15:28:19 +0200
committerGitHub <noreply@github.com>2024-04-02 09:28:19 -0400
commit0ef743778000e7d213e53e6a7b998e1c34a28701 (patch)
tree95b91d1c55335a552e5587b8c086ae8189a51aa0
parent0b9528d6bd0bfde5702b1ee5ed8a249d354434f1 (diff)
downloadllvm-0ef743778000e7d213e53e6a7b998e1c34a28701.zip
llvm-0ef743778000e7d213e53e6a7b998e1c34a28701.tar.gz
llvm-0ef743778000e7d213e53e6a7b998e1c34a28701.tar.bz2
[SelectionDAG][Statepoint] Fix truncation of `gc.statepoint` ID argument (#85908)
The ID argument of `gc.statepoint` gets incorrectly truncated to 32 bits during code generation. This is fixed by using `uint64_t` instead of `unsigned` for the `ID` member in `SelectionDAGBuilder::StatepointLoweringInfo`, and a `patchpoint` test case is extended to check for 64 bit ID generation in stackmaps.
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h2
-rw-r--r--llvm/test/CodeGen/AArch64/stackmap.ll32
2 files changed, 29 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
index dcf46e0..211e165 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
@@ -449,7 +449,7 @@ public:
ArrayRef<const Use> GCTransitionArgs;
/// The ID that the resulting STATEPOINT instruction has to report.
- unsigned ID = -1;
+ uint64_t ID = -1;
/// Information regarding the underlying call instruction.
TargetLowering::CallLoweringInfo CLI;
diff --git a/llvm/test/CodeGen/AArch64/stackmap.ll b/llvm/test/CodeGen/AArch64/stackmap.ll
index ce7dcc4a..995d254 100644
--- a/llvm/test/CodeGen/AArch64/stackmap.ll
+++ b/llvm/test/CodeGen/AArch64/stackmap.ll
@@ -9,11 +9,11 @@
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .hword 0
; Num Functions
-; CHECK-NEXT: .word 14
+; CHECK-NEXT: .word 15
; Num LargeConstants
; CHECK-NEXT: .word 4
; Num Callsites
-; CHECK-NEXT: .word 18
+; CHECK-NEXT: .word 22
; Functions and stack size
; CHECK-NEXT: .xword constantargs
@@ -49,6 +49,9 @@
; CHECK-NEXT: .xword longid
; CHECK-NEXT: .xword 16
; CHECK-NEXT: .xword 4
+; CHECK-NEXT: .xword statepoint_longid
+; CHECK-NEXT: .xword 16
+; CHECK-NEXT: .xword 4
; CHECK-NEXT: .xword clobberLR
; CHECK-NEXT: .xword 112
; CHECK-NEXT: .xword 1
@@ -443,6 +446,26 @@ entry:
ret void
}
+; Test a 64-bit ID for statepoint.
+;
+; CHECK: .xword 4294967295
+; CHECK-LABEL: .word .L{{.*}}-statepoint_longid
+; CHECK: .xword 4294967296
+; CHECK-LABEL: .word .L{{.*}}-statepoint_longid
+; CHECK: .xword 9223372036854775807
+; CHECK-LABEL: .word .L{{.*}}-statepoint_longid
+; CHECK: .xword -1
+; CHECK-LABEL: .word .L{{.*}}-statepoint_longid
+define void @statepoint_longid() gc "statepoint-example" {
+entry:
+ %safepoint_token1 = tail call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 4294967295, i32 0, ptr elementtype(void ()) @return_void, i32 0, i32 0, i32 0, i32 0)
+ %safepoint_token2 = tail call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 4294967296, i32 0, ptr elementtype(void ()) @return_void, i32 0, i32 0, i32 0, i32 0)
+ %safepoint_token3 = tail call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 9223372036854775807, i32 0, ptr elementtype(void ()) @return_void, i32 0, i32 0, i32 0, i32 0)
+ %safepoint_token4 = tail call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 -1, i32 0, ptr elementtype(void ()) @return_void, i32 0, i32 0, i32 0, i32 0)
+ ret void
+}
+declare void @return_void()
+
; Map a value when R11 is the only free register.
; The scratch register should not be used for a live stackmap value.
;
@@ -463,8 +486,8 @@ define void @clobberLR(i32 %a) {
ret void
}
-; A stack frame which needs to be realigned at runtime (to meet alignment
-; criteria for values on the stack) does not have a fixed frame size.
+; A stack frame which needs to be realigned at runtime (to meet alignment
+; criteria for values on the stack) does not have a fixed frame size.
; CHECK-LABEL: .word .L{{.*}}-needsStackRealignment
; CHECK-NEXT: .hword 0
; 0 locations
@@ -537,3 +560,4 @@ define void @floats(float %f, double %g) {
declare void @llvm.experimental.stackmap(i64, i32, ...)
declare void @llvm.experimental.patchpoint.void(i64, i32, ptr, i32, ...)
declare i64 @llvm.experimental.patchpoint.i64(i64, i32, ptr, i32, ...)
+declare token @llvm.experimental.gc.statepoint.p0(i64, i32, ptr, i32, i32, ...)