-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang][RISCV] Extend intrinsic size check variable from 16 -> 32 bits. NFC #111481
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
[clang][RISCV] Extend intrinsic size check variable from 16 -> 32 bits. NFC #111481
Conversation
@llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-risc-v Author: Brandon Wu (4vtomat) ChangesWe currently have over 67000 intrinsics, uint16_t will overflow. Full diff: https://github.com/llvm/llvm-project/pull/111481.diff 1 Files Affected:
diff --git a/clang/lib/Sema/SemaRISCV.cpp b/clang/lib/Sema/SemaRISCV.cpp
index 3da4b515b1b114..f49c2088ef4776 100644
--- a/clang/lib/Sema/SemaRISCV.cpp
+++ b/clang/lib/Sema/SemaRISCV.cpp
@@ -399,7 +399,7 @@ void RISCVIntrinsicManagerImpl::InitRVVIntrinsic(
Record.HasFRMRoundModeOp);
// Put into IntrinsicList.
- uint16_t Index = IntrinsicList.size();
+ uint32_t Index = IntrinsicList.size();
assert(IntrinsicList.size() == (size_t)Index &&
"Intrinsics indices overflow.");
IntrinsicList.push_back({BuiltinName, Signature});
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't any test catch it?
I suppose the CI of intrinsic doc should catch this, but it is not reporting errors as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Why don’t any of our lit tests that use every intrinsic catch it? |
@@ -399,7 +399,7 @@ void RISCVIntrinsicManagerImpl::InitRVVIntrinsic( | |||
Record.HasFRMRoundModeOp); | |||
|
|||
// Put into IntrinsicList. | |||
uint16_t Index = IntrinsicList.size(); | |||
uint32_t Index = IntrinsicList.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the type of Intrinsics on this line further down
Intrinsics.insert({Name, Index});
is it also uint16_t?
We don't see any error, is it because your downstream added some intrinsics? |
Does the number intrinsics vary with the number of extensions enabled? Maybe we don't have a test with all extensions? |
Somehow if we add more "target-feature" the intrinsics increase, I'm not sure why.
Compile with this command:
generate 61674 intrinsics.
generate 64568 intrinsics it's weird. |
Why is it weird? Some intrinsics require specific features. If that feature isn't enabled, the intrinsic is skipped. |
Oh I see, but if we extend the size, the memory usage will grow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to change
struct RVVOverloadIntrinsicDef {
// Indexes of RISCVIntrinsicManagerImpl::IntrinsicList.
SmallVector<uint16_t, 8> Indexes;
};
and
// Mapping function name to index of IntrinsicList.
StringMap<uint16_t> Intrinsics;
Those places were both changed by e0092ea in addition to the place you've currently changed.
Oh, nice catch! I didn't even remember I've changed this before lol~ |
…s. NFC We currently have over 67000 intrinsics, uint16_t will overflow.
f6a27f7
to
c2b4790
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Can this get merged? |
We currently have over 67000 intrinsics, uint16_t will overflow.