diff options
author | Joshua Cao <cao.joshua@yahoo.com> | 2024-06-02 15:02:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-02 15:02:11 -0700 |
commit | ab08df2292334d4980b3e81829a20904e59e13c9 (patch) | |
tree | 76c9b891ac11d9c031659ea6282714ec086db888 /llvm/lib/IR/Attributes.cpp | |
parent | 4ce65423be0ba1d90c11b6a79981d6314e1cf36d (diff) | |
download | llvm-ab08df2292334d4980b3e81829a20904e59e13c9.zip llvm-ab08df2292334d4980b3e81829a20904e59e13c9.tar.gz llvm-ab08df2292334d4980b3e81829a20904e59e13c9.tar.bz2 |
[IR] Do not set `none` for function uwtable (#93387)
This avoids the pitfall where we set the uwtable to none:
```
func.setUWTableKind(llvm::UWTableKind::None)
```
`Attribute::getAsString()` would see an unknown attribute and fail an
assertion. In this patch, we assert that we do not see a None uwtable
kind.
This also skips the check of `UWTableKind::Async`. It is dominated by
the check of `UWTableKind::Default`, which has the same enum value
(nfc).
Diffstat (limited to 'llvm/lib/IR/Attributes.cpp')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index c8d6bdd..7a3c9a9 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -526,13 +526,8 @@ std::string Attribute::getAsString(bool InAttrGrp) const { if (hasAttribute(Attribute::UWTable)) { UWTableKind Kind = getUWTableKind(); - if (Kind != UWTableKind::None) { - return Kind == UWTableKind::Default - ? "uwtable" - : ("uwtable(" + - Twine(Kind == UWTableKind::Sync ? "sync" : "async") + ")") - .str(); - } + assert(Kind != UWTableKind::None && "uwtable attribute should not be none"); + return Kind == UWTableKind::Default ? "uwtable" : "uwtable(sync)"; } if (hasAttribute(Attribute::AllocKind)) { |