[llvm] [WholeProgramDevirt] Add check for AvailableExternal and give up icall.branch.funnel (PR #143468)

Tianle Liu via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 18 21:39:00 PDT 2025


tianleliu wrote:

> Not sure what "skipped to save" means - do you mean "is dropped" (e.g. by the ElimAvailExtern pass)?

The "skip" is not in ElimAvailExtern but LowerTypeTestsModule::lower(). https://github.com/llvm/llvm-project/blob/9d491bc602c2d9730cb42fe25f0753471a3af389/llvm/lib/Transforms/IPO/LowerTypeTests.cpp#L2228
Logic is like this:
  for (GlobalObject &GO : M.global_objects()) {
    if (isa<GlobalVariable>(GO) && **GO.isDeclarationForLinker**())
      **continue;**
....
    auto *GTM = GlobalTypeMember::create(Alloc, &GO, IsJumpTableCanonical,
                                         IsExported, Types);
    **GlobalTypeMembers[&GO] = GTM;**
....
}
when GO.isDeclarationForLinker, it would "continue" and nothing would saved in GlobalTypeMembers[&GO].
So in https://github.com/llvm/llvm-project/blob/9d491bc602c2d9730cb42fe25f0753471a3af389/llvm/lib/Transforms/IPO/LowerTypeTests.cpp#L2330
GTM would be NULL and the NULL would be saved in https://github.com/llvm/llvm-project/blob/9d491bc602c2d9730cb42fe25f0753471a3af389/llvm/lib/Transforms/IPO/LowerTypeTests.cpp#L2387
which would lead crash in https://github.com/llvm/llvm-project/blob/9d491bc602c2d9730cb42fe25f0753471a3af389/llvm/lib/Transforms/IPO/LowerTypeTests.cpp#L2406C7-L2406C34

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


More information about the llvm-commits mailing list