-
Notifications
You must be signed in to change notification settings - Fork 2.1k
C++: Global value numbering for function calls #9892
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
base: main
Are you sure you want to change the base?
Changes from all commits
0b691dd
76b292d
cc8e65f
4ae2187
d324969
c09c38c
844aabe
e0cfbb5
83af49c
5c11062
7c4d380
af2c96f
fac28cc
dc105b4
86bb9c3
9f17bd0
e13ae70
5b51fcb
99b21b3
ba1005f
9ddacf5
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 |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Multiple function calls made in the same function may now receive the same global value number when the analysis can show they produce the same results. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import semmle.code.cpp.ir.implementation.aliased_ssa.IR | ||
| import semmle.code.cpp.ir.internal.Overlap | ||
| import semmle.code.cpp.ir.internal.IRCppLanguage as Language | ||
| import semmle.code.cpp.models.interfaces.SideEffect as SideEffect |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import cpp as CPP | ||
| import semmle.code.cpp.ir.implementation.unaliased_ssa.IR as Unaliased | ||
| import AliasAnalysis as Alias | ||
| import AliasConfiguration as Conf | ||
| import semmle.code.cpp.models.interfaces.SideEffect as SideEffect | ||
|
|
||
| private predicate noLocalSideEffectWrite(CPP::Function func) { | ||
| forall(Unaliased::AddressOperand addr | addr.getUse().getEnclosingFunction() = func | | ||
| not ( | ||
| Alias::getAddressOperandAllocation(addr) instanceof Conf::VariableAllocation and | ||
| Alias::getAddressOperandAllocation(addr).(Conf::VariableAllocation).alwaysEscapes() | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| language[monotonicAggregates] | ||
| private predicate noTransitiveSideEffectWrite(CPP::Function func) { | ||
| exists(Unaliased::IRFunction irFunc | irFunc.getFunction() = func) and | ||
| noLocalSideEffectWrite(func) and | ||
| forall(Unaliased::CallInstruction call | call.getEnclosingFunction() = func | | ||
| exists(call.getStaticCallTarget()) | ||
| ) and | ||
| forall(Unaliased::CallInstruction call, CPP::Function callee | | ||
| call.getStaticCallTarget() = callee and | ||
| call.getEnclosingFunction() = func | ||
| | | ||
| noTransitiveSideEffectWrite(callee) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm always scared of recursion through |
||
| or | ||
| callee.(SideEffect::SideEffectFunction).hasOnlySpecificWriteSideEffects() | ||
| ) | ||
| } | ||
|
|
||
| predicate removeableSideEffect(Unaliased::SideEffectInstruction instr) { | ||
| ( | ||
| instr instanceof Unaliased::CallSideEffectInstruction or | ||
| instr instanceof Unaliased::CallReadSideEffectInstruction | ||
| ) and | ||
| noTransitiveSideEffectWrite(instr | ||
| .getPrimaryInstruction() | ||
| .(Unaliased::CallInstruction) | ||
| .getStaticCallTarget()) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,5 @@ import semmle.code.cpp.ir.implementation.aliased_ssa.internal.SSAConstruction as | |
|
|
||
| /** DEPRECATED: Alias for AliasedSsa */ | ||
| deprecated module AliasedSSA = AliasedSsa; | ||
|
|
||
| import semmle.code.cpp.ir.implementation.aliased_ssa.internal.SideEffectElimination as Elim | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you've checked |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import semmle.code.cpp.ir.implementation.aliased_ssa.IR | ||
| import semmle.code.cpp.ir.internal.Overlap | ||
| import semmle.code.cpp.ir.internal.IRCppLanguage as Language | ||
| import semmle.code.cpp.models.interfaces.SideEffect as SideEffect |
Uh oh!
There was an error while loading. Please reload this page.