diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -55,7 +55,7 @@ struct OpenMPOpt { using OptimizationRemarkGetter = - function_ref(Function *)>; + function_ref; OpenMPOpt(SmallPtrSetImpl &SCC, SmallPtrSetImpl &ModuleSlice, @@ -504,10 +504,11 @@ void emitRemark(Instruction *Inst, StringRef RemarkName, RemarkCallBack &&RemarkCB) { Function *F = Inst->getParent()->getParent(); - auto ORE = OREGetter(F); + auto &ORE = OREGetter(F); - ORE->emit( - [&]() { return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, Inst)); }); + ORE.emit( [&]() { + return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, Inst)); + }); } /// The underyling module. @@ -552,11 +553,10 @@ if (SCC.empty()) return PreservedAnalyses::all(); - auto OREGetter = [&C, &CG, &AM](Function *F) { + auto OREGetter = [&C, &CG, &AM](Function *F) -> OptimizationRemarkEmitter & { FunctionAnalysisManager &FAM = AM.getResult(C, CG).getManager(); - auto &ORE = FAM.getResult(*F); - return std::make_unique(std::move(ORE)); + return FAM.getResult(*F); }; CallGraphUpdater CGUpdater; @@ -607,8 +607,10 @@ CallGraph &CG = getAnalysis().getCallGraph(); CGUpdater.initialize(CG, CGSCC); - auto OREGetter = [](Function *F) { - return std::make_unique(F); + std::unique_ptr ORE; + auto OREGetter = [&ORE](Function *F) -> OptimizationRemarkEmitter & { + ORE = std::make_unique(F); + return *ORE; }; // TODO: Compute the module slice we are allowed to look at. diff --git a/llvm/test/Transforms/OpenMP/deduplication_remarks.ll b/llvm/test/Transforms/OpenMP/deduplication_remarks.ll --- a/llvm/test/Transforms/OpenMP/deduplication_remarks.ll +++ b/llvm/test/Transforms/OpenMP/deduplication_remarks.ll @@ -1,6 +1,6 @@ ; RUN: opt -openmpopt -pass-remarks=openmp-opt -disable-output < %s 2>&1 | FileCheck %s ; RUN: opt -passes=openmpopt -pass-remarks=openmp-opt -disable-output < %s 2>&1 | FileCheck %s -; ModuleID = 'deduplication_analysis.c' +; ModuleID = 'deduplication_remarks.c' source_filename = "deduplication_remarks.c" target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" @@ -10,9 +10,9 @@ @0 = private unnamed_addr global %struct.ident_t { i32 0, i32 34, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str0, i32 0, i32 0) }, align 8 @.str0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1 -; CHECK: remark: deduplication_analysis.c:9:10: OpenMP runtime call __kmpc_global_thread_num moved to deduplication_analysis.c:5:10 -; CHECK: remark: deduplication_analysis.c:7:10: OpenMP runtime call __kmpc_global_thread_num deduplicated -; CHECK: remark: deduplication_analysis.c:5:10: OpenMP runtime call __kmpc_global_thread_num deduplicated +; CHECK: remark: deduplication_remarks.c:9:10: OpenMP runtime call __kmpc_global_thread_num moved to deduplication_remarks.c:5:10 +; CHECK: remark: deduplication_remarks.c:7:10: OpenMP runtime call __kmpc_global_thread_num deduplicated +; CHECK: remark: deduplication_remarks.c:5:10: OpenMP runtime call __kmpc_global_thread_num deduplicated define dso_local void @deduplicate() local_unnamed_addr !dbg !14 { %1 = tail call i32 @__kmpc_global_thread_num(%struct.ident_t* nonnull @0), !dbg !21 call void @useI32(i32 %1), !dbg !23 @@ -34,7 +34,7 @@ !llvm.ident = !{!13} !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None) -!1 = !DIFile(filename: "deduplication_analysis.c", directory: "/tmp") +!1 = !DIFile(filename: "deduplication_remarks.c", directory: "/tmp") !2 = !{} !3 = !{!4} !4 = !DISubprogram(name: "useI32", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)