Skip to content

Commit

Permalink
[unittest][DebugInfo/DWARF] Do not create dwarfgen::Generator if MCAs…
Browse files Browse the repository at this point in the history
…mBackend is missing

dwarfgen::Generator cannot be created if there is no asm backend for a
target. For example, if the default target triple is nvptx-nvidia-cuda,
some tests fail even after D98400, which added checks for most cases.
This patch extends the approach to the remaining cases.

Differential Revision: https://reviews.llvm.org/D116107
  • Loading branch information
igorkudrin committed Dec 22, 2021
1 parent 5fc05a0 commit 2e11e88
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
24 changes: 12 additions & 12 deletions llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
Expand Up @@ -43,7 +43,7 @@ namespace {
template <uint16_t Version, class AddrType, class RefAddrType>
void TestAllForms() {
Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType));
if (!isObjectEmissionSupported(Triple))
if (!isConfigurationSupported(Triple))
return;

// Test that we can decode all DW_FORM values correctly.
Expand Down Expand Up @@ -477,7 +477,7 @@ TEST(DWARFDebugInfo, TestDWARF32Version5Addr8AllForms) {

template <uint16_t Version, class AddrType> void TestChildren() {
Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType));
if (!isObjectEmissionSupported(Triple))
if (!isConfigurationSupported(Triple))
return;

// Test that we can decode DW_FORM_ref_addr values correctly in DWARF 2 with
Expand Down Expand Up @@ -619,7 +619,7 @@ TEST(DWARFDebugInfo, TestDWARF32Version4Addr8Children) {

template <uint16_t Version, class AddrType> void TestReferences() {
Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType));
if (!isObjectEmissionSupported(Triple))
if (!isConfigurationSupported(Triple))
return;

// Test that we can decode DW_FORM_refXXX values correctly in DWARF.
Expand Down Expand Up @@ -881,7 +881,7 @@ TEST(DWARFDebugInfo, TestDWARF32Version4Addr8References) {

template <uint16_t Version, class AddrType> void TestAddresses() {
Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType));
if (!isObjectEmissionSupported(Triple))
if (!isConfigurationSupported(Triple))
return;

// Test the DWARF APIs related to accessing the DW_AT_low_pc and
Expand Down Expand Up @@ -1069,7 +1069,7 @@ TEST(DWARFDebugInfo, DISABLED_TestStringOffsets) {
TEST(DWARFDebugInfo, TestStringOffsets) {
#endif
Triple Triple = getNormalizedDefaultTargetTriple();
if (!isObjectEmissionSupported(Triple))
if (!isConfigurationSupported(Triple))
return;

const char *String1 = "Hello";
Expand Down Expand Up @@ -1133,7 +1133,7 @@ TEST(DWARFDebugInfo, TestStringOffsets) {

TEST(DWARFDebugInfo, TestEmptyStringOffsets) {
Triple Triple = getNormalizedDefaultTargetTriple();
if (!isObjectEmissionSupported(Triple))
if (!isConfigurationSupported(Triple))
return;

const char *String1 = "Hello";
Expand Down Expand Up @@ -1162,7 +1162,7 @@ TEST(DWARFDebugInfo, TestEmptyStringOffsets) {

TEST(DWARFDebugInfo, TestRelations) {
Triple Triple = getNormalizedDefaultTargetTriple();
if (!isObjectEmissionSupported(Triple))
if (!isConfigurationSupported(Triple))
return;

// Test the DWARF APIs related to accessing the DW_AT_low_pc and
Expand Down Expand Up @@ -1349,7 +1349,7 @@ TEST(DWARFDebugInfo, TestDWARFDie) {

TEST(DWARFDebugInfo, TestChildIterators) {
Triple Triple = getNormalizedDefaultTargetTriple();
if (!isObjectEmissionSupported(Triple))
if (!isConfigurationSupported(Triple))
return;

// Test the DWARF APIs related to iterating across the children of a DIE using
Expand Down Expand Up @@ -1458,7 +1458,7 @@ TEST(DWARFDebugInfo, TestEmptyChildren) {

TEST(DWARFDebugInfo, TestAttributeIterators) {
Triple Triple = getNormalizedDefaultTargetTriple();
if (!isObjectEmissionSupported(Triple))
if (!isConfigurationSupported(Triple))
return;

// Test the DWARF APIs related to iterating across all attribute values in a
Expand Down Expand Up @@ -1520,7 +1520,7 @@ TEST(DWARFDebugInfo, TestAttributeIterators) {

TEST(DWARFDebugInfo, TestFindRecurse) {
Triple Triple = getNormalizedDefaultTargetTriple();
if (!isObjectEmissionSupported(Triple))
if (!isConfigurationSupported(Triple))
return;

uint16_t Version = 4;
Expand Down Expand Up @@ -1734,7 +1734,7 @@ TEST(DWARFDebugInfo, TestDwarfToFunctions) {

TEST(DWARFDebugInfo, TestFindAttrs) {
Triple Triple = getNormalizedDefaultTargetTriple();
if (!isObjectEmissionSupported(Triple))
if (!isConfigurationSupported(Triple))
return;

// Test the DWARFDie::find() and DWARFDie::findRecursively() that take an
Expand Down Expand Up @@ -1797,7 +1797,7 @@ TEST(DWARFDebugInfo, TestFindAttrs) {

TEST(DWARFDebugInfo, TestImplicitConstAbbrevs) {
Triple Triple = getNormalizedDefaultTargetTriple();
if (!isObjectEmissionSupported(Triple))
if (!isConfigurationSupported(Triple))
return;

uint16_t Version = 5;
Expand Down
Expand Up @@ -24,7 +24,7 @@ TEST(DWARFDie, manualExtractDump) {
typedef uint32_t AddrType;
uint16_t Version = 4;
Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType));
if (!isObjectEmissionSupported(Triple))
if (!isConfigurationSupported(Triple))
return;

auto ExpectedDG = dwarfgen::Generator::create(Triple, Version);
Expand Down
6 changes: 0 additions & 6 deletions llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp
Expand Up @@ -48,12 +48,6 @@ Triple llvm::dwarf::utils::getDefaultTargetTripleForAddrSize(uint8_t AddrSize) {
}

bool llvm::dwarf::utils::isConfigurationSupported(Triple &T) {
initLLVMIfNeeded();
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);
Expand Down
1 change: 0 additions & 1 deletion llvm/unittests/DebugInfo/DWARF/DwarfUtils.h
Expand Up @@ -21,7 +21,6 @@ namespace utils {
Triple getDefaultTargetTripleForAddrSize(uint8_t AddrSize);
Triple getNormalizedDefaultTargetTriple();
bool isConfigurationSupported(Triple &T);
bool isObjectEmissionSupported(Triple &T);

} // end namespace utils
} // end namespace dwarf
Expand Down

0 comments on commit 2e11e88

Please sign in to comment.