From 8b5fba8081d1494b367671095c6d74d0a013694f Mon Sep 17 00:00:00 2001 From: Adam Nemet Date: Thu, 1 Dec 2016 17:34:44 +0000 Subject: [GVN, OptDiag] Include the value that is forwarded in load elimination [recommitting after the fix in r288307] This requires some changes to the opt-diag API. Hal and I have discussed this at the Dev Meeting and came up with a streaming delimiter (setExtraArgs) to solve this. Arguments after this delimiter are only included in the optimization records and not in the remarks printed in the compiler output. (Note, how in the test the content of the YAML file changes but the remarks on the compiler output don't.) This implements the green GVN message with a bug fix at line http://lab.llvm.org:8080/artifacts/opt-view_test-suite/build/SingleSource/Benchmarks/Dhrystone/CMakeFiles/dry.dir/html/_org_test-suite_SingleSource_Benchmarks_Dhrystone_dry.c.html#L446 The fix is that now we properly include the constant value in the message: "load of type i32 eliminated in favor of 7" Differential Revision: https://reviews.llvm.org/D26489 llvm-svn: 288380 --- llvm/lib/Transforms/Scalar/GVN.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 050cc2ecc89..9a14fcb07f9 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -1591,10 +1591,13 @@ bool GVN::PerformLoadPRE(LoadInst *LI, AvailValInBlkVect &ValuesPerBlock, return true; } -static void reportLoadElim(LoadInst *LI, OptimizationRemarkEmitter *ORE) { +static void reportLoadElim(LoadInst *LI, Value *AvailableValue, + OptimizationRemarkEmitter *ORE) { + using namespace ore; ORE->emit(OptimizationRemark(DEBUG_TYPE, "LoadElim", LI) - << "load of type " << ore::NV("Type", LI->getType()) - << " eliminated"); + << "load of type " << NV("Type", LI->getType()) << " eliminated" + << setExtraArgs() << " in favor of " + << NV("InfavorOfValue", AvailableValue)); } /// Attempt to eliminate a load whose dependencies are @@ -1667,7 +1670,7 @@ bool GVN::processNonLocalLoad(LoadInst *LI) { MD->invalidateCachedPointerInfo(V); markInstructionForDeletion(LI); ++NumGVNLoad; - reportLoadElim(LI, ORE); + reportLoadElim(LI, V, ORE); return true; } @@ -1814,7 +1817,7 @@ bool GVN::processLoad(LoadInst *L) { patchAndReplaceAllUsesWith(L, AvailableValue); markInstructionForDeletion(L); ++NumGVNLoad; - reportLoadElim(L, ORE); + reportLoadElim(L, AvailableValue, ORE); // Tell MDA to rexamine the reused pointer since we might have more // information after forwarding it. if (MD && AvailableValue->getType()->getScalarType()->isPointerTy()) -- cgit v1.2.3