Skip to content

Commit 44af592

Browse files
danilamlarpilipe
andauthored
[Statepoint] Return undef value for the statepoint of the none token (#72552)
Helps avoid the crash in verifier when it tries to print the error. `none` token might be produced by llvm-reduce, since it's a default value, so by extension this also fixes llvm-reduce crash, allowing it to just discard invalid IR. --------- Co-authored-by: arpilipe <[email protected]>
1 parent 2ed1587 commit 44af592

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

llvm/lib/IR/IntrinsicInst.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,10 @@ const Value *GCProjectionInst::getStatepoint() const {
870870
if (isa<UndefValue>(Token))
871871
return Token;
872872

873+
// Treat none token as if it was undef here
874+
if (isa<ConstantTokenNone>(Token))
875+
return UndefValue::get(Token->getType());
876+
873877
// This takes care both of relocates for call statepoints and relocates
874878
// on normal path of invoke statepoint.
875879
if (!isa<LandingPadInst>(Token))

llvm/test/Verifier/gc_none_token.ll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; RUN: not opt -passes=verify -S %s 2>&1 | FileCheck %s
2+
; Check that verifier doesn't crash on relocate with none token
3+
4+
target triple = "x86_64-unknown-linux-gnu"
5+
6+
define i32 @check_verify_none_token() gc "statepoint-example" {
7+
8+
entry:
9+
ret i32 0
10+
11+
unreach:
12+
; CHECK: gc relocate is incorrectly tied to the statepoint
13+
; CHECK: (undef, undef)
14+
%token_call = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token none, i32 0, i32 0)
15+
ret i32 1
16+
}
17+
18+
declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token, i32, i32)

0 commit comments

Comments
 (0)