Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/openmp
diff options
context:
space:
mode:
authorJoseph Huber <jhuber6@vols.utk.edu>2022-02-08 00:41:35 +0300
committerJoseph Huber <jhuber6@vols.utk.edu>2022-02-08 01:12:00 +0300
commitd28051c4ab44141d7c52902de500dfe1293d3de2 (patch)
treec738b5227a3527a62d3bd21f095ae11496d1c74c /openmp
parent260fbffe62296f97aad4f9ff0ff792bc642b7965 (diff)
[Libomptarget] Replace Value RAII with default value
This patch replaces the ValueRAII pointer with a default 'nullptr' value. Previously this was initialized as a reference to an existing variable. The use of this variable caused overhead as the compiler could not look through the uses and determine that it was unused if 'Active' was not set. Because of this accesses to the variable would be left in the runtime once compiled. Fixes #53641 Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D119187
Diffstat (limited to 'openmp')
-rw-r--r--openmp/libomptarget/DeviceRTL/include/State.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/openmp/libomptarget/DeviceRTL/include/State.h b/openmp/libomptarget/DeviceRTL/include/State.h
index 3365b054b472..2f9cbd4c9ca6 100644
--- a/openmp/libomptarget/DeviceRTL/include/State.h
+++ b/openmp/libomptarget/DeviceRTL/include/State.h
@@ -124,20 +124,21 @@ private:
template <typename VTy, typename Ty> struct ValueRAII {
ValueRAII(VTy &V, Ty NewValue, Ty OldValue, bool Active, IdentTy *Ident)
- : Ptr(Active ? V.lookup(/* IsReadonly */ false, Ident) : Val),
+ : Ptr(Active ? &V.lookup(/* IsReadonly */ false, Ident) : nullptr),
Val(OldValue), Active(Active) {
if (!Active)
return;
- ASSERT(Ptr == OldValue && "ValueRAII initialization with wrong old value!");
- Ptr = NewValue;
+ ASSERT(*Ptr == OldValue &&
+ "ValueRAII initialization with wrong old value!");
+ *Ptr = NewValue;
}
~ValueRAII() {
if (Active)
- Ptr = Val;
+ *Ptr = Val;
}
private:
- Ty &Ptr;
+ Ty *Ptr;
Ty Val;
bool Active;
};