Skip to content

Commit ae503b2

Browse files
author
AndreiDiaconu1
committed
Remove incorrect Load
Removed an incorrect `Load` op generated by propery accesses.
1 parent 3c95205 commit ae503b2

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ private predicate ignoreLoad(Expr expr) {
212212
// address is the final value of the expression
213213
expr.getParent() instanceof AddressOfExpr
214214
or
215+
// A property access does not need a load since it is a call
216+
expr instanceof PropertyAccess
217+
or
215218
// If expr is a variable access used as the qualifier for a field access and
216219
// its target variable is a value type variable,
217220
// ignore the load since the address of a variable that is a value type is

csharp/ql/test/library-tests/ir/ir/raw_ir.expected

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,20 +1169,19 @@ pointers.cs:
11691169
# 5| r0_8(glval<null>) = FunctionAddress[get_Length] :
11701170
# 5| r0_9(Int32) = Call : func:r0_8, this:r0_7
11711171
# 5| mu0_10(null) = ^CallSideEffect : ~mu0_2
1172-
# 5| r0_11(Int32) = Load : &:r0_9, ~mu0_2
1173-
# 5| mu0_12(Int32) = Store : &:r0_5, r0_11
1174-
# 6| r0_13(glval<Int32*>) = VariableAddress[b] :
1175-
# 6| r0_14(glval<Int32[]>) = VariableAddress[arr] :
1176-
# 6| r0_15(Int32[]) = Load : &:r0_14, ~mu0_2
1177-
# 6| r0_16(Int32*) = Convert : r0_15
1178-
# 6| mu0_17(Int32*) = Store : &:r0_13, r0_15
1179-
# 8| r0_18(glval<Int32*>) = VariableAddress[p] :
1180-
# 8| r0_19(glval<Int32*>) = VariableAddress[b] :
1181-
# 8| r0_20(Int32*) = Load : &:r0_19, ~mu0_2
1182-
# 8| mu0_21(Int32*) = Store : &:r0_18, r0_20
1183-
# 9| r0_22(glval<Int32>) = VariableAddress[i] :
1184-
# 9| r0_23(Int32) = Constant[0] :
1185-
# 9| mu0_24(Int32) = Store : &:r0_22, r0_23
1172+
# 5| mu0_11(Int32) = Store : &:r0_5, r0_9
1173+
# 6| r0_12(glval<Int32*>) = VariableAddress[b] :
1174+
# 6| r0_13(glval<Int32[]>) = VariableAddress[arr] :
1175+
# 6| r0_14(Int32[]) = Load : &:r0_13, ~mu0_2
1176+
# 6| r0_15(Int32*) = Convert : r0_14
1177+
# 6| mu0_16(Int32*) = Store : &:r0_12, r0_14
1178+
# 8| r0_17(glval<Int32*>) = VariableAddress[p] :
1179+
# 8| r0_18(glval<Int32*>) = VariableAddress[b] :
1180+
# 8| r0_19(Int32*) = Load : &:r0_18, ~mu0_2
1181+
# 8| mu0_20(Int32*) = Store : &:r0_17, r0_19
1182+
# 9| r0_21(glval<Int32>) = VariableAddress[i] :
1183+
# 9| r0_22(Int32) = Constant[0] :
1184+
# 9| mu0_23(Int32) = Store : &:r0_21, r0_22
11861185
#-----| Goto -> Block 2
11871186

11881187
# 3| Block 1
@@ -1357,11 +1356,10 @@ prop.cs:
13571356
# 30| r0_18(glval<null>) = FunctionAddress[get_Prop] :
13581357
# 30| r0_19(Int32) = Call : func:r0_18, this:r0_17
13591358
# 30| mu0_20(null) = ^CallSideEffect : ~mu0_2
1360-
# 30| r0_21(Int32) = Load : &:r0_19, ~mu0_2
1361-
# 30| mu0_22(Int32) = Store : &:r0_15, r0_21
1362-
# 26| v0_23(Void) = ReturnVoid :
1363-
# 26| v0_24(Void) = UnmodeledUse : mu*
1364-
# 26| v0_25(Void) = ExitFunction :
1359+
# 30| mu0_21(Int32) = Store : &:r0_15, r0_19
1360+
# 26| v0_22(Void) = ReturnVoid :
1361+
# 26| v0_23(Void) = UnmodeledUse : mu*
1362+
# 26| v0_24(Void) = ExitFunction :
13651363

13661364
simple_call.cs:
13671365
# 5| System.Int32 test_simple_call.f()

0 commit comments

Comments
 (0)