Index: llvm/lib/IR/Globals.cpp =================================================================== --- llvm/lib/IR/Globals.cpp +++ llvm/lib/IR/Globals.cpp @@ -444,6 +444,8 @@ findBaseObject(const Constant *C, DenseSet &Aliases) { if (auto *GO = dyn_cast(C)) return GO; + if (auto *GI = dyn_cast(C)) + return findBaseObject(GI->getOperand(0), Aliases); if (auto *GA = dyn_cast(C)) if (Aliases.insert(GA).second) return findBaseObject(GA->getOperand(0), Aliases); Index: llvm/test/Bitcode/thinlto-summary-alias-ifunc.ll =================================================================== --- /dev/null +++ llvm/test/Bitcode/thinlto-summary-alias-ifunc.ll @@ -0,0 +1,19 @@ +; RUN: opt -module-summary %s -o - | llvm-bcanalyzer -dump | FileCheck %s + +; PR46340 +; Check that alias-to-ifunc is properly generated in the module summary. + +; CHECK: + +@bar = dso_local alias void (), void ()* @foo +@foo = dso_local ifunc void (), bitcast (i8* ()* @foo_ifunc to void ()*) + +define internal i8* @foo_ifunc() { + ret i8* bitcast (void ()* @foo_impl to i8*) +} + +define internal void @foo_impl() { + ret void +}