1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

[FIX] Avoid creating BFI when emitting remarks for dead functions

Dead function has its body stripped away, and can cause various
analyses to panic. Also it does not make sense to apply analyses on
such function.

Reviewed By: xazax.hun, MaskRay, wenlei, hoy

Differential Revision: https://reviews.llvm.org/D84715
This commit is contained in:
Wei Wang 2020-08-25 10:42:54 -07:00 committed by Hongtao Yu
parent 2e2d347c2e
commit 7dabc836ba
2 changed files with 3 additions and 2 deletions

View File

@ -798,7 +798,7 @@ Error LTO::linkRegularLTO(RegularLTOState::AddedModule Mod,
for (GlobalValue *GV : Mod.Keep) { for (GlobalValue *GV : Mod.Keep) {
if (LivenessFromIndex && !ThinLTO.CombinedIndex.isGUIDLive(GV->getGUID())) { if (LivenessFromIndex && !ThinLTO.CombinedIndex.isGUIDLive(GV->getGUID())) {
if (Function *F = dyn_cast<Function>(GV)) { if (Function *F = dyn_cast<Function>(GV)) {
OptimizationRemarkEmitter ORE(F); OptimizationRemarkEmitter ORE(F, nullptr);
ORE.emit(OptimizationRemark(DEBUG_TYPE, "deadfunction", F) ORE.emit(OptimizationRemark(DEBUG_TYPE, "deadfunction", F)
<< ore::NV("Function", F) << ore::NV("Function", F)
<< " not added to the combined module "); << " not added to the combined module ");

View File

@ -1,7 +1,8 @@
; RUN: opt -module-summary -o %t %s ; RUN: opt -module-summary -o %t %s
; RUN: opt -module-summary -o %t2 %S/Inputs/dead-strip-fulllto.ll ; RUN: opt -module-summary -o %t2 %S/Inputs/dead-strip-fulllto.ll
; RUN: llvm-lto2 run --pass-remarks-output=%t4.yaml --pass-remarks-filter=. \ ; Adding '--pass-remarks-with-hotness' should not cause crash.
; RUN: llvm-lto2 run --pass-remarks-output=%t4.yaml --pass-remarks-filter=. --pass-remarks-with-hotness \
; RUN: %t -r %t,main,px -r %t,live1, -r %t,live2,p -r %t,dead2,p \ ; RUN: %t -r %t,main,px -r %t,live1, -r %t,live2,p -r %t,dead2,p \
; RUN: %t2 -r %t2,live1,p -r %t2,live2, -r %t2,dead1,p -r %t2,dead2, -r %t2,odr, \ ; RUN: %t2 -r %t2,live1,p -r %t2,live2, -r %t2,dead1,p -r %t2,dead2, -r %t2,odr, \
; RUN: -save-temps -o %t3 ; RUN: -save-temps -o %t3