From 4109bac3301eb7b7033eec3c8e8107be8cad9bc9 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 2 May 2025 09:40:50 +0200 Subject: [IR] Do not store Function inside BlockAddress (#137958) Currently BlockAddresses store both the Function and the BasicBlock they reference, and the BlockAddress is part of the use list of both the Function and BasicBlock. This is quite awkward, because this is not really a use of the function itself (and walks of function uses generally skip block addresses for that reason). This also has weird implications on function RAUW (as that will replace the function in block addresses in a way that generally doesn't make sense), and causes other peculiar issues, like the ability to have multiple block addresses for one block (with different functions). Instead, I believe it makes more sense to specify only the basic block and let the function be implied by the BB parent. This does mean that we may have block addresses without a function (if the BB is not inserted), but this should only happen during IR construction. --- clang/lib/CodeGen/CodeGenFunction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp') diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 4d29cea..d773cdd 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -2286,7 +2286,7 @@ llvm::BlockAddress *CodeGenFunction::GetAddrOfLabel(const LabelDecl *L) { // Make sure the indirect branch includes all of the address-taken blocks. IndirectBranch->addDestination(BB); - return llvm::BlockAddress::get(CurFn, BB); + return llvm::BlockAddress::get(CurFn->getType(), BB); } llvm::BasicBlock *CodeGenFunction::GetIndirectGotoBlock() { -- cgit v1.1