Skip to content

Commit 18ae02d

Browse files
jhuber6memfrob
authored andcommitted
[OpenMP] Add IDs to OpenMP remarks
This patch adds unique idenfitiers to the existing OpenMP remarks. This makes it easier to identify the corresponding documentation for each remark that will be hosted in the OpenMP webpage. Depends on D105898 Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D105939
1 parent 6601143 commit 18ae02d

File tree

5 files changed

+65
-48
lines changed

5 files changed

+65
-48
lines changed

clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ void baz(void) __attribute__((assume("omp_no_openmp")));
88

99
void bar1(void) {
1010
#pragma omp parallel // #0
11-
// safe-remark@#0 {{Parallel region is used in unknown ways. Will not attempt to rewrite the state machine.}}
11+
// safe-remark@#0 {{Parallel region is used in unknown ways. Will not attempt to rewrite the state machine. [OMP101]}}
1212
{
1313
}
1414
}
1515
void bar2(void) {
1616
#pragma omp parallel // #1
17-
// safe-remark@#1 {{Parallel region is used in unknown ways. Will not attempt to rewrite the state machine.}}
17+
// safe-remark@#1 {{Parallel region is used in unknown ways. Will not attempt to rewrite the state machine. [OMP101]}}
1818
{
1919
}
2020
}
2121

