@@ -73,17 +73,17 @@ template <AllocationKind AK> struct AllocationTracker {
7373 uint32_t AllocationId = AP.AllocationId ;
7474 if (OMP_UNLIKELY (AllocationId >= SanitizerConfig<AK>::SLOTS))
7575 return {P, 0 , (uint32_t )-1 };
76- auto &A = getAllocation<AK>(AP);
76+ auto &A = getAllocation<AK>(AP, /* AccessId= */ 0 , /* PC= */ 0 );
7777 return {A.Start , A.Length , (uint32_t )A.Tag };
7878 }
7979
8080 [[clang::disable_sanitizer_instrumentation]] static _AS_PTR (void , AK)
8181 create(_AS_PTR(void , AK) Start, uint64_t Length, int64_t AllocationId,
82- uint64_t Slot, int64_t SourceId) {
82+ uint64_t Slot, int64_t SourceId, uint64_t PC ) {
8383 if constexpr (SanitizerConfig<AK>::OFFSET_BITS < 64 )
8484 if (OMP_UNLIKELY (Length >= (1UL << (SanitizerConfig<AK>::OFFSET_BITS))))
8585 __sanitizer_trap_info_ptr->exceedsAllocationLength <AK>(
86- Start, Length, AllocationId, Slot, SourceId);
86+ Start, Length, AllocationId, Slot, SourceId, /* PC= */ 0 );
8787
8888 // Reserve the 0 element for the null pointer in global space.
8989 auto &AllocArr = getAllocationArray<AK>();
@@ -94,7 +94,7 @@ template <AllocationKind AK> struct AllocationTracker {
9494 uint64_t NumSlots = SanitizerConfig<AK>::SLOTS;
9595 if (OMP_UNLIKELY (Slot >= NumSlots))
9696 __sanitizer_trap_info_ptr->exceedsAllocationSlots <AK>(
97- Start, Length, AllocationId, Slot, SourceId);
97+ Start, Length, AllocationId, Slot, SourceId, /* PC= */ 0 );
9898
9999 auto &A = AllocArr.Arr [Slot];
100100
@@ -148,36 +148,38 @@ template <AllocationKind AK> struct AllocationTracker {
148148 [[clang::disable_sanitizer_instrumentation]] static _AS_PTR (void , AK)
149149 checkWithBase(_AS_PTR(void , AK) P, _AS_PTR(void , AK) Start,
150150 int64_t Length, uint32_t Tag, int64_t Size,
151- int64_t AccessId, int64_t SourceId) {
151+ int64_t AccessId, int64_t SourceId, uint64_t PC ) {
152152 AllocationPtrTy<AK> AP = AllocationPtrTy<AK>::get (P);
153153 if constexpr (AK == AllocationKind::LOCAL)
154154 if (Length == 0 )
155- Length = getAllocation<AK>(AP, AccessId).Length ;
155+ Length = getAllocation<AK>(AP, AccessId, PC ).Length ;
156156 if constexpr (AK == AllocationKind::GLOBAL)
157157 if (AP.Magic != SanitizerConfig<AllocationKind::GLOBAL>::MAGIC)
158- __sanitizer_trap_info_ptr->garbagePointer <AK>(AP, (void *)P, SourceId);
158+ __sanitizer_trap_info_ptr->garbagePointer <AK>(AP, (void *)P, SourceId,
159+ PC);
159160 int64_t Offset = AP.Offset ;
160161 if (OMP_UNLIKELY (
161162 Offset > Length - Size ||
162163 (SanitizerConfig<AK>::useTags () && Tag != AP.AllocationTag ))) {
163- __sanitizer_trap_info_ptr->accessError <AK>(AP, Size, AccessId, SourceId);
164+ __sanitizer_trap_info_ptr->accessError <AK>(AP, Size, AccessId, SourceId,
165+ PC);
164166 }
165167 return utils::advancePtr (Start, Offset);
166168 }
167169
168170 [[clang::disable_sanitizer_instrumentation]] static _AS_PTR (void , AK)
169171 check(_AS_PTR(void , AK) P, int64_t Size, int64_t AccessId,
170- int64_t SourceId) {
172+ int64_t SourceId, uint64_t PC ) {
171173 AllocationPtrTy<AK> AP = AllocationPtrTy<AK>::get (P);
172- auto &Alloc = getAllocation<AK>(AP, AccessId);
174+ auto &Alloc = getAllocation<AK>(AP, AccessId, PC );
173175 return checkWithBase (P, Alloc.Start , Alloc.Length , Alloc.Tag , Size,
174- AccessId, SourceId);
176+ AccessId, SourceId, PC );
175177 }
176178
177179 [[clang::disable_sanitizer_instrumentation]] static _AS_PTR (void , AK)
178- unpack(_AS_PTR(void , AK) P, int64_t SourceId = 0 ) {
180+ unpack(_AS_PTR(void , AK) P, int64_t SourceId, uint64_t PC ) {
179181 AllocationPtrTy<AK> AP = AllocationPtrTy<AK>::get (P);
180- auto &A = getAllocation<AK>(AP);
182+ auto &A = getAllocation<AK>(AP, SourceId, PC );
181183 uint64_t Offset = AP.Offset ;
182184 _AS_PTR (void , AK) Ptr = utils::advancePtr (A.Start , Offset);
183185 return Ptr;
@@ -186,15 +188,15 @@ template <AllocationKind AK> struct AllocationTracker {
186188 [[clang::disable_sanitizer_instrumentation]] static void
187189 lifetimeStart (_AS_PTR(void , AK) P, uint64_t Length) {
188190 AllocationPtrTy<AK> AP = AllocationPtrTy<AK>::get (P);
189- auto &A = getAllocation<AK>(AP);
191+ auto &A = getAllocation<AK>(AP, /* AccessId= */ 0 , /* PC= */ 0 );
190192 // TODO: Check length
191193 A.Length = Length;
192194 }
193195
194196 [[clang::disable_sanitizer_instrumentation]] static void
195197 lifetimeEnd (_AS_PTR(void , AK) P, uint64_t Length) {
196198 AllocationPtrTy<AK> AP = AllocationPtrTy<AK>::get (P);
197- auto &A = getAllocation<AK>(AP);
199+ auto &A = getAllocation<AK>(AP, /* AccessId= */ 0 , /* PC= */ 0 );
198200 // TODO: Check length
199201 A.Length = 0 ;
200202 }
@@ -214,17 +216,18 @@ template <AllocationKind AK>
214216AllocationArrayTy<AK>
215217 Allocations<AK>::Arr[SanitizerConfig<AK>::NUM_ALLOCATION_ARRAYS];
216218
217- static void checkForMagic (bool IsGlobal, void *P, int64_t SourceId) {
219+ static void checkForMagic (bool IsGlobal, void *P, int64_t SourceId,
220+ uint64_t PC) {
218221 if (IsGlobal) {
219222 auto AP = AllocationPtrTy<AllocationKind::GLOBAL>::get (P);
220223 if (AP.Magic != SanitizerConfig<AllocationKind::GLOBAL>::MAGIC)
221224 __sanitizer_trap_info_ptr->garbagePointer <AllocationKind::GLOBAL>(
222- AP, P, SourceId);
225+ AP, P, SourceId, PC );
223226 } else {
224227 auto AP = AllocationPtrTy<AllocationKind::LOCAL>::get (P);
225228 if (AP.Magic != SanitizerConfig<AllocationKind::LOCAL>::MAGIC)
226229 __sanitizer_trap_info_ptr->garbagePointer <AllocationKind::LOCAL>(
227- AP, P, SourceId);
230+ AP, P, SourceId, PC );
228231 }
229232}
230233
@@ -236,34 +239,34 @@ extern "C" {
236239[[clang::disable_sanitizer_instrumentation, gnu::flatten, gnu::always_inline,
237240 gnu::used, gnu::retain]] _AS_PTR(void , AllocationKind::LOCAL)
238241 ompx_new_local (_AS_PTR(void , AllocationKind::LOCAL) Start, uint64_t Length,
239- int64_t AllocationId, int64_t SourceId) {
242+ int64_t AllocationId, int64_t SourceId, uint64_t PC ) {
240243 return AllocationTracker<AllocationKind::LOCAL>::create (
241- Start, Length, AllocationId, 0 , SourceId);
244+ Start, Length, AllocationId, 0 , SourceId, PC );
242245}
243246[[clang::disable_sanitizer_instrumentation, gnu::flatten, gnu::always_inline,
244247 gnu::used, gnu::retain]] _AS_PTR(void , AllocationKind::GLOBAL)
245248 ompx_new_global (_AS_PTR(void , AllocationKind::GLOBAL) Start,
246249 uint64_t Length, int64_t AllocationId, uint32_t Slot,
247- int64_t SourceId) {
250+ int64_t SourceId, uint64_t PC ) {
248251 return AllocationTracker<AllocationKind::GLOBAL>::create (
249- Start, Length, AllocationId, Slot, SourceId);
252+ Start, Length, AllocationId, Slot, SourceId, PC );
250253}
251254[[clang::disable_sanitizer_instrumentation, gnu::flatten, gnu::always_inline,
252255 gnu::used, gnu::retain]] void
253256__sanitizer_register_host (_AS_PTR(void , AllocationKind::GLOBAL) Start,
254257 uint64_t Length, uint64_t Slot, int64_t SourceId) {
255258 AllocationTracker<AllocationKind::GLOBAL>::create (Start, Length, Slot, Slot,
256- SourceId);
259+ SourceId, /* PC= */ 0 );
257260}
258261[[clang::disable_sanitizer_instrumentation, gnu::flatten, gnu::always_inline,
259262 gnu::used, gnu::retain]] void *
260263ompx_new (void *Start, uint64_t Length, int64_t AllocationId, uint32_t Slot,
261- int64_t SourceId) {
264+ int64_t SourceId, uint64_t PC ) {
262265 if (REAL_PTR_IS_LOCAL (Start))
263266 return (void *)ompx_new_local ((_AS_PTR (void , AllocationKind::LOCAL))Start,
264- Length, AllocationId, SourceId);
267+ Length, AllocationId, SourceId, PC );
265268 return (void *)ompx_new_global ((_AS_PTR (void , AllocationKind::GLOBAL))Start,
266- Length, AllocationId, Slot, SourceId);
269+ Length, AllocationId, Slot, SourceId, PC );
267270}
268271[[clang::disable_sanitizer_instrumentation, gnu::flatten, gnu::always_inline,
269272 gnu::used, gnu::retain]] void
@@ -287,9 +290,9 @@ ompx_free_global(_AS_PTR(void, AllocationKind::GLOBAL) P, int64_t SourceId) {
287290}
288291[[clang::disable_sanitizer_instrumentation, gnu::flatten, gnu::always_inline,
289292 gnu::used, gnu::retain]] void
290- ompx_free (void *P, int64_t SourceId) {
293+ ompx_free (void *P, int64_t SourceId, uint64_t PC ) {
291294 bool IsGlobal = IS_GLOBAL (P);
292- checkForMagic (IsGlobal, P, SourceId);
295+ checkForMagic (IsGlobal, P, SourceId, PC );
293296 if (IsGlobal)
294297 return ompx_free_global ((_AS_PTR (void , AllocationKind::GLOBAL))P, SourceId);
295298 return ompx_free_local ((_AS_PTR (void , AllocationKind::LOCAL))P, SourceId);
@@ -312,7 +315,7 @@ ompx_free(void *P, int64_t SourceId) {
312315 gnu::used, gnu::retain]] void *
313316ompx_gep (void *P, uint64_t Offset, int64_t SourceId) {
314317 bool IsGlobal = IS_GLOBAL (P);
315- checkForMagic (IsGlobal, P, SourceId);
318+ checkForMagic (IsGlobal, P, SourceId, /* PC= */ 0 );
316319 if (IsGlobal)
317320 return (void *)ompx_gep_global ((_AS_PTR (void , AllocationKind::GLOBAL))P,
318321 Offset, SourceId);
@@ -323,66 +326,71 @@ ompx_gep(void *P, uint64_t Offset, int64_t SourceId) {
323326[[clang::disable_sanitizer_instrumentation, gnu::flatten, gnu::always_inline,
324327 gnu::used, gnu::retain]] _AS_PTR(void , AllocationKind::LOCAL)
325328 ompx_check_local (_AS_PTR(void , AllocationKind::LOCAL) P, uint64_t Size,
326- uint64_t AccessId, int64_t SourceId) {
329+ uint64_t AccessId, int64_t SourceId, uint64_t PC ) {
327330 return AllocationTracker<AllocationKind::LOCAL>::check (P, Size, AccessId,
328- SourceId);
331+ SourceId, PC );
329332}
330333[[clang::disable_sanitizer_instrumentation, gnu::flatten, gnu::always_inline,
331334 gnu::used, gnu::retain]] _AS_PTR(void , AllocationKind::GLOBAL)
332335 ompx_check_global (_AS_PTR(void , AllocationKind::GLOBAL) P, uint64_t Size,
333- uint64_t AccessId, int64_t SourceId) {
336+ uint64_t AccessId, int64_t SourceId, uint64_t PC ) {
334337 return AllocationTracker<AllocationKind::GLOBAL>::check (P, Size, AccessId,
335- SourceId);
338+ SourceId, PC );
336339}
337340[[clang::disable_sanitizer_instrumentation, gnu::flatten, gnu::always_inline,
338341 gnu::used, gnu::retain]] void *
339- ompx_check (void *P, uint64_t Size, uint64_t AccessId, int64_t SourceId) {
342+ ompx_check (void *P, uint64_t Size, uint64_t AccessId, int64_t SourceId,
343+ uint64_t PC) {
340344 bool IsGlobal = IS_GLOBAL (P);
341- checkForMagic (IsGlobal, P, SourceId);
345+ checkForMagic (IsGlobal, P, SourceId, PC );
342346 if (IsGlobal)
343347 return (void *)ompx_check_global ((_AS_PTR (void , AllocationKind::GLOBAL))P,
344- Size, AccessId, SourceId);
348+ Size, AccessId, SourceId, PC );
345349 return (void *)ompx_check_local ((_AS_PTR (void , AllocationKind::LOCAL))P, Size,
346- AccessId, SourceId);
350+ AccessId, SourceId, PC );
347351}
348352
349353[[clang::disable_sanitizer_instrumentation, gnu::flatten, gnu::always_inline,
350354 gnu::used, gnu::retain]] _AS_PTR(void , AllocationKind::LOCAL)
351355 ompx_check_with_base_local (_AS_PTR(void , AllocationKind::LOCAL) P,
352356 _AS_PTR(void , AllocationKind::LOCAL) Start,
353357 uint64_t Length, uint32_t Tag, uint64_t Size,
354- uint64_t AccessId, int64_t SourceId) {
358+ uint64_t AccessId, int64_t SourceId,
359+ uint64_t PC) {
355360 return AllocationTracker<AllocationKind::LOCAL>::checkWithBase (
356- P, Start, Length, Tag, Size, AccessId, SourceId);
361+ P, Start, Length, Tag, Size, AccessId, SourceId, PC );
357362}
358363
359364[[clang::disable_sanitizer_instrumentation, gnu::flatten, gnu::always_inline,
360365 gnu::used, gnu::retain]] _AS_PTR(void , AllocationKind::GLOBAL)
361366 ompx_check_with_base_global (_AS_PTR(void , AllocationKind::GLOBAL) P,
362367 _AS_PTR(void , AllocationKind::GLOBAL) Start,
363368 uint64_t Length, uint32_t Tag, uint64_t Size,
364- uint64_t AccessId, int64_t SourceId) {
369+ uint64_t AccessId, int64_t SourceId,
370+ uint64_t PC) {
365371 return AllocationTracker<AllocationKind::GLOBAL>::checkWithBase (
366- P, Start, Length, Tag, Size, AccessId, SourceId);
372+ P, Start, Length, Tag, Size, AccessId, SourceId, PC );
367373}
368374
369375[[clang::disable_sanitizer_instrumentation, gnu::flatten, gnu::always_inline,
370376 gnu::used, gnu::retain]] _AS_PTR(void , AllocationKind::LOCAL)
371377 ompx_unpack_local (_AS_PTR(void , AllocationKind::LOCAL) P,
372378 int64_t SourceId) {
373- return AllocationTracker<AllocationKind::LOCAL>::unpack (P, SourceId);
379+ return AllocationTracker<AllocationKind::LOCAL>::unpack (P, SourceId,
380+ /* PC=*/ 0 );
374381}
375382[[clang::disable_sanitizer_instrumentation, gnu::flatten, gnu::always_inline,
376383 gnu::used, gnu::retain]] _AS_PTR(void , AllocationKind::GLOBAL)
377384 ompx_unpack_global (_AS_PTR(void , AllocationKind::GLOBAL) P,
378385 int64_t SourceId) {
379- return AllocationTracker<AllocationKind::GLOBAL>::unpack (P, SourceId);
386+ return AllocationTracker<AllocationKind::GLOBAL>::unpack (P, SourceId,
387+ /* PC=*/ 0 );
380388}
381389[[clang::disable_sanitizer_instrumentation, gnu::flatten, gnu::always_inline,
382390 gnu::used, gnu::retain]] void *
383391ompx_unpack (void *P, int64_t SourceId) {
384392 bool IsGlobal = IS_GLOBAL (P);
385- checkForMagic (IsGlobal, P, SourceId);
393+ checkForMagic (IsGlobal, P, SourceId, /* PC= */ 0 );
386394 if (IsGlobal)
387395 return (void *)ompx_unpack_global ((_AS_PTR (void , AllocationKind::GLOBAL))P,
388396 SourceId);
0 commit comments