From 7d64f8073cb9851e599b44ac24584aa6f8999d4f Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Thu, 30 Apr 2026 11:50:21 +0200 Subject: [PATCH] [hist] Annotate RHist with R__CLING_PTRCHECK(off). In JITted RDF nodes, cling added an unnecessary pointer check, which significantly slows down execution. To allow for compiling the package standalone, the macro is defined in RHistUtils instead of including ROOT's RTypes.h --- hist/histv7/inc/ROOT/RAxes.hxx | 3 ++- hist/histv7/inc/ROOT/RHistFillContext.hxx | 2 +- hist/histv7/inc/ROOT/RHistUtils.hxx | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/hist/histv7/inc/ROOT/RAxes.hxx b/hist/histv7/inc/ROOT/RAxes.hxx index 19848da1be1c3..2262531751484 100644 --- a/hist/histv7/inc/ROOT/RAxes.hxx +++ b/hist/histv7/inc/ROOT/RAxes.hxx @@ -10,6 +10,7 @@ #include "RBinIndexMultiDimRange.hxx" #include "RBinIndexRange.hxx" #include "RCategoricalAxis.hxx" +#include "RHistUtils.hxx" #include "RLinearizedIndex.hxx" #include "RRegularAxis.hxx" #include "RVariableBinAxis.hxx" @@ -38,7 +39,7 @@ namespace Internal { /** Bin configurations for all dimensions of a histogram. */ -class RAxes final { +class R__CLING_PTRCHECK(off) RAxes final { template friend class ::ROOT::Experimental::RHistEngine; diff --git a/hist/histv7/inc/ROOT/RHistFillContext.hxx b/hist/histv7/inc/ROOT/RHistFillContext.hxx index 12aa39ddb2b02..be1b3a41d9289 100644 --- a/hist/histv7/inc/ROOT/RHistFillContext.hxx +++ b/hist/histv7/inc/ROOT/RHistFillContext.hxx @@ -28,7 +28,7 @@ A context to concurrently fill an RHist. Feedback is welcome! */ template -class RHistFillContext final { +class R__CLING_PTRCHECK(off) RHistFillContext final { friend class RHistConcurrentFiller; private: diff --git a/hist/histv7/inc/ROOT/RHistUtils.hxx b/hist/histv7/inc/ROOT/RHistUtils.hxx index ac3ca89aee964..4140910567708 100644 --- a/hist/histv7/inc/ROOT/RHistUtils.hxx +++ b/hist/histv7/inc/ROOT/RHistUtils.hxx @@ -12,6 +12,14 @@ #include #endif +#ifdef __CLING__ +// This attribute can significantly speed up JIT-compiled code in CLING +// It is also defined in ROOT, so keep the definitions the same. +#define R__CLING_PTRCHECK(ONOFF) __attribute__((annotate("__cling__ptrcheck(" #ONOFF ")"))) +#else +#define R__CLING_PTRCHECK(ONOFF) +#endif + namespace ROOT { namespace Experimental { namespace Internal {