Skip to content

Commit 5007fd2

Browse files
author
Robert Marsh
committed
C++: Autoformat and sync
1 parent e416d75 commit 5007fd2

File tree

3 files changed

+44
-46
lines changed

3 files changed

+44
-46
lines changed

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,9 @@ private module Cached {
153153
)
154154
}
155155

156-
pragma[noopt]
156+
pragma[noopt]
157157
cached
158-
Instruction getPhiOperandDefinition(
159-
Phi instr, IRBlock newPredecessorBlock, Overlap overlap
160-
) {
158+
Instruction getPhiOperandDefinition(Phi instr, IRBlock newPredecessorBlock, Overlap overlap) {
161159
exists(
162160
Alias::MemoryLocation defLocation, Alias::MemoryLocation useLocation, OldBlock phiBlock,
163161
OldBlock predBlock, OldBlock defBlock, int defOffset, Alias::MemoryLocation actualDefLocation

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,9 @@ private module Cached {
153153
)
154154
}
155155

156+
pragma[noopt]
156157
cached
157-
Instruction getPhiOperandDefinition(
158-
PhiInstruction instr, IRBlock newPredecessorBlock, Overlap overlap
159-
) {
158+
Instruction getPhiOperandDefinition(Phi instr, IRBlock newPredecessorBlock, Overlap overlap) {
160159
exists(
161160
Alias::MemoryLocation defLocation, Alias::MemoryLocation useLocation, OldBlock phiBlock,
162161
OldBlock predBlock, OldBlock defBlock, int defOffset, Alias::MemoryLocation actualDefLocation
@@ -563,28 +562,29 @@ module DefUse {
563562
/**
564563
* Gets the `Instruction` for the definition at offset `defOffset` in block `defBlock`.
565564
*/
566-
bindingset[defOffset, defLocation]
567-
pragma[inline]
568565
Instruction getDefinitionOrChiInstruction(
569566
OldBlock defBlock, int defOffset, Alias::MemoryLocation defLocation,
570567
Alias::MemoryLocation actualDefLocation
571568
) {
572-
defOffset >= 0 and
573-
exists(OldInstruction oldInstr |
574-
oldInstr = defBlock.getInstruction(defOffset / 2) and
575-
if (defOffset % 2) > 0
576-
then (
577-
// An odd offset corresponds to the `Chi` instruction.
578-
result = Chi(oldInstr) and
579-
actualDefLocation = defLocation.getVirtualVariable()
580-
) else (
581-
// An even offset corresponds to the original instruction.
582-
result = getNewInstruction(oldInstr) and
583-
actualDefLocation = defLocation
584-
)
569+
exists(OldInstruction oldInstr, int oldOffset |
570+
oldInstr = defBlock.getInstruction(oldOffset) and
571+
oldOffset >= 0
572+
|
573+
// An odd offset corresponds to the `Chi` instruction.
574+
defOffset = oldOffset * 2 + 1 and
575+
result = Chi(oldInstr) and
576+
defLocation = Alias::getResultMemoryLocation(oldInstr) and
577+
actualDefLocation = defLocation.getVirtualVariable()
578+
or
579+
// An even offset corresponds to the original instruction.
580+
defOffset = oldOffset * 2 and
581+
result = getNewInstruction(oldInstr) and
582+
defLocation = Alias::getResultMemoryLocation(oldInstr) and
583+
actualDefLocation = defLocation
585584
)
586585
or
587-
defOffset < 0 and
586+
defOffset = -1 and
587+
hasDefinition(_, defLocation, defBlock, defOffset) and
588588
result = Phi(defBlock, defLocation) and
589589
actualDefLocation = defLocation
590590
}
@@ -811,16 +811,16 @@ module DefUse {
811811
* Holds if the `Phi` instruction for location `useLocation` at the beginning of block `phiBlock` has an operand along
812812
* the incoming edge from `predBlock`, where that operand's definition is at offset `defOffset` in block `defBlock`.
813813
*/
814-
pragma[inline]
814+
pragma[noopt]
815815
predicate hasPhiOperandDefinition(
816816
Alias::MemoryLocation defLocation, Alias::MemoryLocation useLocation, OldBlock phiBlock,
817817
OldBlock predBlock, OldBlock defBlock, int defOffset
818818
) {
819819
exists(int defRank |
820820
definitionHasPhiNode(useLocation, phiBlock) and
821821
predBlock = phiBlock.getAFeasiblePredecessor() and
822-
hasDefinitionAtRank(useLocation, defLocation, defBlock, defRank, defOffset) and
823822
definitionReachesEndOfBlock(useLocation, defBlock, defRank, predBlock) and
823+
hasDefinitionAtRank(useLocation, defLocation, defBlock, defRank, defOffset) and
824824
exists(Alias::getOverlap(defLocation, useLocation))
825825
)
826826
}

csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,9 @@ private module Cached {
153153
)
154154
}
155155

156+
pragma[noopt]
156157
cached
157-
Instruction getPhiOperandDefinition(
158-
PhiInstruction instr, IRBlock newPredecessorBlock, Overlap overlap
159-
) {
158+
Instruction getPhiOperandDefinition(Phi instr, IRBlock newPredecessorBlock, Overlap overlap) {
160159
exists(
161160
Alias::MemoryLocation defLocation, Alias::MemoryLocation useLocation, OldBlock phiBlock,
162161
OldBlock predBlock, OldBlock defBlock, int defOffset, Alias::MemoryLocation actualDefLocation
@@ -563,28 +562,29 @@ module DefUse {
563562
/**
564563
* Gets the `Instruction` for the definition at offset `defOffset` in block `defBlock`.
565564
*/
566-
bindingset[defOffset, defLocation]
567-
pragma[inline]
568565
Instruction getDefinitionOrChiInstruction(
569566
OldBlock defBlock, int defOffset, Alias::MemoryLocation defLocation,
570567
Alias::MemoryLocation actualDefLocation
571568
) {
572-
defOffset >= 0 and
573-
exists(OldInstruction oldInstr |
574-
oldInstr = defBlock.getInstruction(defOffset / 2) and
575-
if (defOffset % 2) > 0
576-
then (
577-
// An odd offset corresponds to the `Chi` instruction.
578-
result = Chi(oldInstr) and
579-
actualDefLocation = defLocation.getVirtualVariable()
580-
) else (
581-
// An even offset corresponds to the original instruction.
582-
result = getNewInstruction(oldInstr) and
583-
actualDefLocation = defLocation
584-
)
569+
exists(OldInstruction oldInstr, int oldOffset |
570+
oldInstr = defBlock.getInstruction(oldOffset) and
571+
oldOffset >= 0
572+
|
573+
// An odd offset corresponds to the `Chi` instruction.
574+
defOffset = oldOffset * 2 + 1 and
575+
result = Chi(oldInstr) and
576+
defLocation = Alias::getResultMemoryLocation(oldInstr) and
577+
actualDefLocation = defLocation.getVirtualVariable()
578+
or
579+
// An even offset corresponds to the original instruction.
580+
defOffset = oldOffset * 2 and
581+
result = getNewInstruction(oldInstr) and
582+
defLocation = Alias::getResultMemoryLocation(oldInstr) and
583+
actualDefLocation = defLocation
585584
)
586585
or
587-
defOffset < 0 and
586+
defOffset = -1 and
587+
hasDefinition(_, defLocation, defBlock, defOffset) and
588588
result = Phi(defBlock, defLocation) and
589589
actualDefLocation = defLocation
590590
}
@@ -811,16 +811,16 @@ module DefUse {
811811
* Holds if the `Phi` instruction for location `useLocation` at the beginning of block `phiBlock` has an operand along
812812
* the incoming edge from `predBlock`, where that operand's definition is at offset `defOffset` in block `defBlock`.
813813
*/
814-
pragma[inline]
814+
pragma[noopt]
815815
predicate hasPhiOperandDefinition(
816816
Alias::MemoryLocation defLocation, Alias::MemoryLocation useLocation, OldBlock phiBlock,
817817
OldBlock predBlock, OldBlock defBlock, int defOffset
818818
) {
819819
exists(int defRank |
820820
definitionHasPhiNode(useLocation, phiBlock) and
821821
predBlock = phiBlock.getAFeasiblePredecessor() and
822-
hasDefinitionAtRank(useLocation, defLocation, defBlock, defRank, defOffset) and
823822
definitionReachesEndOfBlock(useLocation, defBlock, defRank, predBlock) and
823+
hasDefinitionAtRank(useLocation, defLocation, defBlock, defRank, defOffset) and
824824
exists(Alias::getOverlap(defLocation, useLocation))
825825
)
826826
}

0 commit comments

Comments
 (0)