[llvm] [ORC] Add signext on @sum() arguments in test. (PR #113308)
Jonas Paulsson via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 22 05:41:39 PDT 2024
https://github.com/JonPsson1 created https://github.com/llvm/llvm-project/pull/113308
Use static std::strings for the textual representations of @sum(). The usage of static variables is already there, e.g. with TargetTriple, so I have assumed that this is thread-safe.
The TargetTriple is not the full Triple class, but just the string representation. If the complete version of this is needed, the full Triple is needed so that it can be passed to TargetLibraryInfo getExtAttrForI32Param/Return. For now, there is just a string recognition of s390 which does need the extensions. Maybe this is ok for now as this is just a test, after all..?
Fixes: #112503
>From 03be6d7f9a71402347e1152ec7bbfc7a140f3c1c Mon Sep 17 00:00:00 2001
From: Jonas Paulsson <paulson1 at linux.ibm.com>
Date: Tue, 22 Oct 2024 09:57:05 +0200
Subject: [PATCH] Add signext on @sum() arguments.
---
.../ExecutionEngine/Orc/OrcCAPITest.cpp | 61 +++++++++++--------
1 file changed, 35 insertions(+), 26 deletions(-)
diff --git a/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp b/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
index 4d67daf2def5bc..c50e36a8c23eb1 100644
--- a/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/OrcCAPITest.cpp
@@ -90,6 +90,35 @@ class OrcCAPITestBase : public testing::Test {
LLVMOrcDisposeLLJIT(J);
TargetSupported = true;
+
+ // Create test functions in text format, with the proper extension
+ // attributes.
+ if (SumExample.empty()) {
+ std::string I32RetExt = "";
+ std::string I32ArgExt = "";
+ if (StringRef(TargetTriple).starts_with("s390x-ibm-linux"))
+ I32RetExt = I32ArgExt = "signext ";
+
+ std::ostringstream OS;
+ OS << "define " << I32RetExt << " i32 "
+ << R"(@sum()" << "i32 " << I32ArgExt << "%x, i32 " << I32ArgExt << "%y)"
+ << R"( {
+ entry:
+ %r = add nsw i32 %x, %y
+ ret i32 %r
+ }
+ )";
+ SumExample = OS.str();
+
+ OS << R"(
+ !llvm.module.flags = !{!0}
+ !llvm.dbg.cu = !{!1}
+ !0 = !{i32 2, !"Debug Info Version", i32 3}
+ !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, emissionKind: FullDebug)
+ !2 = !DIFile(filename: "sum.c", directory: "/tmp")
+ )";
+ SumDebugExample = OS.str();
+ }
}
void SetUp() override {
@@ -199,37 +228,17 @@ class OrcCAPITestBase : public testing::Test {
static std::string TargetTriple;
static bool TargetSupported;
+
+ static std::string SumExample;
+ static std::string SumDebugExample;
+
};
std::string OrcCAPITestBase::TargetTriple;
bool OrcCAPITestBase::TargetSupported = false;
-namespace {
-
-constexpr StringRef SumExample =
- R"(
- define i32 @sum(i32 %x, i32 %y) {
- entry:
- %r = add nsw i32 %x, %y
- ret i32 %r
- }
- )";
-
-constexpr StringRef SumDebugExample =
- R"(
- define i32 @sum(i32 %x, i32 %y) {
- entry:
- %r = add nsw i32 %x, %y
- ret i32 %r
- }
- !llvm.module.flags = !{!0}
- !llvm.dbg.cu = !{!1}
- !0 = !{i32 2, !"Debug Info Version", i32 3}
- !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, emissionKind: FullDebug)
- !2 = !DIFile(filename: "sum.c", directory: "/tmp")
- )";
-
-} // end anonymous namespace.
+std::string OrcCAPITestBase::SumExample;
+std::string OrcCAPITestBase::SumDebugExample;
// Consumes the given error ref and returns the string error message.
static std::string toString(LLVMErrorRef E) {
More information about the llvm-commits
mailing list