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 @@ -44,6 +44,8 @@ Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType)); if (!isConfigurationSupported(Triple)) return; + if (!supportsObjectEmission(Triple)) + return; // Test that we can decode all DW_FORM values correctly. const AddrType AddrValue = (AddrType)0x0123456789abcdefULL; @@ -458,6 +460,8 @@ Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType)); if (!isConfigurationSupported(Triple)) return; + if (!supportsObjectEmission(Triple)) + return; // Test that we can decode DW_FORM_ref_addr values correctly in DWARF 2 with // 4 byte addresses. DW_FORM_ref_addr values should be 4 bytes when using @@ -588,6 +592,8 @@ Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType)); if (!isConfigurationSupported(Triple)) return; + if (!supportsObjectEmission(Triple)) + return; // Test that we can decode DW_FORM_refXXX values correctly in DWARF. auto ExpectedDG = dwarfgen::Generator::create(Triple, Version); @@ -838,6 +844,8 @@ Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType)); if (!isConfigurationSupported(Triple)) return; + if (!supportsObjectEmission(Triple)) + return; // Test the DWARF APIs related to accessing the DW_AT_low_pc and // DW_AT_high_pc. @@ -1010,6 +1018,8 @@ Triple Triple = getNormalizedDefaultTargetTriple(); if (!isConfigurationSupported(Triple)) return; + if (!supportsObjectEmission(Triple)) + return; const char *String1 = "Hello"; const char *String2 = "World"; @@ -1074,6 +1084,8 @@ Triple Triple = getNormalizedDefaultTargetTriple(); if (!isConfigurationSupported(Triple)) return; + if (!supportsObjectEmission(Triple)) + return; const char *String1 = "Hello"; @@ -1103,6 +1115,8 @@ Triple Triple = getNormalizedDefaultTargetTriple(); if (!isConfigurationSupported(Triple)) return; + if (!supportsObjectEmission(Triple)) + return; // Test the DWARF APIs related to accessing the DW_AT_low_pc and // DW_AT_high_pc. @@ -1290,6 +1304,8 @@ Triple Triple = getNormalizedDefaultTargetTriple(); if (!isConfigurationSupported(Triple)) return; + if (!supportsObjectEmission(Triple)) + return; // Test the DWARF APIs related to iterating across the children of a DIE using // the DWARFDie::iterator class. @@ -1399,6 +1415,8 @@ Triple Triple = getNormalizedDefaultTargetTriple(); if (!isConfigurationSupported(Triple)) return; + if (!supportsObjectEmission(Triple)) + return; // Test the DWARF APIs related to iterating across all attribute values in a // a DWARFDie. @@ -1461,6 +1479,8 @@ Triple Triple = getNormalizedDefaultTargetTriple(); if (!isConfigurationSupported(Triple)) return; + if (!supportsObjectEmission(Triple)) + return; uint16_t Version = 4; auto ExpectedDG = dwarfgen::Generator::create(Triple, Version); @@ -1675,6 +1695,8 @@ Triple Triple = getNormalizedDefaultTargetTriple(); if (!isConfigurationSupported(Triple)) return; + if (!supportsObjectEmission(Triple)) + return; // Test the DWARFDie::find() and DWARFDie::findRecursively() that take an // ArrayRef value to make sure they work correctly. @@ -1738,6 +1760,8 @@ Triple Triple = getNormalizedDefaultTargetTriple(); if (!isConfigurationSupported(Triple)) return; + if (!supportsObjectEmission(Triple)) + return; uint16_t Version = 5; auto ExpectedDG = dwarfgen::Generator::create(Triple, Version); 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 supportsObjectEmission(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::supportsObjectEmission(Triple &T) { + std::string ErrorStr; + std::string TripleName; + const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, T, ErrorStr); + return TheTarget->hasMCAsmBackend(); +}