-
Notifications
You must be signed in to change notification settings - Fork 0
Change getTgtMemIntrinsic interface with returning a pair #1
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
Changes from 3 commits
55c3ad2
d88808b
867b0d7
7e574c7
f2abced
e89d6ba
9f26e22
665ebae
766d8c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -975,9 +975,10 @@ class TargetTransformInfoImplBase { | |||||||
| return 0; | ||||||||
| } | ||||||||
|
|
||||||||
| virtual bool getTgtMemIntrinsic(IntrinsicInst *Inst, | ||||||||
| MemIntrinsicInfo &Info) const { | ||||||||
| return false; | ||||||||
| virtual std::pair<std::optional<MemIntrinsicInfo>, | ||||||||
| std::optional<SmallVector<InterestingMemoryOperand, 1>>> | ||||||||
|
||||||||
| std::optional<SmallVector<InterestingMemoryOperand, 1>>> | |
| std::pair<MemIntrinsicInfo, | |
| SmallVector<InterestingMemoryOperand, 1>> |
The interface after dropping std::optional will look like this.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |||||
| #include "llvm/Analysis/MemoryBuiltins.h" | ||||||
| #include "llvm/Analysis/StackSafetyAnalysis.h" | ||||||
| #include "llvm/Analysis/TargetLibraryInfo.h" | ||||||
| #include "llvm/Analysis/TargetTransformInfo.h" | ||||||
| #include "llvm/Analysis/ValueTracking.h" | ||||||
| #include "llvm/BinaryFormat/MachO.h" | ||||||
| #include "llvm/Demangle/Demangle.h" | ||||||
|
|
@@ -803,7 +804,8 @@ struct AddressSanitizer { | |||||
|
|
||||||
| bool ignoreAccess(Instruction *Inst, Value *Ptr); | ||||||
| void getInterestingMemoryOperands( | ||||||
| Instruction *I, SmallVectorImpl<InterestingMemoryOperand> &Interesting); | ||||||
| Instruction *I, SmallVectorImpl<InterestingMemoryOperand> &Interesting, | ||||||
| const TargetTransformInfo *TTI); | ||||||
|
|
||||||
| void instrumentMop(ObjectSizeOffsetVisitor &ObjSizeVis, | ||||||
| InterestingMemoryOperand &O, bool UseCalls, | ||||||
|
|
@@ -843,7 +845,7 @@ struct AddressSanitizer { | |||||
| void instrumentMemIntrinsic(MemIntrinsic *MI, RuntimeCallInserter &RTCI); | ||||||
| Value *memToShadow(Value *Shadow, IRBuilder<> &IRB); | ||||||
| bool suppressInstrumentationSiteForDebug(int &Instrumented); | ||||||
| bool instrumentFunction(Function &F, const TargetLibraryInfo *TLI); | ||||||
| bool instrumentFunction(Function &F, const TargetLibraryInfo *TLI, const TargetTransformInfo *TTI); | ||||||
| bool maybeInsertAsanInitAtFunctionEntry(Function &F); | ||||||
| bool maybeInsertDynamicShadowAtFunctionEntry(Function &F); | ||||||
| void markEscapedLocalAllocas(Function &F); | ||||||
|
|
@@ -1312,7 +1314,8 @@ PreservedAnalyses AddressSanitizerPass::run(Module &M, | |||||
| Options.MaxInlinePoisoningSize, Options.CompileKernel, Options.Recover, | ||||||
| Options.UseAfterScope, Options.UseAfterReturn); | ||||||
| const TargetLibraryInfo &TLI = FAM.getResult<TargetLibraryAnalysis>(F); | ||||||
| Modified |= FunctionSanitizer.instrumentFunction(F, &TLI); | ||||||
| const TargetTransformInfo &TTI = FAM.getResult<TargetIRAnalysis>(F); | ||||||
| Modified |= FunctionSanitizer.instrumentFunction(F, &TLI, &TTI); | ||||||
| } | ||||||
| Modified |= ModuleSanitizer.instrumentModule(); | ||||||
| if (!Modified) | ||||||
|
|
@@ -1450,7 +1453,8 @@ bool AddressSanitizer::ignoreAccess(Instruction *Inst, Value *Ptr) { | |||||
| } | ||||||
|
|
||||||
| void AddressSanitizer::getInterestingMemoryOperands( | ||||||
| Instruction *I, SmallVectorImpl<InterestingMemoryOperand> &Interesting) { | ||||||
| Instruction *I, SmallVectorImpl<InterestingMemoryOperand> &Interesting, | ||||||
| const TargetTransformInfo *TTI) { | ||||||
| // Do not instrument the load fetching the dynamic shadow address. | ||||||
| if (LocalDynamicShadow == I) | ||||||
| return; | ||||||
|
|
@@ -1568,6 +1572,15 @@ void AddressSanitizer::getInterestingMemoryOperands( | |||||
| break; | ||||||
| } | ||||||
| default: | ||||||
| if (auto *II = dyn_cast<IntrinsicInst>(I)) { | ||||||
| std::pair<std::optional<MemIntrinsicInfo>, | ||||||
| std::optional<SmallVector<InterestingMemoryOperand, 1>>> | ||||||
| MemInfo; | ||||||
| MemInfo = TTI->getTgtMemIntrinsic(II); | ||||||
| if (MemInfo.second != std::nullopt) | ||||||
|
||||||
| if (MemInfo.second != std::nullopt) | |
| if (!MemInfo.second.empty()) |
Check the SmallVector is empty or not.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think Analysis should include a header from Transforms. The Transforms library has a dependency on the Analysis library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. The reason I include this header from Transforms is to use
InterestingMemoryOperand, maybe moveInterestingMemoryOperandfrom Transforms header toAnalysis/InterestingMemoryOperand.hand include it inTransforms/Instrumentation/AddressSanitizerCommon.h?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good to me.