Skip to content

Commit 0c6457b

Browse files
authored
[LLVM][TableGen] Refine overloaded intrinsic suffix check (#117957)
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]+
1 parent 0ca8a59 commit 0c6457b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

llvm/test/TableGen/intrinsic-overload-conflict.td

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ include "llvm/IR/Intrinsics.td"
66
// CHECK: foo = 1,
77
def int_foo : Intrinsic<[llvm_any_ty]>;
88

9-
// No conflicts, since .bar is not a vaid mangled type.
9+
// No conflicts, since .bar is not a valid mangled type.
1010
// CHECK: foo_bar,
1111
def int_foo_bar : Intrinsic<[llvm_i32_ty]>;
1212

1313
// CHECK: foo_bar_f32,
1414
def int_foo_bar_f32 : Intrinsic<[llvm_i32_ty]>;
1515

16+
// No conflicts, since i is not a valid mangled type without a bitwidth.
17+
// CHECK: foo_i
18+
def int_foo_i : Intrinsic<[llvm_i32_ty]>;
19+
1620
#ifdef CONFLICT
1721
// CHECK-CONFLICT: error: intrinsic `llvm.foo.a3` cannot share prefix `llvm.foo.a3` with another overloaded intrinsic `llvm.foo`
1822
// CHECK-CONFLICT: error: intrinsic `llvm.foo.bf16` cannot share prefix `llvm.foo.bf16` with another overloaded intrinsic `llvm.foo`

llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ static bool doesSuffixLookLikeMangledType(StringRef Suffix) {
157157
return false;
158158

159159
// [pi][0-9]+
160-
if (is_contained("pi", Suffix[0]) && all_of(Suffix.drop_front(), isDigit))
160+
if (Suffix.size() > 1 && is_contained("pi", Suffix[0]) &&
161+
all_of(Suffix.drop_front(), isDigit))
161162
return true;
162163

163164
// Match one of the named types.

0 commit comments

Comments
 (0)