[llvm] 4b1674f - [IR] Reject token overload types in intrinsic signature matching (#210799)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 2 05:29:47 PDT 2026
Author: Akshay K
Date: 2026-09-02T08:29:41-04:00
New Revision: 4b1674fe15991faf55fc788a06f682fc56ea0afd
URL: https://github.com/llvm/llvm-project/commit/4b1674fe15991faf55fc788a06f682fc56ea0afd
DIFF: https://github.com/llvm/llvm-project/commit/4b1674fe15991faf55fc788a06f682fc56ea0afd.diff
LOG: [IR] Reject token overload types in intrinsic signature matching (#210799)
Parsing a declaration of an llvm_any_ty intrinsic with a token overload
type crashes opt at parse time:
```
declare token @llvm.ssa.copy.token(token)
Unhandled type
UNREACHABLE executed at llvm/lib/IR/Intrinsics.cpp:133!
```
The unconstrained Any matcher accepts a token, and
Intrinsic::remangleIntrinsicFunction (run from
`LLParser::validateEndOfModule`, before the Verifier) then fails to
mangle it into the intrinsic name.
Token has no name mangling, so no overloaded intrinsic can be
instantiated on it. Reject it in matchIntrinsicType's Overloaded case,
turning the crash into the same clean "expected ..., but got token"
broken-module error that constrained overloads already produce.
Label needs no such check: it is excluded from function signatures by
`FunctionType::isValidReturnType`/`isValidArgumentType` and the
LLParser, so it never reaches matchIntrinsicType.
Fixed llvm_token_ty operands (gc.result, coro.*, ...) are unaffected.
Fixes #210641.
Added:
llvm/test/Assembler/intrinsic-token-overload-invalid.ll
Modified:
llvm/lib/IR/Intrinsics.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/Intrinsics.cpp b/llvm/lib/IR/Intrinsics.cpp
index 2fc6f135d7c5b..82b5bff1b9dec 100644
--- a/llvm/lib/IR/Intrinsics.cpp
+++ b/llvm/lib/IR/Intrinsics.cpp
@@ -1097,6 +1097,12 @@ matchIntrinsicType(Type *Ty, ArrayRef<Intrinsic::IITDescriptor> &Infos,
"Table consistency error");
OverloadTys.push_back(Ty);
+ // Token has no mangling (see getMangledTypeStr), so it cannot be an
+ // overload type; reject it with a signature error. Label is already
+ // excluded from function signatures, so it never reaches here.
+ if (Ty->isTokenTy())
+ return PrintMsg(false, "any manglable type", OIdx);
+
IITDescriptor::AnyKindVectorConstraint VC;
IITDescriptor::AnyKindElementConstraint EC;
std::tie(VC, EC) = D.getOverloadConstraints();
diff --git a/llvm/test/Assembler/intrinsic-token-overload-invalid.ll b/llvm/test/Assembler/intrinsic-token-overload-invalid.ll
new file mode 100644
index 0000000000000..f6b3f7e1d066e
--- /dev/null
+++ b/llvm/test/Assembler/intrinsic-token-overload-invalid.ll
@@ -0,0 +1,13 @@
+; RUN: not opt -disable-output %s 2>&1 | FileCheck %s
+
+; Token overloads of llvm_any_ty intrinsics used to crash parse-time intrinsic
+; remangling with "Unhandled type" in the name mangler (#210641). They must be
+; rejected with a normal signature error, like constrained overloads are.
+
+; CHECK: intrinsic return type (overload type 0) expected any manglable type, but got token
+declare token @llvm.ssa.copy.token(token)
+
+; CHECK: intrinsic argument 0 type (overload type 0) expected any manglable type, but got token
+declare i1 @llvm.is.constant.token(token)
+
+; CHECK: error: input module is broken!
More information about the llvm-commits
mailing list