[llvm] 4261406 - [JITLink] Error instead of asserting on unrecognized edge kinds.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 16 18:52:48 PDT 2022


Author: Lang Hames
Date: 2022-04-16T18:52:27-07:00
New Revision: 42614062e21d05f94db878e9cd120e518c50633c

URL: https://github.com/llvm/llvm-project/commit/42614062e21d05f94db878e9cd120e518c50633c
DIFF: https://github.com/llvm/llvm-project/commit/42614062e21d05f94db878e9cd120e518c50633c.diff

LOG: [JITLink] Error instead of asserting on unrecognized edge kinds.

It's idiomatic to require that plugins (especially platform plugins) be
installed to handle special edge kinds. If the plugins are not installed and an
object is loaded that uses one of the special edge kinds then we want to error
out rather than asserting.

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h
    llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h b/llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h
index 4a4e8d15be664..9a2bc9b09350e 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h
@@ -447,11 +447,10 @@ inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E,
     break;
   }
 
-  default: {
-    // If you hit this you should check that *constructor and other non-fixup
-    // edges have been removed prior to applying fixups.
-    llvm_unreachable("Graph contains edge kind with no fixup expression");
-  }
+  default:
+    return make_error<JITLinkError>(
+        "In graph " + G.getName() + ", section " + B.getSection().getName() +
+        "unsupported edge kind" + getEdgeKindName(E.getKind()));
   }
 
   return Error::success();

diff  --git a/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp b/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
index 873c820e5be49..ed59aa4be9687 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
@@ -677,7 +677,10 @@ class MachOJITLinker_arm64 : public JITLinker<MachOJITLinker_arm64> {
       break;
     }
     default:
-      llvm_unreachable("Unrecognized edge kind");
+      return make_error<JITLinkError>(
+          "In graph " + G.getName() + ", section " + B.getSection().getName() +
+          "unsupported edge kind" +
+          getMachOARM64RelocationKindName(E.getKind()));
     }
 
     return Error::success();


        


More information about the llvm-commits mailing list