From ddf7fb71db7d60dfed0426a6812461c222dbc849 Mon Sep 17 00:00:00 2001 From: Mason Remy Date: Thu, 28 Nov 2024 02:05:18 +0000 Subject: [PATCH] [LLVM][TableGen] Refine overloaded intrinsic suffix check Previously the check comments indicated that [pi][0-9]+ would match as a type suffix, however the check itself was looking for [pi][0-9]* and hence an 'i' suffix in isolation was being considered as a type suffix despite it not having a bitwidth. This change makes the check consistent with the comment and looks for [pi][0-9]+ --- llvm/test/TableGen/intrinsic-overload-conflict.td | 6 +++++- llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/llvm/test/TableGen/intrinsic-overload-conflict.td b/llvm/test/TableGen/intrinsic-overload-conflict.td index 84333119d41f5..13431c3bc49e0 100644 --- a/llvm/test/TableGen/intrinsic-overload-conflict.td +++ b/llvm/test/TableGen/intrinsic-overload-conflict.td @@ -6,13 +6,17 @@ include "llvm/IR/Intrinsics.td" // CHECK: foo = 1, def int_foo : Intrinsic<[llvm_any_ty]>; -// No conflicts, since .bar is not a vaid mangled type. +// No conflicts, since .bar is not a valid mangled type. // CHECK: foo_bar, def int_foo_bar : Intrinsic<[llvm_i32_ty]>; // CHECK: foo_bar_f32, def int_foo_bar_f32 : Intrinsic<[llvm_i32_ty]>; +// No conflicts, since i is not a valid mangled type without a bitwidth. +// CHECK: foo_i +def int_foo_i : Intrinsic<[llvm_i32_ty]>; + #ifdef CONFLICT // CHECK-CONFLICT: error: intrinsic `llvm.foo.a3` cannot share prefix `llvm.foo.a3` with another overloaded intrinsic `llvm.foo` // CHECK-CONFLICT: error: intrinsic `llvm.foo.bf16` cannot share prefix `llvm.foo.bf16` with another overloaded intrinsic `llvm.foo` diff --git a/llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp b/llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp index 18e0b8fd135bb..0846f66ea6452 100644 --- a/llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp +++ b/llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp @@ -157,7 +157,8 @@ static bool doesSuffixLookLikeMangledType(StringRef Suffix) { return false; // [pi][0-9]+ - if (is_contained("pi", Suffix[0]) && all_of(Suffix.drop_front(), isDigit)) + if (Suffix.size() > 1 && is_contained("pi", Suffix[0]) && + all_of(Suffix.drop_front(), isDigit)) return true; // Match one of the named types.