summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorMike Rice <michael.p.rice@intel.com>2022-05-25 15:02:26 -0700
committerMike Rice <michael.p.rice@intel.com>2022-05-26 09:51:48 -0700
commit0a5cfbf7b2e82e7980b66428e88b4e28e814d7bb (patch)
tree57227909327184f7826c14532e158542d47a1cd5 /clang/lib/CodeGen/CodeGenModule.cpp
parent939a43461ba3cd540a049a62a27dab2732bedd64 (diff)
[OpenMP] Use the align clause value from 'omp allocate' for globals
Refactor the code that handles the align clause of 'omp allocate' so it can be used with globals as well as local variables. Differential Revision: https://reviews.llvm.org/D126426
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index a035e5ddd9e6..b4ae266f8988 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4738,7 +4738,12 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
GV->setConstant(true);
}
- GV->setAlignment(getContext().getDeclAlign(D).getAsAlign());
+ CharUnits AlignVal = getContext().getDeclAlign(D);
+ // Check for alignment specifed in an 'omp allocate' directive.
+ if (llvm::Optional<CharUnits> AlignValFromAllocate =
+ getOMPAllocateAlignment(D))
+ AlignVal = AlignValFromAllocate.getValue();
+ GV->setAlignment(AlignVal.getAsAlign());
// On Darwin, unlike other Itanium C++ ABI platforms, the thread-wrapper
// function is only defined alongside the variable, not also alongside