Skip to content

Commit 93cdf76

Browse files
committed
[OMPIRBuilder] Don't use invalid debug loc in declare mapper function.
This is similar to llvm#147950 but for declare mapper function.
1 parent 82a276e commit 93cdf76

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8319,8 +8319,9 @@ Expected<Function *> OpenMPIRBuilder::emitUserDefinedMapper(
83198319

83208320
// Start the mapper function code generation.
83218321
BasicBlock *EntryBB = BasicBlock::Create(M.getContext(), "entry", MapperFn);
8322-
auto SavedIP = Builder.saveIP();
8322+
IRBuilder<>::InsertPointGuard IPG(Builder);
83238323
Builder.SetInsertPoint(EntryBB);
8324+
Builder.SetCurrentDebugLocation(llvm::DebugLoc());
83248325

83258326
Value *MapperHandle = MapperFn->getArg(0);
83268327
Value *BaseIn = MapperFn->getArg(1);
@@ -8506,7 +8507,6 @@ Expected<Function *> OpenMPIRBuilder::emitUserDefinedMapper(
85068507
emitBlock(DoneBB, MapperFn, /*IsFinished=*/true);
85078508

85088509
Builder.CreateRetVoid();
8509-
Builder.restoreIP(SavedIP);
85108510
return MapperFn;
85118511
}
85128512

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
2+
3+
module attributes {omp.target_triples = ["amdgcn-amd-amdhsa"]} {
4+
omp.declare_mapper @_QQFmy_testmy_mapper : !llvm.struct<"_QFmy_testTmy_type", (i32)> {
5+
^bb0(%arg0: !llvm.ptr):
6+
%0 = llvm.mlir.constant(0 : i32) : i32
7+
%1 = llvm.getelementptr %arg0[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<"_QFmy_testTmy_type", (i32)>
8+
%2 = omp.map.info var_ptr(%1 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = "var%data"}
9+
%3 = omp.map.info var_ptr(%arg0 : !llvm.ptr, !llvm.struct<"_QFmy_testTmy_type", (i32)>) map_clauses(tofrom) capture(ByRef) members(%2 : [0] : !llvm.ptr) -> !llvm.ptr {name = "var", partial_map = true}
10+
omp.declare_mapper.info map_entries(%3, %2 : !llvm.ptr, !llvm.ptr)
11+
}
12+
13+
llvm.func @_QPopenmp_target_data_mapper() {
14+
%0 = llvm.mlir.constant(1 : i64) : i64
15+
%1 = llvm.alloca %0 x !llvm.struct<"_QFmy_testTmy_type", (i32)> {bindc_name = "a"} : (i64) -> !llvm.ptr
16+
%2 = omp.map.info var_ptr(%1 : !llvm.ptr, !llvm.struct<"_QFmy_testTmy_type", (i32)>) map_clauses(tofrom) capture(ByRef) mapper(@_QQFmy_testmy_mapper) -> !llvm.ptr {name = "a"}
17+
omp.target_data map_entries(%2 : !llvm.ptr) {
18+
%3 = llvm.mlir.constant(10 : i32) : i32
19+
%4 = llvm.getelementptr %1[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<"_QFmy_testTmy_type", (i32)>
20+
llvm.store %3, %4 : i32, !llvm.ptr
21+
omp.terminator
22+
}
23+
llvm.return
24+
} loc(#loc12)
25+
} loc(#loc)
26+
27+
#loc = loc("test.f90":4:18)
28+
#loc1 = loc("test.f90":4:18)
29+
30+
#di_file = #llvm.di_file<"test.f90" in "">
31+
#di_null_type = #llvm.di_null_type
32+
#di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>,
33+
sourceLanguage = DW_LANG_Fortran95, file = #di_file, producer = "flang",
34+
isOptimized = false, emissionKind = LineTablesOnly>
35+
#di_subroutine_type = #llvm.di_subroutine_type<
36+
callingConvention = DW_CC_program, types = #di_null_type>
37+
#di_subprogram = #llvm.di_subprogram<id = distinct[1]<>,
38+
compileUnit = #di_compile_unit, scope = #di_file, name = "main",
39+
file = #di_file, subprogramFlags = "Definition|MainSubprogram",
40+
type = #di_subroutine_type>
41+
42+
#loc12 = loc(fused<#di_subprogram>[#loc1])
43+
44+
// CHECK: define internal void @{{.*}}omp_mapper{{.*}}_QQFmy_testmy_mapper
45+
// CHECK-NOT: !dbg
46+
// CHECK: }
47+

0 commit comments

Comments
 (0)