[llvm] 2e11e88 - [unittest][DebugInfo/DWARF] Do not create dwarfgen::Generator if MCAsmBackend is missing

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 22 03:54:17 PST 2021


Author: Igor Kudrin
Date: 2021-12-22T18:52:43+07:00
New Revision: 2e11e8885c68f7ec6e1f2699a9461708d29ec4df

URL: https://github.com/llvm/llvm-project/commit/2e11e8885c68f7ec6e1f2699a9461708d29ec4df
DIFF: https://github.com/llvm/llvm-project/commit/2e11e8885c68f7ec6e1f2699a9461708d29ec4df.diff

LOG: [unittest][DebugInfo/DWARF] Do not create dwarfgen::Generator if MCAsmBackend 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

Added: 
    

Modified: 
    llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
    llvm/unittests/DebugInfo/DWARF/DWARFDieManualExtractTest.cpp
    llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp
    llvm/unittests/DebugInfo/DWARF/DwarfUtils.h

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
index 68d06003a5e5..44f438e91f99 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -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.
@@ -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
@@ -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.
@@ -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
@@ -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";
@@ -1133,7 +1133,7 @@ TEST(DWARFDebugInfo, TestStringOffsets) {
 
 TEST(DWARFDebugInfo, TestEmptyStringOffsets) {
   Triple Triple = getNormalizedDefaultTargetTriple();
-  if (!isObjectEmissionSupported(Triple))
+  if (!isConfigurationSupported(Triple))
     return;
 
   const char *String1 = "Hello";
@@ -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
@@ -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
@@ -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
@@ -1520,7 +1520,7 @@ TEST(DWARFDebugInfo, TestAttributeIterators) {
 
 TEST(DWARFDebugInfo, TestFindRecurse) {
   Triple Triple = getNormalizedDefaultTargetTriple();
-  if (!isObjectEmissionSupported(Triple))
+  if (!isConfigurationSupported(Triple))
     return;
 
   uint16_t Version = 4;
@@ -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
@@ -1797,7 +1797,7 @@ TEST(DWARFDebugInfo, TestFindAttrs) {
 
 TEST(DWARFDebugInfo, TestImplicitConstAbbrevs) {
   Triple Triple = getNormalizedDefaultTargetTriple();
-  if (!isObjectEmissionSupported(Triple))
+  if (!isConfigurationSupported(Triple))
     return;
 
   uint16_t Version = 5;

diff  --git a/llvm/unittests/DebugInfo/DWARF/DWARFDieManualExtractTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDieManualExtractTest.cpp
index 2333fc619edb..fd5f138f7733 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDieManualExtractTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDieManualExtractTest.cpp
@@ -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);

diff  --git a/llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp b/llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp
index e337f34d1972..9a4a794b4451 100644
--- a/llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp
@@ -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);

diff  --git a/llvm/unittests/DebugInfo/DWARF/DwarfUtils.h b/llvm/unittests/DebugInfo/DWARF/DwarfUtils.h
index 00eaef25cfba..036071e0b567 100644
--- a/llvm/unittests/DebugInfo/DWARF/DwarfUtils.h
+++ b/llvm/unittests/DebugInfo/DWARF/DwarfUtils.h
@@ -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


        


More information about the llvm-commits mailing list