diff options
author | Joseph Huber <jhuber6@vols.utk.edu> | 2023-05-12 12:09:37 -0500 |
---|---|---|
committer | Joseph Huber <jhuber6@vols.utk.edu> | 2023-05-12 13:14:27 -0500 |
commit | dd02984519abafe7637cdafcf4ede8b303f385ab (patch) | |
tree | 0585843986b22bc20a35ea220b0da1c9f6f5dc97 /llvm/lib | |
parent | 182e5acb1172fe4c3effe518d2dac3bc3972dd09 (diff) | |
download | llvm-dd02984519abafe7637cdafcf4ede8b303f385ab.zip llvm-dd02984519abafe7637cdafcf4ede8b303f385ab.tar.gz llvm-dd02984519abafe7637cdafcf4ede8b303f385ab.tar.bz2 |
[OpenMP] Naturally align internal global variables in the OpenMPIRBuilder
We use this helper to make several internal global variables during
codegen. currently we do not specify any alignment which allows the
alignment to be set incorrectly after some changes in how alignment was
handled. This patch explicitly aligns these variables to the natural
alignment as specified by the data layout
Fixes https://github.com/llvm/llvm-project/issues/62668
Reviewed By: tianshilei1992, gchatelet
Differential Revision: https://reviews.llvm.org/D150461
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index 0d72218..8370cd0 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -4225,10 +4225,12 @@ OpenMPIRBuilder::getOrCreateInternalVariable(Type *Ty, const StringRef &Name, // variable for possibly changing that to internal or private, or maybe // create different versions of the function for different OMP internal // variables. - Elem.second = new GlobalVariable( + auto *GV = new GlobalVariable( M, Ty, /*IsConstant=*/false, GlobalValue::CommonLinkage, Constant::getNullValue(Ty), Elem.first(), /*InsertBefore=*/nullptr, GlobalValue::NotThreadLocal, AddressSpace); + GV->setAlignment(M.getDataLayout().getABITypeAlign(Ty)); + Elem.second = GV; } return cast<GlobalVariable>(&*Elem.second); |