Skip to content

Commit 366b716

Browse files
committed
[MLIR][OpenMP][OMPIRBuilder] Add lowering support for omp.target_triples
This patch modifies MLIR to LLVM IR lowering of the OpenMP dialect to take into consideration the contents of the `omp.target_triples` module attribute while generating code for `omp.target` operations. It adds the `OpenMPIRBuilderConfig::TargetTriples` field and initializes it using the `amendOperation` flow of the `OpenMPToLLVMIRTranslation` pass. Some changes are introduced into the `OpenMPIRBuilder` to allow passing the information about whether a target region is intended to be offloaded from outside. The result of this change is that offloading calls are only generated when the `--offload-arch` or `-fopenmp-targets` options are given to the compiler. Otherwise, only the host fallback code is generated. This fixes linker errors currently triggered by `flang-new` if a source file containing a `target` construct is compiled without any of the aforementioned options. Several unit tests impacted by these changes, which are intended to check host code generated for `omp.target` operations, are updated to contain the new attribute. Without it, no calls to `__tgt_target_kernel` and associated control flow operations are generated. Fixes #100209.
1 parent 5a8c5c3 commit 366b716

15 files changed

+204
-58
lines changed

flang/test/Integration/OpenMP/map-types-and-sizes.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
! added to this directory and sub-directories.
77
!===----------------------------------------------------------------------===!
88

9-
!RUN: %flang_fc1 -emit-llvm -fopenmp -flang-deprecated-no-hlfir %s -o - | FileCheck %s
9+
!RUN: %flang_fc1 -emit-llvm -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -flang-deprecated-no-hlfir %s -o - | FileCheck %s
1010

1111
!===============================================================================
1212
! Check MapTypes for target implicit captures

llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ class OpenMPIRBuilderConfig {
115115
// Grid Value for the GPU target
116116
std::optional<omp::GV> GridValue;
117117

118+
/// When compilation is being done for the OpenMP host (i.e. `IsTargetDevice =
119+
/// false`), this contains the list of offloading triples associated, if any.
120+
SmallVector<Triple> TargetTriples;
121+
118122
OpenMPIRBuilderConfig();
119123
OpenMPIRBuilderConfig(bool IsTargetDevice, bool IsGPU,
120124
bool OpenMPOffloadMandatory,
@@ -2180,21 +2184,22 @@ class OpenMPIRBuilder {
21802184
/// kernel args vector.
21812185
struct TargetKernelArgs {
21822186
/// Number of arguments passed to the runtime library.
2183-
unsigned NumTargetItems;
2187+
unsigned NumTargetItems = 0;
21842188
/// Arguments passed to the runtime library
21852189
TargetDataRTArgs RTArgs;
21862190
/// The number of iterations
2187-
Value *NumIterations;
2191+
Value *NumIterations = nullptr;
21882192
/// The number of teams.
2189-
Value *NumTeams;
2193+
Value *NumTeams = nullptr;
21902194
/// The number of threads.
2191-
Value *NumThreads;
2195+
Value *NumThreads = nullptr;
21922196
/// The size of the dynamic shared memory.
2193-
Value *DynCGGroupMem;
2197+
Value *DynCGGroupMem = nullptr;
21942198
/// True if the kernel has 'no wait' clause.
2195-
bool HasNoWait;
2199+
bool HasNoWait = false;
21962200

2197-
/// Constructor for TargetKernelArgs
2201+
// Constructors for TargetKernelArgs.
2202+
TargetKernelArgs() {}
21982203
TargetKernelArgs(unsigned NumTargetItems, TargetDataRTArgs RTArgs,
21992204
Value *NumIterations, Value *NumTeams, Value *NumThreads,
22002205
Value *DynCGGroupMem, bool HasNoWait)
@@ -2831,6 +2836,7 @@ class OpenMPIRBuilder {
28312836
/// Generator for '#omp target'
28322837
///
28332838
/// \param Loc where the target data construct was encountered.
2839+
/// \param IsOffloadEntry whether it is an offload entry.
28342840
/// \param CodeGenIP The insertion point where the call to the outlined
28352841
/// function should be emitted.
28362842
/// \param EntryInfo The entry information about the function.
@@ -2844,6 +2850,7 @@ class OpenMPIRBuilder {
28442850
/// \param Dependencies A vector of DependData objects that carry
28452851
// dependency information as passed in the depend clause
28462852
InsertPointTy createTarget(const LocationDescription &Loc,
2853+
bool IsOffloadEntry,
28472854
OpenMPIRBuilder::InsertPointTy AllocaIP,
28482855
OpenMPIRBuilder::InsertPointTy CodeGenIP,
28492856
TargetRegionEntryInfo &EntryInfo, int32_t NumTeams,

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6768,7 +6768,7 @@ static Function *emitTargetTaskProxyFunction(OpenMPIRBuilder &OMPBuilder,
67686768
return ProxyFn;
67696769
}
67706770
static void emitTargetOutlinedFunction(
6771-
OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
6771+
OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder, bool IsOffloadEntry,
67726772
TargetRegionEntryInfo &EntryInfo, Function *&OutlinedFn,
67736773
Constant *&OutlinedFnID, SmallVectorImpl<Value *> &Inputs,
67746774
OpenMPIRBuilder::TargetBodyGenCallbackTy &CBFunc,
@@ -6781,8 +6781,8 @@ static void emitTargetOutlinedFunction(
67816781
CBFunc, ArgAccessorFuncCB);
67826782
};
67836783

6784-
OMPBuilder.emitTargetRegionFunction(EntryInfo, GenerateOutlinedFunction, true,
6785-
OutlinedFn, OutlinedFnID);
6784+
OMPBuilder.emitTargetRegionFunction(EntryInfo, GenerateOutlinedFunction,
6785+
IsOffloadEntry, OutlinedFn, OutlinedFnID);
67866786
}
67876787
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitTargetTask(
67886788
Function *OutlinedFn, Value *OutlinedFnID,
@@ -6898,15 +6898,22 @@ OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitTargetTask(
68986898

68996899
Builder.restoreIP(TargetTaskBodyIP);
69006900

6901-
// emitKernelLaunch makes the necessary runtime call to offload the kernel.
6902-
// We then outline all that code into a separate function
6903-
// ('kernel_launch_function' in the pseudo code above). This function is then
6904-
// called by the target task proxy function (see
6905-
// '@.omp_target_task_proxy_func' in the pseudo code above)
6906-
// "@.omp_target_task_proxy_func' is generated by emitTargetTaskProxyFunction
6907-
Builder.restoreIP(emitKernelLaunch(Builder, OutlinedFn, OutlinedFnID,
6908-
EmitTargetCallFallbackCB, Args, DeviceID,
6909-
RTLoc, TargetTaskAllocaIP));
6901+
if (OutlinedFnID) {
6902+
// emitKernelLaunch makes the necessary runtime call to offload the kernel.
6903+
// We then outline all that code into a separate function
6904+
// ('kernel_launch_function' in the pseudo code above). This function is
6905+
// then called by the target task proxy function (see
6906+
// '@.omp_target_task_proxy_func' in the pseudo code above)
6907+
// "@.omp_target_task_proxy_func' is generated by
6908+
// emitTargetTaskProxyFunction.
6909+
Builder.restoreIP(emitKernelLaunch(Builder, OutlinedFn, OutlinedFnID,
6910+
EmitTargetCallFallbackCB, Args, DeviceID,
6911+
RTLoc, TargetTaskAllocaIP));
6912+
} else {
6913+
// When OutlinedFnID is set to nullptr, then it's not an offloading call. In
6914+
// this case, we execute the host implementation directly.
6915+
Builder.restoreIP(EmitTargetCallFallbackCB(Builder.saveIP()));
6916+
}
69106917

69116918
OI.ExitBB = Builder.saveIP().getBlock();
69126919
OI.PostOutlineCB = [this, ToBeDeleted, Dependencies,
@@ -7015,11 +7022,7 @@ OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitTargetTask(
70157022
Function *TaskCompleteFn =
70167023
getOrCreateRuntimeFunctionPtr(OMPRTL___kmpc_omp_task_complete_if0);
70177024
Builder.CreateCall(TaskBeginFn, {Ident, ThreadID, TaskData});
7018-
CallInst *CI = nullptr;
7019-
if (HasShareds)
7020-
CI = Builder.CreateCall(ProxyFn, {ThreadID, TaskData});
7021-
else
7022-
CI = Builder.CreateCall(ProxyFn, {ThreadID});
7025+
CallInst *CI = Builder.CreateCall(ProxyFn, {ThreadID, TaskData});
70237026
CI->setDebugLoc(StaleCI->getDebugLoc());
70247027
Builder.CreateCall(TaskCompleteFn, {Ident, ThreadID, TaskData});
70257028
} else if (DepArray) {
@@ -7052,6 +7055,7 @@ OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitTargetTask(
70527055
<< "\n");
70537056
return Builder.saveIP();
70547057
}
7058+
70557059
void OpenMPIRBuilder::emitOffloadingArraysAndArgs(
70567060
InsertPointTy AllocaIP, InsertPointTy CodeGenIP, TargetDataInfo &Info,
70577061
TargetDataRTArgs &RTArgs, MapInfosTy &CombinedInfo, bool IsNonContiguous,
@@ -7069,6 +7073,37 @@ static void emitTargetCall(
70697073
SmallVectorImpl<Value *> &Args,
70707074
OpenMPIRBuilder::GenMapInfoCallbackTy GenMapInfoCB,
70717075
SmallVector<llvm::OpenMPIRBuilder::DependData> Dependencies = {}) {
7076+
// Generate a function call to the host fallback implementation of the target
7077+
// region. This is called by the host when no offload entry was generated for
7078+
// the target region and when the offloading call fails at runtime.
7079+
auto &&EmitTargetCallFallbackCB =
7080+
[&](OpenMPIRBuilder::InsertPointTy IP) -> OpenMPIRBuilder::InsertPointTy {
7081+
Builder.restoreIP(IP);
7082+
Builder.CreateCall(OutlinedFn, Args);
7083+
return Builder.saveIP();
7084+
};
7085+
7086+
bool HasNoWait = false;
7087+
bool HasDependencies = Dependencies.size() > 0;
7088+
bool RequiresOuterTargetTask = HasNoWait || HasDependencies;
7089+
7090+
// If we don't have an ID for the target region, it means an offload entry
7091+
// wasn't created. In this case we just run the host fallback directly.
7092+
if (!OutlinedFnID) {
7093+
if (RequiresOuterTargetTask) {
7094+
// Arguments that are intended to be directly forwarded to an
7095+
// emitKernelLaunch call are pased as nullptr, since OutlinedFnID=nullptr
7096+
// results in that call not being done.
7097+
OpenMPIRBuilder::TargetKernelArgs KArgs;
7098+
Builder.restoreIP(OMPBuilder.emitTargetTask(
7099+
OutlinedFn, /*OutlinedFnID=*/nullptr, EmitTargetCallFallbackCB, KArgs,
7100+
/*DeviceID=*/nullptr, /*RTLoc=*/nullptr, AllocaIP, Dependencies,
7101+
HasNoWait));
7102+
} else {
7103+
Builder.restoreIP(EmitTargetCallFallbackCB(Builder.saveIP()));
7104+
}
7105+
return;
7106+
}
70727107

70737108
OpenMPIRBuilder::TargetDataInfo Info(
70747109
/*RequiresDevicePointerInfo=*/false,
@@ -7081,14 +7116,6 @@ static void emitTargetCall(
70817116
/*IsNonContiguous=*/true,
70827117
/*ForEndCall=*/false);
70837118

7084-
// emitKernelLaunch
7085-
auto &&EmitTargetCallFallbackCB =
7086-
[&](OpenMPIRBuilder::InsertPointTy IP) -> OpenMPIRBuilder::InsertPointTy {
7087-
Builder.restoreIP(IP);
7088-
Builder.CreateCall(OutlinedFn, Args);
7089-
return Builder.saveIP();
7090-
};
7091-
70927119
unsigned NumTargetItems = Info.NumberOfPtrs;
70937120
// TODO: Use correct device ID
70947121
Value *DeviceID = Builder.getInt64(OMP_DEVICEID_UNDEF);
@@ -7103,10 +7130,6 @@ static void emitTargetCall(
71037130
// TODO: Use correct DynCGGroupMem
71047131
Value *DynCGGroupMem = Builder.getInt32(0);
71057132

7106-
bool HasNoWait = false;
7107-
bool HasDependencies = Dependencies.size() > 0;
7108-
bool RequiresOuterTargetTask = HasNoWait || HasDependencies;
7109-
71107133
OpenMPIRBuilder::TargetKernelArgs KArgs(NumTargetItems, RTArgs, NumIterations,
71117134
NumTeamsVal, NumThreadsVal,
71127135
DynCGGroupMem, HasNoWait);
@@ -7123,8 +7146,9 @@ static void emitTargetCall(
71237146
DeviceID, RTLoc, AllocaIP));
71247147
}
71257148
}
7149+
71267150
OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createTarget(
7127-
const LocationDescription &Loc, InsertPointTy AllocaIP,
7151+
const LocationDescription &Loc, bool IsOffloadEntry, InsertPointTy AllocaIP,
71287152
InsertPointTy CodeGenIP, TargetRegionEntryInfo &EntryInfo, int32_t NumTeams,
71297153
int32_t NumThreads, SmallVectorImpl<Value *> &Args,
71307154
GenMapInfoCallbackTy GenMapInfoCB,
@@ -7138,12 +7162,13 @@ OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createTarget(
71387162
Builder.restoreIP(CodeGenIP);
71397163

71407164
Function *OutlinedFn;
7141-
Constant *OutlinedFnID;
7165+
Constant *OutlinedFnID = nullptr;
71427166
// The target region is outlined into its own function. The LLVM IR for
71437167
// the target region itself is generated using the callbacks CBFunc
71447168
// and ArgAccessorFuncCB
7145-
emitTargetOutlinedFunction(*this, Builder, EntryInfo, OutlinedFn,
7146-
OutlinedFnID, Args, CBFunc, ArgAccessorFuncCB);
7169+
emitTargetOutlinedFunction(*this, Builder, IsOffloadEntry, EntryInfo,
7170+
OutlinedFn, OutlinedFnID, Args, CBFunc,
7171+
ArgAccessorFuncCB);
71477172

71487173
// If we are not on the target device, then we need to generate code
71497174
// to make a remote call (offload) to the previously outlined function

llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5983,8 +5983,8 @@ TEST_F(OpenMPIRBuilderTest, TargetRegion) {
59835983
TargetRegionEntryInfo EntryInfo("func", 42, 4711, 17);
59845984
OpenMPIRBuilder::LocationDescription OmpLoc({Builder.saveIP(), DL});
59855985
Builder.restoreIP(OMPBuilder.createTarget(
5986-
OmpLoc, Builder.saveIP(), Builder.saveIP(), EntryInfo, -1, 0, Inputs,
5987-
GenMapInfoCB, BodyGenCB, SimpleArgAccessorCB));
5986+
OmpLoc, /*IsOffloadEntry=*/true, Builder.saveIP(), Builder.saveIP(),
5987+
EntryInfo, -1, 0, Inputs, GenMapInfoCB, BodyGenCB, SimpleArgAccessorCB));
59885988
OMPBuilder.finalize();
59895989
Builder.CreateRetVoid();
59905990

@@ -6087,7 +6087,8 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
60876087
/*Line=*/3, /*Count=*/0);
60886088

60896089
Builder.restoreIP(
6090-
OMPBuilder.createTarget(Loc, EntryIP, EntryIP, EntryInfo, /*NumTeams=*/-1,
6090+
OMPBuilder.createTarget(Loc, /*IsOffloadEntry=*/true, EntryIP, EntryIP,
6091+
EntryInfo, /*NumTeams=*/-1,
60916092
/*NumThreads=*/0, CapturedArgs, GenMapInfoCB,
60926093
BodyGenCB, SimpleArgAccessorCB));
60936094

@@ -6235,7 +6236,8 @@ TEST_F(OpenMPIRBuilderTest, ConstantAllocaRaise) {
62356236
/*Line=*/3, /*Count=*/0);
62366237

62376238
Builder.restoreIP(
6238-
OMPBuilder.createTarget(Loc, EntryIP, EntryIP, EntryInfo, /*NumTeams=*/-1,
6239+
OMPBuilder.createTarget(Loc, /*IsOffloadEntry=*/true, EntryIP, EntryIP,
6240+
EntryInfo, /*NumTeams=*/-1,
62396241
/*NumThreads=*/0, CapturedArgs, GenMapInfoCB,
62406242
BodyGenCB, SimpleArgAccessorCB));
62416243

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3233,13 +3233,20 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
32333233
if (!targetOpSupported(opInst))
32343234
return failure();
32353235

3236+
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
3237+
bool isTargetDevice = ompBuilder->Config.isTargetDevice();
32363238
auto parentFn = opInst.getParentOfType<LLVM::LLVMFuncOp>();
32373239
auto targetOp = cast<omp::TargetOp>(opInst);
32383240
auto &targetRegion = targetOp.getRegion();
32393241
DataLayout dl = DataLayout(opInst.getParentOfType<ModuleOp>());
32403242
SmallVector<Value> mapVars = targetOp.getMapVars();
32413243
llvm::Function *llvmOutlinedFn = nullptr;
32423244

3245+
// TODO: It can also be false if a compile-time constant `false` IF clause is
3246+
// specified.
3247+
bool isOffloadEntry =
3248+
isTargetDevice || !ompBuilder->Config.TargetTriples.empty();
3249+
32433250
LogicalResult bodyGenStatus = success();
32443251
using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
32453252
auto bodyCB = [&](InsertPointTy allocaIP,
@@ -3306,14 +3313,12 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
33063313
auto argAccessorCB = [&](llvm::Argument &arg, llvm::Value *input,
33073314
llvm::Value *&retVal, InsertPointTy allocaIP,
33083315
InsertPointTy codeGenIP) {
3309-
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
3310-
33113316
// We just return the unaltered argument for the host function
33123317
// for now, some alterations may be required in the future to
33133318
// keep host fallback functions working identically to the device
33143319
// version (e.g. pass ByCopy values should be treated as such on
33153320
// host and device, currently not always the case)
3316-
if (!ompBuilder->Config.isTargetDevice()) {
3321+
if (!isTargetDevice) {
33173322
retVal = cast<llvm::Value>(&arg);
33183323
return codeGenIP;
33193324
}
@@ -3339,9 +3344,9 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
33393344
moduleTranslation, dds);
33403345

33413346
builder.restoreIP(moduleTranslation.getOpenMPBuilder()->createTarget(
3342-
ompLoc, allocaIP, builder.saveIP(), entryInfo, defaultValTeams,
3343-
defaultValThreads, kernelInput, genMapInfoCB, bodyCB, argAccessorCB,
3344-
dds));
3347+
ompLoc, isOffloadEntry, allocaIP, builder.saveIP(), entryInfo,
3348+
defaultValTeams, defaultValThreads, kernelInput, genMapInfoCB, bodyCB,
3349+
argAccessorCB, dds));
33453350

33463351
// Remap access operations to declare target reference pointers for the
33473352
// device, essentially generating extra loadop's as necessary
@@ -3714,6 +3719,23 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::amendOperation(
37143719
}
37153720
return failure();
37163721
})
3722+
.Case("omp.target_triples",
3723+
[&](Attribute attr) {
3724+
if (auto triplesAttr = dyn_cast<ArrayAttr>(attr)) {
3725+
llvm::OpenMPIRBuilderConfig &config =
3726+
moduleTranslation.getOpenMPBuilder()->Config;
3727+
config.TargetTriples.clear();
3728+
config.TargetTriples.reserve(triplesAttr.size());
3729+
for (Attribute tripleAttr : triplesAttr) {
3730+
if (auto tripleStrAttr = dyn_cast<StringAttr>(tripleAttr))
3731+
config.TargetTriples.emplace_back(tripleStrAttr.getValue());
3732+
else
3733+
return failure();
3734+
}
3735+
return success();
3736+
}
3737+
return failure();
3738+
})
37173739
.Default([](Attribute) {
37183740
// Fall through for omp attributes that do not require lowering.
37193741
return success();

mlir/test/Target/LLVMIR/omptarget-array-sectioning-host.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// array bounds to lower to the full size of the array and the sectioned
88
// array to be the size of 3*3*1*element-byte-size (36 bytes in this case).
99

10-
module attributes {omp.is_target_device = false} {
10+
module attributes {omp.is_target_device = false, omp.target_triples = ["amdgcn-amd-amdhsa"]} {
1111
llvm.func @_3d_target_array_section() {
1212
%0 = llvm.mlir.addressof @_QFEinarray : !llvm.ptr
1313
%1 = llvm.mlir.addressof @_QFEoutarray : !llvm.ptr

mlir/test/Target/LLVMIR/omptarget-byref-bycopy-generation-host.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
22

3-
module attributes {omp.is_target_device = false} {
3+
module attributes {omp.is_target_device = false, omp.target_triples = ["amdgcn-amd-amdhsa"]} {
44
llvm.func @_QQmain() attributes {fir.bindc_name = "main"} {
55
%0 = llvm.mlir.addressof @_QFEi : !llvm.ptr
66
%1 = llvm.mlir.addressof @_QFEsp : !llvm.ptr
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
2+
3+
module attributes {omp.is_target_device = false} {
4+
llvm.func @omp_target_depend_() {
5+
%0 = llvm.mlir.constant(39 : index) : i64
6+
%1 = llvm.mlir.constant(1 : index) : i64
7+
%2 = llvm.mlir.constant(40 : index) : i64
8+
%3 = omp.map.bounds lower_bound(%1 : i64) upper_bound(%0 : i64) extent(%2 : i64) stride(%1 : i64) start_idx(%1 : i64)
9+
%4 = llvm.mlir.addressof @_QFEa : !llvm.ptr
10+
%5 = omp.map.info var_ptr(%4 : !llvm.ptr, !llvm.array<40 x i32>) map_clauses(from) capture(ByRef) bounds(%3) -> !llvm.ptr {name = "a"}
11+
omp.target map_entries(%5 -> %arg0 : !llvm.ptr) depend(taskdependin -> %4 : !llvm.ptr) {
12+
^bb0(%arg0: !llvm.ptr):
13+
%6 = llvm.mlir.constant(100 : index) : i32
14+
llvm.store %6, %arg0 : i32, !llvm.ptr
15+
omp.terminator
16+
}
17+
llvm.return
18+
}
19+
20+
llvm.mlir.global internal @_QFEa() {addr_space = 0 : i32} : !llvm.array<40 x i32> {
21+
%0 = llvm.mlir.zero : !llvm.array<40 x i32>
22+
llvm.return %0 : !llvm.array<40 x i32>
23+
}
24+
}
25+
26+
// CHECK: define void @omp_target_depend_()
27+
// CHECK-NOT: define {{.*}} @
28+
// CHECK-NOT: call i32 @__tgt_target_kernel({{.*}})
29+
// CHECK: call void @__omp_offloading_[[DEV:.*]]_[[FIL:.*]]_omp_target_depend__l[[LINE:.*]](ptr {{.*}})
30+
// CHECK-NEXT: ret void
31+
32+
// CHECK: define internal void @__omp_offloading_[[DEV]]_[[FIL]]_omp_target_depend__l[[LINE]](ptr %[[ADDR_A:.*]])
33+
// CHECK: store i32 100, ptr %[[ADDR_A]], align 4

0 commit comments

Comments
 (0)