Skip to content

Commit

Permalink
[OpenMP] Emit remark on the captured call instead of the variable
Browse files Browse the repository at this point in the history
Changes the remark to emit on the function call that captures the globalized
variable instead of the globalized variable itself. The user should be able to
see which variable it was in the argument list of the function.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D106980
  • Loading branch information
jhuber6 committed Feb 4, 2022
1 parent 6abb70c commit 6b78526
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Expand Up @@ -6316,7 +6316,7 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {

if (ValidUsesOnly &&
AI.LibraryFunctionId == LibFunc___kmpc_alloc_shared)
A.emitRemark<OptimizationRemarkMissed>(AI.CB, "OMP113", Remark);
A.emitRemark<OptimizationRemarkMissed>(CB, "OMP113", Remark);

LLVM_DEBUG(dbgs() << "[H2S] Bad user: " << *UserI << "\n");
ValidUsesOnly = false;
Expand Down
7 changes: 4 additions & 3 deletions llvm/test/Transforms/OpenMP/globalization_remarks.ll
Expand Up @@ -17,23 +17,24 @@ entry:
%0 = call i8* @__kmpc_alloc_shared(i64 4), !dbg !10
%x_on_stack = bitcast i8* %0 to i32*
%1 = bitcast i32* %x_on_stack to i8*
call void @share(i8* %1)
call void @share(i8* %1), !dbg !10
call void @__kmpc_free_shared(i8* %0)
call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 true)
ret void
}

define void @share(i8* %x) {
define internal void @share(i8* %x) {
entry:
store i8* %x, i8** @S
ret void
}

declare i8* @__kmpc_alloc_shared(i64)

declare void @__kmpc_free_shared(i8*)
declare void @__kmpc_free_shared(i8* nocapture)

declare i32 @__kmpc_target_init(%struct.ident_t*, i1, i1, i1);

declare void @__kmpc_target_deinit(%struct.ident_t*, i1, i1)

!llvm.dbg.cu = !{!0}
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/OpenMP/remove_globalization.ll
Expand Up @@ -93,7 +93,7 @@ define internal void @bar() {
;
entry:
%0 = call i8* @__kmpc_alloc_shared(i64 4), !dbg !13
call void @share(i8* %0)
call void @share(i8* %0), !dbg !13
call void @__kmpc_free_shared(i8* %0, i64 4)
ret void
}
Expand Down

0 comments on commit 6b78526

Please sign in to comment.