-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
[SPARC] Fix regression from UpgradeDataLayoutString change #110608
Conversation
It turns out that we cannot rely on the presence of `i64:64` as an "anchor" when adding the `-i128:128` string due to tools that generate custom datalayout strings (e.g bugpoint, among other things). Revert to the generic regex matcher to make sure that we can still add the i128 string in all other cases. This fixes the regression introduced in llvm#106951.
@llvm/pr-subscribers-llvm-ir Author: Koakuma (koachan) ChangesIt turns out that we cannot rely on the presence of This fixes the regression introduced in #106951. Full diff: https://github.com/llvm/llvm-project/pull/110608.diff 1 Files Affected:
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 6f833acd6dbc0d..76c8a6db533465 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -5519,12 +5519,12 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) {
if (T.isSPARC()) {
// Add "-i128:128"
- std::string I64 = "-i64:64";
std::string I128 = "-i128:128";
if (!StringRef(Res).contains(I128)) {
- size_t Pos = Res.find(I64);
- assert(Pos != size_t(-1) && "no i64 data layout found!");
- Res.insert(Pos + I64.size(), I128);
+ SmallVector<StringRef, 4> Groups;
+ Regex R("^([Ee](-[mpi][^-]*)*)((-[^mpi][^-]*)*)$");
+ if (R.match(Res, &Groups))
+ Res = (Groups[1] + I128 + Groups[3]).str();
}
return Res;
}
|
Confirmed: with this patch, |
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.
Wouldn't it be enough to drop the assertion?
If the datalayout is already "incorrect" to the point that it does not have i64 alignment, it probably doesn't make sense to add i128 alignment?
Hmm, yeah, turning the assert into an if seem to work too. I guess it's better like this. |
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
It turns out that we cannot rely on the presence of `-i64:64` as a position reference when adding the `-i128:128` datalayout string due to some custom datalayout strings lacking it (e.g ones used by bugpoint, among other things). Do not add the `-i128:128` string in that case. This fixes the regression introduced in llvm#106951.
It turns out that we cannot rely on the presence of
-i64:64
as a position reference when adding the-i128:128
datalayout string due to some custom datalayout strings lacking it (e.g ones used by bugpoint, among other things).Do not add the
-i128:128
string in that case.This fixes the regression introduced in #106951.