-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[NFC][IR] Add SetNoSanitize helpers #86772
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
vitalybuka
merged 9 commits into
main
from
users/vitalybuka/spr/nfcir-add-setnosanitize-helpers
Mar 27, 2024
Merged
[NFC][IR] Add SetNoSanitize helpers #86772
vitalybuka
merged 9 commits into
main
from
users/vitalybuka/spr/nfcir-add-setnosanitize-helpers
Mar 27, 2024
Conversation
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
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4
@llvm/pr-subscribers-llvm-ir Author: Vitaly Buka (vitalybuka) ChangesFull diff: https://github.com/llvm/llvm-project/pull/86772.diff 3 Files Affected:
diff --git a/llvm/include/llvm/IR/GlobalValue.h b/llvm/include/llvm/IR/GlobalValue.h
index aa8188cd99fee1..c61d502aa332b0 100644
--- a/llvm/include/llvm/IR/GlobalValue.h
+++ b/llvm/include/llvm/IR/GlobalValue.h
@@ -360,6 +360,7 @@ class GlobalValue : public Constant {
// storage is shared between `G1` and `G2`.
void setSanitizerMetadata(SanitizerMetadata Meta);
void removeSanitizerMetadata();
+ void setNoSanitizeMetadata();
bool isTagged() const {
return hasSanitizerMetadata() && getSanitizerMetadata().Memtag;
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index a6165ef13fd790..2a0c1e9e8c446b 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -221,6 +221,12 @@ class IRBuilderBase {
AddOrRemoveMetadataToCopy(LLVMContext::MD_dbg, L.getAsMDNode());
}
+ /// Set nosanitize metadata.
+ void SetNoSanitizeMetadata() {
+ AddOrRemoveMetadataToCopy(llvm::LLVMContext::MD_nosanitize,
+ llvm::MDNode::get(getContext(), std::nullopt));
+ }
+
/// Collect metadata with IDs \p MetadataKinds from \p Src which should be
/// added to all created instructions. Entries present in MedataDataToCopy but
/// not on \p Src will be dropped from MetadataToCopy.
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 481a1d802e66b6..40f854a2c90635 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -243,6 +243,13 @@ void GlobalValue::removeSanitizerMetadata() {
HasSanitizerMetadata = false;
}
+void GlobalValue::setNoSanitizeMetadata() {
+ SanitizerMetadata Meta;
+ Meta.NoAddress = true;
+ Meta.NoHWAddress = true;
+ setSanitizerMetadata(Meta);
+}
+
StringRef GlobalObject::getSectionImpl() const {
assert(hasSection());
return getContext().pImpl->GlobalObjectSections[this];
|
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4 [skip ci]
fmayer
approved these changes
Mar 27, 2024
Created using spr 1.3.4
Created using spr 1.3.4 [skip ci]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This will be used by #86775