diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp --- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp @@ -42,7 +42,7 @@ template void TestAllForms() { Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType)); - if (!isConfigurationSupported(Triple)) + if (!isObjectEmissionSupported(Triple)) return; // Test that we can decode all DW_FORM values correctly. @@ -456,7 +456,7 @@ template void TestChildren() { Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType)); - if (!isConfigurationSupported(Triple)) + if (!isObjectEmissionSupported(Triple)) return; // Test that we can decode DW_FORM_ref_addr values correctly in DWARF 2 with @@ -586,7 +586,7 @@ template void TestReferences() { Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType)); - if (!isConfigurationSupported(Triple)) + if (!isObjectEmissionSupported(Triple)) return; // Test that we can decode DW_FORM_refXXX values correctly in DWARF. @@ -836,7 +836,7 @@ template void TestAddresses() { Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType)); - if (!isConfigurationSupported(Triple)) + if (!isObjectEmissionSupported(Triple)) return; // Test the DWARF APIs related to accessing the DW_AT_low_pc and @@ -1008,7 +1008,7 @@ TEST(DWARFDebugInfo, TestStringOffsets) { Triple Triple = getNormalizedDefaultTargetTriple(); - if (!isConfigurationSupported(Triple)) + if (!isObjectEmissionSupported(Triple)) return; const char *String1 = "Hello"; @@ -1072,7 +1072,7 @@ TEST(DWARFDebugInfo, TestEmptyStringOffsets) { Triple Triple = getNormalizedDefaultTargetTriple(); - if (!isConfigurationSupported(Triple)) + if (!isObjectEmissionSupported(Triple)) return; const char *String1 = "Hello"; @@ -1101,7 +1101,7 @@ TEST(DWARFDebugInfo, TestRelations) { Triple Triple = getNormalizedDefaultTargetTriple(); - if (!isConfigurationSupported(Triple)) + if (!isObjectEmissionSupported(Triple)) return; // Test the DWARF APIs related to accessing the DW_AT_low_pc and @@ -1288,7 +1288,7 @@ TEST(DWARFDebugInfo, TestChildIterators) { Triple Triple = getNormalizedDefaultTargetTriple(); - if (!isConfigurationSupported(Triple)) + if (!isObjectEmissionSupported(Triple)) return; // Test the DWARF APIs related to iterating across the children of a DIE using @@ -1397,7 +1397,7 @@ TEST(DWARFDebugInfo, TestAttributeIterators) { Triple Triple = getNormalizedDefaultTargetTriple(); - if (!isConfigurationSupported(Triple)) + if (!isObjectEmissionSupported(Triple)) return; // Test the DWARF APIs related to iterating across all attribute values in a @@ -1459,7 +1459,7 @@ TEST(DWARFDebugInfo, TestFindRecurse) { Triple Triple = getNormalizedDefaultTargetTriple(); - if (!isConfigurationSupported(Triple)) + if (!isObjectEmissionSupported(Triple)) return; uint16_t Version = 4; @@ -1673,7 +1673,7 @@ TEST(DWARFDebugInfo, TestFindAttrs) { Triple Triple = getNormalizedDefaultTargetTriple(); - if (!isConfigurationSupported(Triple)) + if (!isObjectEmissionSupported(Triple)) return; // Test the DWARFDie::find() and DWARFDie::findRecursively() that take an @@ -1736,7 +1736,7 @@ TEST(DWARFDebugInfo, TestImplicitConstAbbrevs) { Triple Triple = getNormalizedDefaultTargetTriple(); - if (!isConfigurationSupported(Triple)) + if (!isObjectEmissionSupported(Triple)) return; uint16_t Version = 5; diff --git a/llvm/unittests/DebugInfo/DWARF/DwarfUtils.h b/llvm/unittests/DebugInfo/DWARF/DwarfUtils.h --- a/llvm/unittests/DebugInfo/DWARF/DwarfUtils.h +++ b/llvm/unittests/DebugInfo/DWARF/DwarfUtils.h @@ -21,6 +21,7 @@ Triple getDefaultTargetTripleForAddrSize(uint8_t AddrSize); Triple getNormalizedDefaultTargetTriple(); bool isConfigurationSupported(Triple &T); +bool isObjectEmissionSupported(Triple &T); } // end namespace utils } // end namespace dwarf diff --git a/llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp b/llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp --- a/llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp @@ -52,3 +52,10 @@ std::string Err; return TargetRegistry::lookupTarget(T.getTriple(), Err); } + +bool llvm::dwarf::utils::isObjectEmissionSupported(Triple &T) { + initLLVMIfNeeded(); + std::string Err; + const Target *TheTarget = TargetRegistry::lookupTarget(T.getTriple(), Err); + return TheTarget && TheTarget->hasMCAsmBackend(); +}