[llvm] 8db3022 - [OpenMPIRBuilder] Check GV type instead of pointee type (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 02:31:49 PDT 2023
Author: Nikita Popov
Date: 2023-07-18T11:31:41+02:00
New Revision: 8db30225ecc433fd02b623bc4789904930892eb7
URL: https://github.com/llvm/llvm-project/commit/8db30225ecc433fd02b623bc4789904930892eb7
DIFF: https://github.com/llvm/llvm-project/commit/8db30225ecc433fd02b623bc4789904930892eb7.diff
LOG: [OpenMPIRBuilder] Check GV type instead of pointee type (NFC)
Change the assertion to check the value type instead of the pointee
type. To facilitate this, store GlobalVariable* instead of Constant*
in the map.
Added:
Modified:
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index 011f47223435f1..fc838765949c4d 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -1469,7 +1469,7 @@ class OpenMPIRBuilder {
/// <critical_section_name> + ".var" for "omp critical" directives; 2)
/// <mangled_name_for_global_var> + ".cache." for cache for threadprivate
/// variables.
- StringMap<Constant*, BumpPtrAllocator> InternalVars;
+ StringMap<GlobalVariable *, BumpPtrAllocator> InternalVars;
/// Computes the size of type in bytes.
Value *getSizeInBytes(Value *BasePtr);
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 1b2837226aca57..4c3696f9c342ab 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4410,8 +4410,7 @@ OpenMPIRBuilder::getOrCreateInternalVariable(Type *Ty, const StringRef &Name,
unsigned AddressSpace) {
auto &Elem = *InternalVars.try_emplace(Name, nullptr).first;
if (Elem.second) {
- assert(cast<PointerType>(Elem.second->getType())
- ->isOpaqueOrPointeeTypeMatches(Ty) &&
+ assert(Elem.second->getValueType() == Ty &&
"OMP internal variable has
diff erent type than requested");
} else {
// TODO: investigate the appropriate linkage type used for the global
@@ -4426,7 +4425,7 @@ OpenMPIRBuilder::getOrCreateInternalVariable(Type *Ty, const StringRef &Name,
Elem.second = GV;
}
- return cast<GlobalVariable>(&*Elem.second);
+ return Elem.second;
}
Value *OpenMPIRBuilder::getOMPCriticalRegionLock(StringRef CriticalName) {
More information about the llvm-commits
mailing list