Skip to content

Commit 07bef02

Browse files
authored
[OpenMPOpt] Initialize OpenMPIRBuilderConfig::IsGPU flag (#104456)
This patch ensures the `IsGPU` flag is set by the OpenMPOpt pass, so that it can be relied upon by `OpenMPIRBuilder` methods when called by that pass as well. Since currently there are very limited callers for the `OpenMPIRBuilder::isGPU()` method, no assertions are being triggered by the lack of initialization of this flag. However, when more offloading-related features are implemented, it will eventually start happening.
1 parent 3e07090 commit 07bef02

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,19 @@ struct OMPInformationCache : public InformationCache {
286286
OpenMPPostLink(OpenMPPostLink) {
287287

288288
OMPBuilder.Config.IsTargetDevice = isOpenMPDevice(OMPBuilder.M);
289+
const Triple T(OMPBuilder.M.getTargetTriple());
290+
switch (T.getArch()) {
291+
case llvm::Triple::nvptx:
292+
case llvm::Triple::nvptx64:
293+
case llvm::Triple::amdgcn:
294+
assert(OMPBuilder.Config.IsTargetDevice &&
295+
"OpenMP AMDGPU/NVPTX is only prepared to deal with device code.");
296+
OMPBuilder.Config.IsGPU = true;
297+
break;
298+
default:
299+
OMPBuilder.Config.IsGPU = false;
300+
break;
301+
}
289302
OMPBuilder.initialize();
290303
initializeRuntimeFunctions(M);
291304
initializeInternalControlVars();

0 commit comments

Comments
 (0)