diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp --- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -1200,13 +1200,20 @@ << "\n"); ORE.emit([&]() { - return OptimizationRemark(DEBUG_TYPE, "ProcessLoopStridedStore", - NewCall->getDebugLoc(), Preheader) - << "Transformed loop-strided store in " - << ore::NV("Function", TheStore->getFunction()) - << " function into a call to " - << ore::NV("NewFunction", NewCall->getCalledFunction()) - << "() intrinsic"; + OptimizationRemark R(DEBUG_TYPE, "ProcessLoopStridedStore", + NewCall->getDebugLoc(), Preheader); + R << "Transformed loop-strided store in " + << ore::NV("Function", TheStore->getFunction()) + << " function into a call to " + << ore::NV("NewFunction", NewCall->getCalledFunction()) + << "() intrinsic"; + if (!Stores.empty()) + R << ore::setExtraArgs(); + for (auto *I : Stores) { + R << ore::NV("FromBlock", I->getParent()->getName()) + << ore::NV("ToBlock", Preheader->getName()); + } + return R; }); // Okay, the memset has been formed. Zap the original store and anything that @@ -1452,7 +1459,10 @@ << ore::NV("NewFunction", NewCall->getCalledFunction()) << "() intrinsic from " << ore::NV("Inst", InstRemark) << " instruction in " << ore::NV("Function", TheStore->getFunction()) - << " function"; + << " function" + << ore::setExtraArgs() + << ore::NV("FromBlock", TheStore->getParent()->getName()) + << ore::NV("ToBlock", Preheader->getName()); }); // Okay, a new call to memcpy/memmove has been formed. Zap the original store diff --git a/llvm/test/Transforms/LoopIdiom/memcpy-debugify-remarks.ll b/llvm/test/Transforms/LoopIdiom/memcpy-debugify-remarks.ll --- a/llvm/test/Transforms/LoopIdiom/memcpy-debugify-remarks.ll +++ b/llvm/test/Transforms/LoopIdiom/memcpy-debugify-remarks.ll @@ -1,5 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -basic-aa -debugify -loop-idiom -pass-remarks=loop-idiom -pass-remarks-analysis=loop-idiom -verify -verify-each -verify-dom-info -verify-loop-info < %s -S 2>&1 | FileCheck %s +; RUN: opt -basic-aa -debugify -loop-idiom -pass-remarks=loop-idiom -pass-remarks-analysis=loop-idiom -pass-remarks-output=%t.yaml -verify -verify-each -verify-dom-info -verify-loop-info < %s -S 2>&1 | FileCheck %s +; RUN: FileCheck --input-file=%t.yaml %s --check-prefixes=YAML target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @@ -8,6 +9,22 @@ ; CHECK: remark: :6:1: Formed a call to llvm.memcpy.p0i8.p0i8.i64() intrinsic from load and store instruction in test6_dest_align function +; YAML: --- !Passed +; YAML-NEXT: Pass: loop-idiom +; YAML-NEXT: Name: ProcessLoopStoreOfLoopLoad +; YAML-NEXT: DebugLoc: { File: '', Line: 6, Column: 1 } +; YAML-NEXT: Function: test6_dest_align +; YAML-NEXT: Args: +; YAML-NEXT: - String: 'Formed a call to ' +; YAML-NEXT: - NewFunction: llvm.memcpy.p0i8.p0i8.i64 +; YAML-NEXT: - String: '() intrinsic from ' +; YAML-NEXT: - Inst: load and store +; YAML-NEXT: - String: ' instruction in ' +; YAML-NEXT: - Function: test6_dest_align +; YAML-NEXT: DebugLoc: { File: '', Line: 1, Column: 0 } +; YAML-NEXT: - String: ' function' +; YAML-NEXT: ... + define void @test6_dest_align(i32* noalias align 1 %Base, i32* noalias align 4 %Dest, i64 %Size) nounwind ssp { ; CHECK-LABEL: @test6_dest_align( ; CHECK-NEXT: bb.nph: diff --git a/llvm/test/Transforms/LoopIdiom/memset-debugify-remarks.ll b/llvm/test/Transforms/LoopIdiom/memset-debugify-remarks.ll --- a/llvm/test/Transforms/LoopIdiom/memset-debugify-remarks.ll +++ b/llvm/test/Transforms/LoopIdiom/memset-debugify-remarks.ll @@ -1,5 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -basic-aa -debugify -loop-idiom -pass-remarks=loop-idiom -pass-remarks-analysis=loop-idiom -verify -verify-each -verify-dom-info -verify-loop-info < %s -S 2>&1 | FileCheck %s +; RUN: opt -basic-aa -debugify -loop-idiom -pass-remarks=loop-idiom -pass-remarks-analysis=loop-idiom -pass-remarks-output=%t.yaml -verify -verify-each -verify-dom-info -verify-loop-info < %s -S 2>&1 | FileCheck %s +; RUN: FileCheck --input-file=%t.yaml %s --check-prefixes=YAML target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @@ -11,7 +12,23 @@ ; *begin = value; ; } -; CHECK: remark: :4:1: Transformed loop-strided store in _Z15my_basic_memsetPcS_c function into a call to llvm.memset.p0i8.i64() intrinsic +; CHECK: remark: :4:1: Transformed loop-strided store in _Z15my_basic_memsetPcS_c function into a call to llvm.memset.p0i8.i64() intrinsic{{$}} + +; YAML: --- !Passed +; YAML-NEXT: Pass: loop-idiom +; YAML-NEXT: Name: ProcessLoopStridedStore +; YAML-NEXT: DebugLoc: { File: '', Line: 4, Column: 1 } +; YAML-NEXT: Function: _Z15my_basic_memsetPcS_c +; YAML-NEXT: Args: +; YAML-NEXT: - String: 'Transformed loop-strided store in ' +; YAML-NEXT: - Function: _Z15my_basic_memsetPcS_c +; YAML-NEXT: DebugLoc: { File: '', Line: 1, Column: 0 } +; YAML-NEXT: - String: ' function into a call to ' +; YAML-NEXT: - NewFunction: llvm.memset.p0i8.i64 +; YAML-NEXT: - String: '() intrinsic' +; YAML-NEXT: - FromBlock: for.body +; YAML-NEXT: - ToBlock: for.body.preheader +; YAML-NEXT: ... define void @_Z15my_basic_memsetPcS_c(i8* %ptr, i8* %end, i8 %value) { ; CHECK-LABEL: @_Z15my_basic_memsetPcS_c(