forked from OSchip/llvm-project
[ORC] Record target triple in C API testcase, print it on failure.
This will simplify identification of unsupported triples when we see builder failures in this test case.
This commit is contained in:
parent
0bef55738e
commit
7fe11894e2
|
@ -48,16 +48,20 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *Triple = LLVMOrcJITTargetMachineBuilderGetTargetTriple(JTMB);
|
// Capture the target triple. We'll use it for both verification that
|
||||||
if (!isSupported(Triple)) {
|
// this target is *supposed* to be supported, and error messages in
|
||||||
|
// the case that it fails anyway.
|
||||||
|
char *TT = LLVMOrcJITTargetMachineBuilderGetTargetTriple(JTMB);
|
||||||
|
TargetTriple = TT;
|
||||||
|
LLVMOrcJITTargetMachineBuilderDisposeTargetTriple(JTMB, TT);
|
||||||
|
|
||||||
|
if (!isSupported(TargetTriple)) {
|
||||||
// If this triple isn't supported then bail out.
|
// If this triple isn't supported then bail out.
|
||||||
TargetSupported = false;
|
TargetSupported = false;
|
||||||
LLVMOrcJITTargetMachineBuilderDisposeTargetTriple(JTMB, Triple);
|
|
||||||
LLVMOrcDisposeJITTargetMachineBuilder(JTMB);
|
LLVMOrcDisposeJITTargetMachineBuilder(JTMB);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMOrcJITTargetMachineBuilderDisposeTargetTriple(JTMB, Triple);
|
|
||||||
LLVMOrcLLJITBuilderRef Builder = LLVMOrcCreateLLJITBuilder();
|
LLVMOrcLLJITBuilderRef Builder = LLVMOrcCreateLLJITBuilder();
|
||||||
LLVMOrcLLJITBuilderSetJITTargetMachineBuilder(Builder, JTMB);
|
LLVMOrcLLJITBuilderSetJITTargetMachineBuilder(Builder, JTMB);
|
||||||
LLVMOrcLLJITRef J;
|
LLVMOrcLLJITRef J;
|
||||||
|
@ -149,9 +153,11 @@ protected:
|
||||||
return TSM;
|
return TSM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string TargetTriple;
|
||||||
static bool TargetSupported;
|
static bool TargetSupported;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::string OrcCAPITestBase::TargetTriple;
|
||||||
bool OrcCAPITestBase::TargetSupported = false;
|
bool OrcCAPITestBase::TargetSupported = false;
|
||||||
|
|
||||||
TEST_F(OrcCAPITestBase, SymbolStringPoolUniquing) {
|
TEST_F(OrcCAPITestBase, SymbolStringPoolUniquing) {
|
||||||
|
@ -208,7 +214,8 @@ TEST_F(OrcCAPITestBase, MaterializationUnitCreation) {
|
||||||
LLVMOrcJITDylibDefine(MainDylib, MU);
|
LLVMOrcJITDylibDefine(MainDylib, MU);
|
||||||
LLVMOrcJITTargetAddress OutAddr;
|
LLVMOrcJITTargetAddress OutAddr;
|
||||||
if (LLVMOrcLLJITLookup(Jit, &OutAddr, "test")) {
|
if (LLVMOrcLLJITLookup(Jit, &OutAddr, "test")) {
|
||||||
FAIL() << "Failed to look up \"test\" symbol";
|
FAIL() << "Failed to look up \"test\" symbol (triple = "
|
||||||
|
<< TargetTriple << ")";
|
||||||
}
|
}
|
||||||
ASSERT_EQ(Addr, OutAddr);
|
ASSERT_EQ(Addr, OutAddr);
|
||||||
}
|
}
|
||||||
|
@ -225,7 +232,8 @@ TEST_F(OrcCAPITestBase, DefinitionGenerators) {
|
||||||
LLVMOrcJITDylibAddGenerator(MainDylib, Gen);
|
LLVMOrcJITDylibAddGenerator(MainDylib, Gen);
|
||||||
LLVMOrcJITTargetAddress OutAddr;
|
LLVMOrcJITTargetAddress OutAddr;
|
||||||
if (LLVMOrcLLJITLookup(Jit, &OutAddr, "test")) {
|
if (LLVMOrcLLJITLookup(Jit, &OutAddr, "test")) {
|
||||||
FAIL() << "The DefinitionGenerator did not create symbol \"test\"";
|
FAIL() << "The DefinitionGenerator did not create symbol \"test\" "
|
||||||
|
<< "(triple = " << TargetTriple << ")";
|
||||||
}
|
}
|
||||||
LLVMOrcJITTargetAddress ExpectedAddr =
|
LLVMOrcJITTargetAddress ExpectedAddr =
|
||||||
(LLVMOrcJITTargetAddress)(&materializationUnitFn);
|
(LLVMOrcJITTargetAddress)(&materializationUnitFn);
|
||||||
|
@ -245,11 +253,13 @@ TEST_F(OrcCAPITestBase, ResourceTrackerDefinitionLifetime) {
|
||||||
LLVMOrcJITDylibCreateResourceTracker(MainDylib);
|
LLVMOrcJITDylibCreateResourceTracker(MainDylib);
|
||||||
LLVMOrcThreadSafeModuleRef TSM = createTestModule();
|
LLVMOrcThreadSafeModuleRef TSM = createTestModule();
|
||||||
if (LLVMErrorRef E = LLVMOrcLLJITAddLLVMIRModuleWithRT(Jit, RT, TSM)) {
|
if (LLVMErrorRef E = LLVMOrcLLJITAddLLVMIRModuleWithRT(Jit, RT, TSM)) {
|
||||||
FAIL() << "Failed to add LLVM IR module to LLJIT";
|
FAIL() << "Failed to add LLVM IR module to LLJIT (triple = "
|
||||||
|
<< TargetTriple << ")";
|
||||||
}
|
}
|
||||||
LLVMOrcJITTargetAddress TestFnAddr;
|
LLVMOrcJITTargetAddress TestFnAddr;
|
||||||
if (LLVMOrcLLJITLookup(Jit, &TestFnAddr, "sum")) {
|
if (LLVMOrcLLJITLookup(Jit, &TestFnAddr, "sum")) {
|
||||||
FAIL() << "Symbol \"sum\" was not added into JIT";
|
FAIL() << "Symbol \"sum\" was not added into JIT (triple = "
|
||||||
|
<< TargetTriple << ")";
|
||||||
}
|
}
|
||||||
ASSERT_TRUE(!!TestFnAddr);
|
ASSERT_TRUE(!!TestFnAddr);
|
||||||
LLVMOrcResourceTrackerRemove(RT);
|
LLVMOrcResourceTrackerRemove(RT);
|
||||||
|
@ -273,11 +283,13 @@ TEST_F(OrcCAPITestBase, ResourceTrackerTransfer) {
|
||||||
LLVMOrcJITDylibCreateResourceTracker(MainDylib);
|
LLVMOrcJITDylibCreateResourceTracker(MainDylib);
|
||||||
LLVMOrcThreadSafeModuleRef TSM = createTestModule();
|
LLVMOrcThreadSafeModuleRef TSM = createTestModule();
|
||||||
if (LLVMErrorRef E = LLVMOrcLLJITAddLLVMIRModuleWithRT(Jit, DefaultRT, TSM)) {
|
if (LLVMErrorRef E = LLVMOrcLLJITAddLLVMIRModuleWithRT(Jit, DefaultRT, TSM)) {
|
||||||
FAIL() << "Failed to add LLVM IR module to LLJIT";
|
FAIL() << "Failed to add LLVM IR module to LLJIT (triple = "
|
||||||
|
<< TargetTriple << ")";
|
||||||
}
|
}
|
||||||
LLVMOrcJITTargetAddress Addr;
|
LLVMOrcJITTargetAddress Addr;
|
||||||
if (LLVMOrcLLJITLookup(Jit, &Addr, "sum")) {
|
if (LLVMOrcLLJITLookup(Jit, &Addr, "sum")) {
|
||||||
FAIL() << "Symbol \"sum\" was not added into JIT";
|
FAIL() << "Symbol \"sum\" was not added into JIT (triple = "
|
||||||
|
<< TargetTriple << ")";
|
||||||
}
|
}
|
||||||
LLVMOrcResourceTrackerTransferTo(DefaultRT, RT2);
|
LLVMOrcResourceTrackerTransferTo(DefaultRT, RT2);
|
||||||
LLVMErrorRef Err = LLVMOrcLLJITLookup(Jit, &Addr, "sum");
|
LLVMErrorRef Err = LLVMOrcLLJITLookup(Jit, &Addr, "sum");
|
||||||
|
@ -298,12 +310,14 @@ TEST_F(OrcCAPITestBase, ExecutionTest) {
|
||||||
LLVMOrcThreadSafeModuleRef TSM = createTestModule();
|
LLVMOrcThreadSafeModuleRef TSM = createTestModule();
|
||||||
if (LLVMErrorRef E = LLVMOrcLLJITAddLLVMIRModule(Jit, MainDylib, TSM)) {
|
if (LLVMErrorRef E = LLVMOrcLLJITAddLLVMIRModule(Jit, MainDylib, TSM)) {
|
||||||
LLVMConsumeError(E);
|
LLVMConsumeError(E);
|
||||||
FAIL() << "Failed to add LLVM IR module to LLJIT";
|
FAIL() << "Failed to add LLVM IR module to LLJIT (triple = "
|
||||||
|
<< TargetTriple << ")";
|
||||||
}
|
}
|
||||||
LLVMOrcJITTargetAddress TestFnAddr;
|
LLVMOrcJITTargetAddress TestFnAddr;
|
||||||
if (LLVMErrorRef E = LLVMOrcLLJITLookup(Jit, &TestFnAddr, "sum")) {
|
if (LLVMErrorRef E = LLVMOrcLLJITLookup(Jit, &TestFnAddr, "sum")) {
|
||||||
LLVMConsumeError(E);
|
LLVMConsumeError(E);
|
||||||
FAIL() << "Symbol \"sum\" was not added into JIT";
|
FAIL() << "Symbol \"sum\" was not added into JIT (triple = "
|
||||||
|
<< TargetTriple << ")";
|
||||||
}
|
}
|
||||||
auto *SumFn = (SumFunctionType)(TestFnAddr);
|
auto *SumFn = (SumFunctionType)(TestFnAddr);
|
||||||
int32_t Result = SumFn(1, 1);
|
int32_t Result = SumFn(1, 1);
|
||||||
|
|
Loading…
Reference in New Issue