2222
void foo1(void) {
2323
#pragma omp target teams // #2
24-
// all-remark@#2 {{Rewriting generic-mode kernel with a customized state machine.}}
24+
// all-remark@#2 {{Rewriting generic-mode kernel with a customized state machine. [OMP131]}}
2525

2626
{
27-
baz(); // all-remark {{Value has potential side effects preventing SPMD-mode execution. Add `__attribute__((assume("ompx_spmd_amenable")))` to the called function to override.}}
27+
baz(); // all-remark {{Value has potential side effects preventing SPMD-mode execution. Add `__attribute__((assume("ompx_spmd_amenable")))` to the called function to override. [OMP121]}}
2828
#pragma omp parallel // #3
2929
{
3030
}
@@ -37,9 +37,9 @@ void foo1(void) {
3737

3838
void foo2(void) {
3939
#pragma omp target teams // #5
40-
// all-remark@#5 {{Rewriting generic-mode kernel with a customized state machine.}}
40+
// all-remark@#5 {{Rewriting generic-mode kernel with a customized state machine. [OMP131]}}
4141
{
42-
baz(); // all-remark {{Value has potential side effects preventing SPMD-mode execution. Add `__attribute__((assume("ompx_spmd_amenable")))` to the called function to override.}}
42+
baz(); // all-remark {{Value has potential side effects preventing SPMD-mode execution. Add `__attribute__((assume("ompx_spmd_amenable")))` to the called function to override. [OMP121]}}
4343
#pragma omp parallel // #6
4444
{
4545
}
@@ -55,9 +55,9 @@ void foo2(void) {
5555

5656
void foo3(void) {
5757
#pragma omp target teams // #8
58-
// all-remark@#8 {{Rewriting generic-mode kernel with a customized state machine.}}
58+
// all-remark@#8 {{Rewriting generic-mode kernel with a customized state machine. [OMP131]}}
5959
{
60-
baz(); // all-remark {{Value has potential side effects preventing SPMD-mode execution. Add `__attribute__((assume("ompx_spmd_amenable")))` to the called function to override.}}
60+
baz(); // all-remark {{Value has potential side effects preventing SPMD-mode execution. Add `__attribute__((assume("ompx_spmd_amenable")))` to the called function to override. [OMP121]}}
6161
#pragma omp parallel // #9
6262
{
6363
}
@@ -83,4 +83,4 @@ void spmd(void) {
8383
}
8484
}
8585

86-
// all-remark@* 9 {{OpenMP runtime call __kmpc_global_thread_num deduplicated}}
86+
// all-remark@* 9 {{OpenMP runtime call __kmpc_global_thread_num deduplicated. [OMP170]}}

clang/test/OpenMP/remarks_parallel_in_target_state_machine.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ void baz(void) __attribute__((assume("omp_no_openmp")));
88

99
void bar(void) {
1010
#pragma omp parallel // #1 \
11-
// expected-remark@#1 {{Parallel region is used in unknown ways. Will not attempt to rewrite the state machine.}}
11+
// expected-remark@#1 {{Parallel region is used in unknown ways. Will not attempt to rewrite the state machine. [OMP101]}}
1212
{
1313
}
1414
}
1515

1616
void foo(void) {
1717
#pragma omp target teams // #2
18-
// expected-remark@#2 {{Rewriting generic-mode kernel with a customized state machine.}}
18+
// expected-remark@#2 {{Rewriting generic-mode kernel with a customized state machine. [OMP131]}}
1919
{
20-
baz(); // expected-remark {{Value has potential side effects preventing SPMD-mode execution. Add `__attribute__((assume("ompx_spmd_amenable")))` to the called function to override.}}
20+
baz(); // expected-remark {{Value has potential side effects preventing SPMD-mode execution. Add `__attribute__((assume("ompx_spmd_amenable")))` to the called function to override. [OMP121]}}
2121
#pragma omp parallel
2222
{
2323
}
@@ -40,4 +40,4 @@ void spmd(void) {
4040
}
4141
}
4242

43-
// expected-remark@* {{OpenMP runtime call __kmpc_global_thread_num deduplicated}}
43+
// expected-remark@* {{OpenMP runtime call __kmpc_global_thread_num deduplicated. [OMP170]}}

llvm/include/llvm/Transforms/IPO/Attributor.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,13 @@ struct Attributor {
15871587
Function *F = I->getFunction();
15881588
auto &ORE = OREGetter.getValue()(F);
15891589

1590-
ORE.emit([&]() { return RemarkCB(RemarkKind(PassName, RemarkName, I)); });
1590+
if (RemarkName.startswith("OMP"))
1591+
ORE.emit([&]() {
1592+
return RemarkCB(RemarkKind(PassName, RemarkName, I))
1593+
<< " [" << RemarkName << "]";
1594+
});
1595+
else
1596+
ORE.emit([&]() { return RemarkCB(RemarkKind(PassName, RemarkName, I)); });
15911597
}
15921598

15931599
/// Emit a remark on a function.
@@ -1599,7 +1605,13 @@ struct Attributor {
15991605

16001606
auto &ORE = OREGetter.getValue()(F);
16011607

1602-
ORE.emit([&]() { return RemarkCB(RemarkKind(PassName, RemarkName, F)); });
1608+
if (RemarkName.startswith("OMP"))
1609+
ORE.emit([&]() {
1610+
return RemarkCB(RemarkKind(PassName, RemarkName, F))
1611+
<< " [" << RemarkName << "]";
1612+
});
1613+
else
1614+
ORE.emit([&]() { return RemarkCB(RemarkKind(PassName, RemarkName, F)); });
16031615
}
16041616

16051617
/// Helper struct used in the communication between an abstract attribute (AA)

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5039,7 +5039,10 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
50395039
return OR << "Moving globalized variable to the stack.";
50405040
return OR << "Moving memory allocation from the heap to the stack.";
50415041
};
5042-
A.emitRemark<OptimizationRemark>(AI.CB, "HeapToStack", Remark);
5042+
if (AI.LibraryFunctionId == LibFunc___kmpc_alloc_shared)
5043+
A.emitRemark<OptimizationRemark>(AI.CB, "OMP110", Remark);
5044+
else
5045+
A.emitRemark<OptimizationRemark>(AI.CB, "HeapToStack", Remark);
50435046

50445047
Value *Size;
50455048
Optional<APInt> SizeAPI = getSize(A, *this, AI);
@@ -5335,8 +5338,7 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
53355338
};
53365339

53375340
if (AI.LibraryFunctionId == LibFunc___kmpc_alloc_shared)
5338-
A.emitRemark<OptimizationRemarkMissed>(AI.CB, "HeapToStackFailed",
5339-
Remark);
5341+
A.emitRemark<OptimizationRemarkMissed>(AI.CB, "OMP113", Remark);
53405342

53415343
LLVM_DEBUG(dbgs() << "[H2S] Bad user: " << *UserI << "\n");
53425344
ValidUsesOnly = false;

llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -949,8 +949,7 @@ struct OpenMPOpt {
949949
return OR << ".";
950950
};
951951

952-
emitRemark<OptimizationRemark>(MergableCIs.front(),
953-
"OpenMPParallelRegionMerging", Remark);
952+
emitRemark<OptimizationRemark>(MergableCIs.front(), "OMP150", Remark);
954953

955954
Function *OriginalFn = BB->getParent();
956955
LLVM_DEBUG(dbgs() << TAG << "Merge " << MergableCIs.size()
@@ -1204,8 +1203,7 @@ struct OpenMPOpt {
12041203
auto Remark = [&](OptimizationRemark OR) {
12051204
return OR << "Removing parallel region with no side-effects.";
12061205
};
1207-
emitRemark<OptimizationRemark>(CI, "OpenMPParallelRegionDeletion",
1208-
Remark);
1206+
emitRemark<OptimizationRemark>(CI, "OMP160", Remark);
12091207

12101208
CGUpdater.removeCallSite(*CI);
12111209
CI->eraseFromParent();
@@ -1311,7 +1309,7 @@ struct OpenMPOpt {
13111309
<< "Found thread data sharing on the GPU. "
13121310
<< "Expect degraded performance due to data globalization.";
13131311
};
1314-
emitRemark<OptimizationRemarkMissed>(CI, "OpenMPGlobalization", Remark);
1312+
emitRemark<OptimizationRemarkMissed>(CI, "OMP112", Remark);
13151313
}
13161314

13171315
return false;
@@ -1593,9 +1591,9 @@ struct OpenMPOpt {
15931591
<< ore::NV("OpenMPOptRuntime", RFI.Name) << " deduplicated.";
15941592
};
15951593
if (CI->getDebugLoc())
1596-
emitRemark<OptimizationRemark>(CI, "OpenMPRuntimeDeduplicated", Remark);
1594+
emitRemark<OptimizationRemark>(CI, "OMP170", Remark);
15971595
else
1598-
emitRemark<OptimizationRemark>(&F, "OpenMPRuntimeDeduplicated", Remark);
1596+
emitRemark<OptimizationRemark>(&F, "OMP170", Remark);
15991597

16001598
CGUpdater.removeCallSite(*CI);
16011599
CI->replaceAllUsesWith(ReplVal);
@@ -1702,7 +1700,14 @@ struct OpenMPOpt {
17021700
Function *F = I->getParent()->getParent();
17031701
auto &ORE = OREGetter(F);
17041702

1705-
ORE.emit([&]() { return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, I)); });
1703+
if (RemarkName.startswith("OMP"))
1704+
ORE.emit([&]() {
1705+
return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, I))
1706+
<< " [" << RemarkName << "]";
1707+
});
1708+
else
1709+
ORE.emit(
1710+
[&]() { return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, I)); });
17061711
}
17071712

17081713
/// Emit a remark on a function.
@@ -1711,7 +1716,14 @@ struct OpenMPOpt {
17111716
RemarkCallBack &&RemarkCB) const {
17121717
auto &ORE = OREGetter(F);
17131718

1714-
ORE.emit([&]() { return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, F)); });
1719+
if (RemarkName.startswith("OMP"))
1720+
ORE.emit([&]() {
1721+
return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, F))
1722+
<< " [" << RemarkName << "]";
1723+
});
1724+
else
1725+
ORE.emit(
1726+
[&]() { return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, F)); });
17151727
}
17161728

