[SPARC] Fix regression from UpgradeDataLayoutString change#110608
[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, |
nikic
left a comment
There was a problem hiding this comment.
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. |
It turns out that we cannot rely on the presence of
-i64:64as a position reference when adding the-i128:128datalayout string due to some custom datalayout strings lacking it (e.g ones used by bugpoint, among other things).Do not add the
-i128:128string in that case.This fixes the regression introduced in #106951.