[llvm] [SPARC] Fix regression from UpgradeDataLayoutString change (PR #110608)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 30 17:49:21 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Koakuma (koachan)
<details>
<summary>Changes</summary>
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).
Revert to the generic regex matcher to make sure that we can still add the i128 string in those cases.
This fixes the regression introduced in https://github.com/llvm/llvm-project/pull/106951.
---
Full diff: https://github.com/llvm/llvm-project/pull/110608.diff
1 Files Affected:
- (modified) llvm/lib/IR/AutoUpgrade.cpp (+4-4)
``````````diff
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;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/110608
More information about the llvm-commits
mailing list