17171729
/// The underlying module.
@@ -1880,8 +1892,7 @@ bool OpenMPOpt::rewriteDeviceCodeStateMachine() {
18801892
<< (UnknownUse ? "unknown" : "unexpected")
18811893
<< " ways. Will not attempt to rewrite the state machine.";
18821894
};
1883-
emitRemark<OptimizationRemarkAnalysis>(F, "OpenMPParallelRegionInNonSPMD",
1884-
Remark);
1895+
emitRemark<OptimizationRemarkAnalysis>(F, "OMP101", Remark);
18851896
continue;
18861897
}
18871898

@@ -1893,8 +1904,7 @@ bool OpenMPOpt::rewriteDeviceCodeStateMachine() {
18931904
return ORA << "Parallel region is not called from a unique kernel. "
18941905
"Will not attempt to rewrite the state machine.";
18951906
};
1896-
emitRemark<OptimizationRemarkAnalysis>(
1897-
F, "OpenMPParallelRegionInMultipleKernesl", Remark);
1907+
emitRemark<OptimizationRemarkAnalysis>(F, "OMP102", Remark);
18981908
continue;
18991909
}
19001910

@@ -2581,8 +2591,7 @@ struct AAHeapToSharedFunction : public AAHeapToShared {
25812591
<< ((AllocSize->getZExtValue() != 1) ? " bytes " : " byte ")
25822592
<< "of shared memory.";
25832593
};
2584-
A.emitRemark<OptimizationRemark>(CB, "OpenMPReplaceGlobalization",
2585-
Remark);
2594+
A.emitRemark<OptimizationRemark>(CB, "OMP111", Remark);
25862595

