@@ -90,6 +90,35 @@ class OrcCAPITestBase : public testing::Test {
9090
9191 LLVMOrcDisposeLLJIT (J);
9292 TargetSupported = true ;
93+
94+ // Create test functions in text format, with the proper extension
95+ // attributes.
96+ if (SumExample.empty ()) {
97+ std::string I32RetExt = " " ;
98+ std::string I32ArgExt = " " ;
99+ if (StringRef (TargetTriple).starts_with (" s390x-ibm-linux" ))
100+ I32RetExt = I32ArgExt = " signext " ;
101+
102+ std::ostringstream OS;
103+ OS << " define " << I32RetExt << " i32 "
104+ << R"( @sum()" << " i32 " << I32ArgExt << " %x, i32 " << I32ArgExt << " %y)"
105+ << R"( {
106+ entry:
107+ %r = add nsw i32 %x, %y
108+ ret i32 %r
109+ }
110+ )" ;
111+ SumExample = OS.str ();
112+
113+ OS << R"(
114+ !llvm.module.flags = !{!0}
115+ !llvm.dbg.cu = !{!1}
116+ !0 = !{i32 2, !"Debug Info Version", i32 3}
117+ !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, emissionKind: FullDebug)
118+ !2 = !DIFile(filename: "sum.c", directory: "/tmp")
119+ )" ;
120+ SumDebugExample = OS.str ();
121+ }
93122 }
94123
95124 void SetUp () override {
@@ -199,37 +228,17 @@ class OrcCAPITestBase : public testing::Test {
199228
200229 static std::string TargetTriple;
201230 static bool TargetSupported;
231+
232+ static std::string SumExample;
233+ static std::string SumDebugExample;
234+
202235};
203236
204237std::string OrcCAPITestBase::TargetTriple;
205238bool OrcCAPITestBase::TargetSupported = false ;
206239
207- namespace {
208-
209- constexpr StringRef SumExample =
210- R"(
211- define i32 @sum(i32 %x, i32 %y) {
212- entry:
213- %r = add nsw i32 %x, %y
214- ret i32 %r
215- }
216- )" ;
217-
218- constexpr StringRef SumDebugExample =
219- R"(
220- define i32 @sum(i32 %x, i32 %y) {
221- entry:
222- %r = add nsw i32 %x, %y
223- ret i32 %r
224- }
225- !llvm.module.flags = !{!0}
226- !llvm.dbg.cu = !{!1}
227- !0 = !{i32 2, !"Debug Info Version", i32 3}
228- !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, emissionKind: FullDebug)
229- !2 = !DIFile(filename: "sum.c", directory: "/tmp")
230- )" ;
231-
232- } // end anonymous namespace.
240+ std::string OrcCAPITestBase::SumExample;
241+ std::string OrcCAPITestBase::SumDebugExample;
233242
234243// Consumes the given error ref and returns the string error message.
235244static std::string toString (LLVMErrorRef E) {
0 commit comments