[llvm] [llubi] Add basic support for icmp, terminators and function calls (PR #181393)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 14 01:15:52 PST 2026


================
@@ -17,7 +17,29 @@ namespace llvm::ubi {
 
 Context::Context(Module &M)
     : Ctx(M.getContext()), M(M), DL(M.getDataLayout()),
-      TLIImpl(M.getTargetTriple()) {}
+      TLIImpl(M.getTargetTriple()) {
+  // Register all valid function and block targets.
+  for (Function &F : M) {
+    auto FuncObj = allocate(0, F.getPointerAlignment(DL).value(), F.getName(),
+                            DL.getProgramAddressSpace(), MemInitKind::Zeroed);
+    assert(FuncObj && "Failed to allocate memory for function object.");
+    ValidFuncTargets.try_emplace(FuncObj->getAddress(),
+                                 std::make_pair(&F, FuncObj));
+    FuncAddrMap.try_emplace(&F, deriveFromMemoryObject(FuncObj));
+
+    for (BasicBlock &BB : F) {
+      // The entry block is not an valid block target.
+      if (&BB == &F.getEntryBlock())
+        continue;
----------------
nikic wrote:

Should we limit this to blocks that are isAddressTaken()?

https://github.com/llvm/llvm-project/pull/181393


More information about the llvm-commits mailing list