25872596
SharedMem->setAlignment(MaybeAlign(32));
25882597

@@ -2823,8 +2832,8 @@ struct AAKernelInfoFunction : AAKernelInfo {
28232832
}
28242833
return ORA << ".";
28252834
};
2826-
A.emitRemark<OptimizationRemarkAnalysis>(
2827-
NonCompatibleI, "OpenMPKernelNonSPMDMode", Remark);
2835+
A.emitRemark<OptimizationRemarkAnalysis>(NonCompatibleI, "OMP121",
2836+
Remark);
28282837

28292838
LLVM_DEBUG(dbgs() << TAG << "SPMD-incompatible side-effect: "
28302839
<< *NonCompatibleI << "\n");
@@ -2864,8 +2873,7 @@ struct AAKernelInfoFunction : AAKernelInfo {
28642873
auto Remark = [&](OptimizationRemark OR) {
28652874
return OR << "Transformed generic-mode kernel to SPMD-mode.";
28662875
};
2867-
A.emitRemark<OptimizationRemark>(KernelInitCB, "OpenMPKernelSPMDMode",
2868-
Remark);
2876+
A.emitRemark<OptimizationRemark>(KernelInitCB, "OMP120", Remark);
28692877
return true;
28702878
};
28712879

@@ -2909,8 +2917,7 @@ struct AAKernelInfoFunction : AAKernelInfo {
29092917
auto Remark = [&](OptimizationRemark OR) {
29102918
return OR << "Removing unused state machine from generic-mode kernel.";
29112919
};
2912-
A.emitRemark<OptimizationRemark>(
2913-
KernelInitCB, "OpenMPKernelWithoutStateMachine", Remark);
2920+
A.emitRemark<OptimizationRemark>(KernelInitCB, "OMP130", Remark);
29142921

29152922
return ChangeStatus::CHANGED;
29162923
}
@@ -2923,18 +2930,15 @@ struct AAKernelInfoFunction : AAKernelInfo {
29232930
return OR << "Rewriting generic-mode kernel with a customized state "
29242931
"machine.";
29252932
};
2926-
A.emitRemark<OptimizationRemark>(
2927-
KernelInitCB, "OpenMPKernelWithCustomizedStateMachine", Remark);
2933+
A.emitRemark<OptimizationRemark>(KernelInitCB, "OMP131", Remark);
29282934
} else {
29292935
++NumOpenMPTargetRegionKernelsCustomStateMachineWithFallback;
29302936

29312937
auto Remark = [&](OptimizationRemarkAnalysis OR) {
29322938
return OR << "Generic-mode kernel is executed with a customized state "
29332939
"machine that requires a fallback.";
29342940
};
2935-
A.emitRemark<OptimizationRemarkAnalysis>(
2936-
KernelInitCB, "OpenMPKernelWithCustomizedStateMachineAndFallback",
2937-
Remark);
2941+
A.emitRemark<OptimizationRemarkAnalysis>(KernelInitCB, "OMP132", Remark);
29382942

29392943
// Tell the user why we ended up with a fallback.
29402944
for (CallBase *UnknownParallelRegionCB : ReachedUnknownParallelRegions) {
@@ -2945,9 +2949,8 @@ struct AAKernelInfoFunction : AAKernelInfo {
29452949
<< "`__attribute__((assume(\"omp_no_parallelism\")))` to "
29462950
"override.";
29472951
};
2948-
A.emitRemark<OptimizationRemarkAnalysis>(
2949-
UnknownParallelRegionCB,
2950-
"OpenMPKernelWithCustomizedStateMachineAndFallback", Remark);
2952+
A.emitRemark<OptimizationRemarkAnalysis>(UnknownParallelRegionCB,
2953+
"OMP133", Remark);
29512954
}
29522955
}
29532956

@@ -3741,7 +3744,7 @@ PreservedAnalyses OpenMPOptPass::run(Module &M, ModuleAnalysisManager &AM) {
37413744
auto EmitRemark = [&](Function &F) {
37423745
auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(F);
37433746
ORE.emit([&]() {
3744-
OptimizationRemarkAnalysis ORA(DEBUG_TYPE, "InternalizationFailure", &F);
3747+
OptimizationRemarkAnalysis ORA(DEBUG_TYPE, "OMP140", &F);
37453748
return ORA << "Could not internalize function. "
37463749
<< "Some optimizations may not be possible.";
37473750
});

0 commit comments

Comments
 (0)