[llvm] 2fdf963 - [GlobalISel] Explicitly fail trying to translate `gc.statepoint` and related intrinsics
Markus Böck via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 30 15:47:28 PDT 2022
Author: Markus Böck
Date: 2022-08-31T00:47:17+02:00
New Revision: 2fdf963dafdf4cc31112e3881c8933c5d5b5451d
URL: https://github.com/llvm/llvm-project/commit/2fdf963dafdf4cc31112e3881c8933c5d5b5451d
DIFF: https://github.com/llvm/llvm-project/commit/2fdf963dafdf4cc31112e3881c8933c5d5b5451d.diff
LOG: [GlobalISel] Explicitly fail trying to translate `gc.statepoint` and related intrinsics
The provided testcase would previously fail with an assertion due to later down below trying to allocate registers for `token` return types and arguments. This is especially problematic as the process would then exit instead of falling back to using FastIsel.
This patch fixes that by simply explicitly failing translation if either of these intrinsics are encountered.
Fixes https://github.com/llvm/llvm-project/issues/57349
Differential Revision: https://reviews.llvm.org/D132974
Added:
llvm/test/CodeGen/AArch64/GlobalISel/pr57349.ll
Modified:
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 109256b840d60..aff1f0bb7ea1a 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -61,6 +61,7 @@
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/PatternMatch.h"
+#include "llvm/IR/Statepoint.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
@@ -2403,6 +2404,10 @@ bool IRTranslator::translateCall(const User &U, MachineIRBuilder &MIRBuilder) {
if (CI.countOperandBundlesOfType(LLVMContext::OB_cfguardtarget))
return false;
+ // FIXME: support statepoints and related.
+ if (isa<GCStatepointInst, GCRelocateInst, GCResultInst>(U))
+ return false;
+
if (CI.isInlineAsm())
return translateInlineAsm(CI, MIRBuilder);
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll
index 501ea11dd0542..136c7e5c759c1 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll
@@ -141,6 +141,21 @@ entry:
ret i1 %obit
}
+; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to translate instruction: {{.*}}llvm.experimental.gc.statepoint{{.*}} (in function: gc_intr)
+; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for gc_intr
+; FALLBACK-WITH-REPORT-OUT-LABEL: gc_intr
+
+declare token @llvm.experimental.gc.statepoint.p0(i64 immarg, i32 immarg, i32()*, i32 immarg, i32 immarg, ...)
+declare i32 @llvm.experimental.gc.result(token)
+
+declare i32 @extern_returning_i32()
+
+define i32 @gc_intr() gc "statepoint-example" {
+ %statepoint_token = call token (i64, i32, i32()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, i32()* elementtype(i32 ()) @extern_returning_i32, i32 0, i32 0, i32 0, i32 0) [ "deopt"() ]
+ %ret = call i32 (token) @llvm.experimental.gc.result(token %statepoint_token)
+ ret i32 %ret
+}
+
attributes #1 = { "target-features"="+sve" }
attributes #2 = { "target-features"="+ls64" }
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/pr57349.ll b/llvm/test/CodeGen/AArch64/GlobalISel/pr57349.ll
new file mode 100644
index 0000000000000..a5d0220796b08
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/pr57349.ll
@@ -0,0 +1,22 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -global-isel -global-isel-abort=2 -mtriple aarch64-unknown-unknown -verify-machineinstrs %s -o - | FileCheck %s
+
+define i32 @__init__() gc "statepoint-example" {
+; CHECK-LABEL: __init__:
+; CHECK: // %bb.0:
+; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
+; CHECK-NEXT: .cfi_def_cfa_offset 16
+; CHECK-NEXT: .cfi_offset w30, -16
+; CHECK-NEXT: bl builtins.__init__
+; CHECK-NEXT: .Ltmp0:
+; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
+; CHECK-NEXT: ret
+ %statepoint_token = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(i32 ()) @builtins.__init__, i32 0, i32 0, i32 0, i32 0) [ "deopt"() ]
+ %ret = call i32 (token) @llvm.experimental.gc.result(token %statepoint_token)
+ ret i32 %ret
+}
+
+declare i32 @builtins.__init__()
+
+declare token @llvm.experimental.gc.statepoint.p0(i64 immarg, i32 immarg, ptr, i32 immarg, i32 immarg, ...)
+declare i32 @llvm.experimental.gc.result(token)
More information about the llvm-commits
mailing list