@@ -48,16 +48,20 @@ class OrcCAPITestBase : public testing::Test {
48
48
return ;
49
49
}
50
50
51
- char *Triple = LLVMOrcJITTargetMachineBuilderGetTargetTriple (JTMB);
52
- if (!isSupported (Triple)) {
51
+ // Capture the target triple. We'll use it for both verification that
52
+ // this target is *supposed* to be supported, and error messages in
53
+ // the case that it fails anyway.
54
+ char *TT = LLVMOrcJITTargetMachineBuilderGetTargetTriple (JTMB);
55
+ TargetTriple = TT;
56
+ LLVMOrcJITTargetMachineBuilderDisposeTargetTriple (JTMB, TT);
57
+
58
+ if (!isSupported (TargetTriple)) {
53
59
// If this triple isn't supported then bail out.
54
60
TargetSupported = false ;
55
- LLVMOrcJITTargetMachineBuilderDisposeTargetTriple (JTMB, Triple);
56
61
LLVMOrcDisposeJITTargetMachineBuilder (JTMB);
57
62
return ;
58
63
}
59
64
60
- LLVMOrcJITTargetMachineBuilderDisposeTargetTriple (JTMB, Triple);
61
65
LLVMOrcLLJITBuilderRef Builder = LLVMOrcCreateLLJITBuilder ();
62
66
LLVMOrcLLJITBuilderSetJITTargetMachineBuilder (Builder, JTMB);
63
67
LLVMOrcLLJITRef J;
@@ -149,9 +153,11 @@ class OrcCAPITestBase : public testing::Test {
149
153
return TSM;
150
154
}
151
155
156
+ static std::string TargetTriple;
152
157
static bool TargetSupported;
153
158
};
154
159
160
+ std::string OrcCAPITestBase::TargetTriple;
155
161
bool OrcCAPITestBase::TargetSupported = false ;
156
162
157
163
TEST_F (OrcCAPITestBase, SymbolStringPoolUniquing) {
@@ -208,7 +214,8 @@ TEST_F(OrcCAPITestBase, MaterializationUnitCreation) {
208
214
LLVMOrcJITDylibDefine (MainDylib, MU);
209
215
LLVMOrcJITTargetAddress OutAddr;
210
216
if (LLVMOrcLLJITLookup (Jit, &OutAddr, " test" )) {
211
- FAIL () << " Failed to look up \" test\" symbol" ;
217
+ FAIL () << " Failed to look up \" test\" symbol (triple = "
218
+ << TargetTriple << " )" ;
212
219
}
213
220
ASSERT_EQ (Addr, OutAddr);
214
221
}
@@ -225,7 +232,8 @@ TEST_F(OrcCAPITestBase, DefinitionGenerators) {
225
232
LLVMOrcJITDylibAddGenerator (MainDylib, Gen);
226
233
LLVMOrcJITTargetAddress OutAddr;
227
234
if (LLVMOrcLLJITLookup (Jit, &OutAddr, " test" )) {
228
- FAIL () << " The DefinitionGenerator did not create symbol \" test\" " ;
235
+ FAIL () << " The DefinitionGenerator did not create symbol \" test\" "
236
+ << " (triple = " << TargetTriple << " )" ;
229
237
}
230
238
LLVMOrcJITTargetAddress ExpectedAddr =
231
239
(LLVMOrcJITTargetAddress)(&materializationUnitFn);
@@ -245,11 +253,13 @@ TEST_F(OrcCAPITestBase, ResourceTrackerDefinitionLifetime) {
245
253
LLVMOrcJITDylibCreateResourceTracker (MainDylib);
246
254
LLVMOrcThreadSafeModuleRef TSM = createTestModule ();
247
255
if (LLVMErrorRef E = LLVMOrcLLJITAddLLVMIRModuleWithRT (Jit, RT, TSM)) {
248
- FAIL () << " Failed to add LLVM IR module to LLJIT" ;
256
+ FAIL () << " Failed to add LLVM IR module to LLJIT (triple = "
257
+ << TargetTriple << " )" ;
249
258
}
250
259
LLVMOrcJITTargetAddress TestFnAddr;
251
260
if (LLVMOrcLLJITLookup (Jit, &TestFnAddr, " sum" )) {
252
- FAIL () << " Symbol \" sum\" was not added into JIT" ;
261
+ FAIL () << " Symbol \" sum\" was not added into JIT (triple = "
262
+ << TargetTriple << " )" ;
253
263
}
254
264
ASSERT_TRUE (!!TestFnAddr);
255
265
LLVMOrcResourceTrackerRemove (RT);
@@ -273,11 +283,13 @@ TEST_F(OrcCAPITestBase, ResourceTrackerTransfer) {
273
283
LLVMOrcJITDylibCreateResourceTracker (MainDylib);
274
284
LLVMOrcThreadSafeModuleRef TSM = createTestModule ();
275
285
if (LLVMErrorRef E = LLVMOrcLLJITAddLLVMIRModuleWithRT (Jit, DefaultRT, TSM)) {
276
- FAIL () << " Failed to add LLVM IR module to LLJIT" ;
286
+ FAIL () << " Failed to add LLVM IR module to LLJIT (triple = "
287
+ << TargetTriple << " )" ;
277
288
}
278
289
LLVMOrcJITTargetAddress Addr;
279
290
if (LLVMOrcLLJITLookup (Jit, &Addr, " sum" )) {
280
- FAIL () << " Symbol \" sum\" was not added into JIT" ;
291
+ FAIL () << " Symbol \" sum\" was not added into JIT (triple = "
292
+ << TargetTriple << " )" ;
281
293
}
282
294
LLVMOrcResourceTrackerTransferTo (DefaultRT, RT2);
283
295
LLVMErrorRef Err = LLVMOrcLLJITLookup (Jit, &Addr, " sum" );
@@ -298,12 +310,14 @@ TEST_F(OrcCAPITestBase, ExecutionTest) {
298
310
LLVMOrcThreadSafeModuleRef TSM = createTestModule ();
299
311
if (LLVMErrorRef E = LLVMOrcLLJITAddLLVMIRModule (Jit, MainDylib, TSM)) {
300
312
LLVMConsumeError (E);
301
- FAIL () << " Failed to add LLVM IR module to LLJIT" ;
313
+ FAIL () << " Failed to add LLVM IR module to LLJIT (triple = "
314
+ << TargetTriple << " )" ;
302
315
}
303
316
LLVMOrcJITTargetAddress TestFnAddr;
304
317
if (LLVMErrorRef E = LLVMOrcLLJITLookup (Jit, &TestFnAddr, " sum" )) {
305
318
LLVMConsumeError (E);
306
- FAIL () << " Symbol \" sum\" was not added into JIT" ;
319
+ FAIL () << " Symbol \" sum\" was not added into JIT (triple = "
320
+ << TargetTriple << " )" ;
307
321
}
308
322
auto *SumFn = (SumFunctionType)(TestFnAddr);
309
323
int32_t Result = SumFn (1 , 1 );
0 commit comments