-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[AllocToken] Introduce AllocToken instrumentation pass #156838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
melver
merged 22 commits into
main
from
users/melver/spr/alloctoken-introduce-alloctoken-instrumentation-pass
Oct 7, 2025
Merged
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a6a16e6
[𝘀𝗽𝗿] initial version
melver d77f2c0
fixup! Switch to fixed MD
melver 0d4640a
fixup! address reviewer comments
melver c8c3dcf
fixup! address reviewer comments round 2
melver ccc17e3
fixup! use update_test_checks.py for opt tests
melver af29669
[𝘀𝗽𝗿] changes introduced through rebase
melver 44ce657
rebase
melver e0fd16a
fixup! do not strip _
melver 137f0bc
[𝘀𝗽𝗿] changes introduced through rebase
melver e356bbb
fixup! address some comments
melver 3fc5e61
[𝘀𝗽𝗿] changes introduced through rebase
melver deebe93
fixup! address more comments
melver f0baf7a
[𝘀𝗽𝗿] changes introduced through rebase
melver 404eccd
rebase
melver 0681533
[𝘀𝗽𝗿] changes introduced through rebase
melver 2bfda1c
fixup! address comments
melver 050244a
fixup!
melver 352d361
[𝘀𝗽𝗿] changes introduced through rebase
melver fb017cc
rebase
melver c17356a
[𝘀𝗽𝗿] changes introduced through rebase
melver e7ec7a5
rebase
melver 97fa679
rebase
melver File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//===- AllocToken.h - Allocation token instrumentation --------------------===// | ||
melver marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file declares the AllocTokenPass, an instrumentation pass that | ||
// replaces allocation calls with ones including an allocation token. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_ALLOCTOKEN_H | ||
#define LLVM_TRANSFORMS_INSTRUMENTATION_ALLOCTOKEN_H | ||
|
||
#include "llvm/IR/Analysis.h" | ||
#include "llvm/IR/PassManager.h" | ||
#include <optional> | ||
|
||
namespace llvm { | ||
|
||
class Module; | ||
|
||
struct AllocTokenOptions { | ||
std::optional<uint64_t> MaxTokens; | ||
bool FastABI = false; | ||
bool Extended = false; | ||
AllocTokenOptions() = default; | ||
}; | ||
|
||
/// A module pass that rewrites heap allocations to use token-enabled | ||
/// allocation functions based on various source-level properties. | ||
class AllocTokenPass : public PassInfoMixin<AllocTokenPass> { | ||
public: | ||
LLVM_ABI explicit AllocTokenPass(AllocTokenOptions Opts = {}); | ||
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM); | ||
static bool isRequired() { return true; } | ||
|
||
private: | ||
const AllocTokenOptions Options; | ||
}; | ||
|
||
} // namespace llvm | ||
|
||
#endif // LLVM_TRANSFORMS_INSTRUMENTATION_ALLOCTOKEN_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.