diff --git a/compiler-rt/lib/scudo/standalone/combined.h b/compiler-rt/lib/scudo/standalone/combined.h --- a/compiler-rt/lib/scudo/standalone/combined.h +++ b/compiler-rt/lib/scudo/standalone/combined.h @@ -299,7 +299,7 @@ #endif } - uptr computeOddEvenMaskForPointerMaybe(Options Options, uptr Ptr, + uptr computeOddEvenMaskForPointerMaybe(const Options &Options, uptr Ptr, uptr ClassId) { if (!Options.get(OptionBit::UseOddEvenTags)) return 0; @@ -317,7 +317,7 @@ bool ZeroContents = false) NO_THREAD_SAFETY_ANALYSIS { initThreadMaybe(); - const Options Options = Primary.Options.load(); + const Options &Options = Primary.Options.load(); if (UNLIKELY(Alignment > MaxAlignment)) { if (Options.get(OptionBit::MayReturnNull)) return nullptr; @@ -580,7 +580,7 @@ if (UNLIKELY(Header.State != Chunk::State::Allocated)) reportInvalidChunkState(AllocatorAction::Deallocating, Ptr); - const Options Options = Primary.Options.load(); + const Options &Options = Primary.Options.load(); if (Options.get(OptionBit::DeallocTypeMismatch)) { if (UNLIKELY(Header.OriginOrWasZeroed != Origin)) { // With the exception of memalign'd chunks, that can be still be free'd. @@ -603,7 +603,7 @@ void *reallocate(void *OldPtr, uptr NewSize, uptr Alignment = MinAlignment) { initThreadMaybe(); - const Options Options = Primary.Options.load(); + const Options &Options = Primary.Options.load(); if (UNLIKELY(NewSize >= MaxAllowedMallocSize)) { if (Options.get(OptionBit::MayReturnNull)) return nullptr; @@ -1134,7 +1134,7 @@ reinterpret_cast(Ptr) - SizeOrUnusedBytes; } - void quarantineOrDeallocateChunk(Options Options, void *TaggedPtr, + void quarantineOrDeallocateChunk(const Options &Options, void *TaggedPtr, Chunk::UnpackedHeader *Header, uptr Size) NO_THREAD_SAFETY_ANALYSIS { void *Ptr = getHeaderTaggedPointer(TaggedPtr); @@ -1273,7 +1273,7 @@ storeEndMarker(RoundNewPtr, NewSize, BlockEnd); } - void storePrimaryAllocationStackMaybe(Options Options, void *Ptr) { + void storePrimaryAllocationStackMaybe(const Options &Options, void *Ptr) { if (!UNLIKELY(Options.get(OptionBit::TrackAllocationStacks))) return; auto *Ptr32 = reinterpret_cast(Ptr); @@ -1305,7 +1305,7 @@ atomic_store_relaxed(&Entry->Ptr, reinterpret_cast(Ptr)); } - void storeSecondaryAllocationStackMaybe(Options Options, void *Ptr, + void storeSecondaryAllocationStackMaybe(const Options &Options, void *Ptr, uptr Size) { if (!UNLIKELY(Options.get(OptionBit::TrackAllocationStacks))) return; @@ -1320,7 +1320,7 @@ storeRingBufferEntry(untagPointer(Ptr), Trace, Tid, Size, 0, 0); } - void storeDeallocationStackMaybe(Options Options, void *Ptr, u8 PrevTag, + void storeDeallocationStackMaybe(const Options &Options, void *Ptr, u8 PrevTag, uptr Size) { if (!UNLIKELY(Options.get(OptionBit::TrackAllocationStacks))) return; diff --git a/compiler-rt/lib/scudo/standalone/options.h b/compiler-rt/lib/scudo/standalone/options.h --- a/compiler-rt/lib/scudo/standalone/options.h +++ b/compiler-rt/lib/scudo/standalone/options.h @@ -38,7 +38,7 @@ } }; -template bool useMemoryTagging(Options Options) { +template bool useMemoryTagging(const Options &Options) { return allocatorSupportsMemoryTagging() && Options.get(OptionBit::UseMemoryTagging); } diff --git a/compiler-rt/lib/scudo/standalone/secondary.h b/compiler-rt/lib/scudo/standalone/secondary.h --- a/compiler-rt/lib/scudo/standalone/secondary.h +++ b/compiler-rt/lib/scudo/standalone/secondary.h @@ -90,7 +90,7 @@ public: void init(UNUSED s32 ReleaseToOsInterval) {} bool retrieve(UNUSED uptr Size, UNUSED CachedBlock &Entry) { return false; } - void store(UNUSED Options Options, LargeBlock::Header *H) { unmap(H); } + void store(UNUSED const Options &Options, LargeBlock::Header *H) { unmap(H); } bool canCache(UNUSED uptr Size) { return false; } void disable() {} void enable() {} @@ -113,7 +113,7 @@ static const uptr MaxUnusedCachePages = 4U; template -bool mapSecondary(Options Options, uptr CommitBase, uptr CommitSize, +bool mapSecondary(const Options &Options, uptr CommitBase, uptr CommitSize, uptr AllocPos, uptr Flags, MemMapT &MemMap) { Flags |= MAP_RESIZABLE; Flags |= MAP_ALLOWNOMEM; @@ -179,7 +179,7 @@ setOption(Option::ReleaseInterval, static_cast(ReleaseToOsInterval)); } - void store(Options Options, LargeBlock::Header *H) EXCLUDES(Mutex) { + void store(const Options &Options, LargeBlock::Header *H) EXCLUDES(Mutex) { if (!canCache(H->CommitSize)) return unmap(H); @@ -407,11 +407,11 @@ S->link(&Stats); } - void *allocate(Options Options, uptr Size, uptr AlignmentHint = 0, + void *allocate(const Options &Options, uptr Size, uptr AlignmentHint = 0, uptr *BlockEnd = nullptr, FillContentsMode FillContents = NoFill); - void deallocate(Options Options, void *Ptr); + void deallocate(const Options &Options, void *Ptr); static uptr getBlockEnd(void *Ptr) { auto *B = LargeBlock::getHeader(Ptr); @@ -443,7 +443,7 @@ } } - inline void setHeader(Options Options, CachedBlock &Entry, + inline void setHeader(const Options &Options, CachedBlock &Entry, LargeBlock::Header *H, bool &Zeroed) { Zeroed = Entry.Time == 0; if (useMemoryTagging(Options)) { @@ -501,7 +501,7 @@ // the committed memory will amount to something close to Size - AlignmentHint // (pending rounding and headers). template -void *MapAllocator::allocate(Options Options, uptr Size, uptr Alignment, +void *MapAllocator::allocate(const Options &Options, uptr Size, uptr Alignment, uptr *BlockEndPtr, FillContentsMode FillContents) { if (Options.get(OptionBit::AddLargeAllocationSlack)) @@ -620,7 +620,7 @@ } template -void MapAllocator::deallocate(Options Options, void *Ptr) +void MapAllocator::deallocate(const Options &Options, void *Ptr) EXCLUDES(Mutex) { LargeBlock::Header *H = LargeBlock::getHeader(Ptr); const uptr CommitSize = H->CommitSize;