Skip to content

[LLVM][TableGen] Refine overloaded intrinsic suffix check #117957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion llvm/test/TableGen/intrinsic-overload-conflict.td
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
3 changes: 2 additions & 1 deletion llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading