Skip to content

Commit 8db3022

Browse files
committed
[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.
1 parent fe705c3 commit 8db3022

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@ class OpenMPIRBuilder {
14691469
/// <critical_section_name> + ".var" for "omp critical" directives; 2)
14701470
/// <mangled_name_for_global_var> + ".cache." for cache for threadprivate
14711471
/// variables.
1472-
StringMap<Constant*, BumpPtrAllocator> InternalVars;
1472+
StringMap<GlobalVariable *, BumpPtrAllocator> InternalVars;
14731473

14741474
/// Computes the size of type in bytes.
14751475
Value *getSizeInBytes(Value *BasePtr);

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4410,8 +4410,7 @@ OpenMPIRBuilder::getOrCreateInternalVariable(Type *Ty, const StringRef &Name,
44104410
unsigned AddressSpace) {
44114411
auto &Elem = *InternalVars.try_emplace(Name, nullptr).first;
44124412
if (Elem.second) {
4413-
assert(cast<PointerType>(Elem.second->getType())
4414-
->isOpaqueOrPointeeTypeMatches(Ty) &&
4413+
assert(Elem.second->getValueType() == Ty &&
44154414
"OMP internal variable has different type than requested");
44164415
} else {
44174416
// TODO: investigate the appropriate linkage type used for the global
@@ -4426,7 +4425,7 @@ OpenMPIRBuilder::getOrCreateInternalVariable(Type *Ty, const StringRef &Name,
44264425
Elem.second = GV;
44274426
}
44284427

4429-
return cast<GlobalVariable>(&*Elem.second);
4428+
return Elem.second;
44304429
}
44314430

44324431
Value *OpenMPIRBuilder::getOMPCriticalRegionLock(StringRef CriticalName) {

0 commit comments

Comments
 (0)