Skip to content

Commit df2b313

Browse files
authored
Merge pull request github#14155 from alexet/reach-end-of-function-return
CPP: Make functions that reach the end return.
2 parents 38892bb + e8dfecc commit df2b313

File tree

7 files changed

+116
-90
lines changed

7 files changed

+116
-90
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Treat functions that reach the end of the function as returning in the IR.
5+
They used to be treated as unreachable but it is allowed in C.

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/IRConstruction.qll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,6 @@ predicate hasUnreachedInstruction(IRFunction func) {
405405
exists(Call c |
406406
c.getEnclosingFunction() = func.getFunction() and
407407
any(Options opt).exits(c.getTarget())
408-
) and
409-
not exists(TranslatedUnreachableReturnStmt return |
410-
return.getEnclosingFunction().getFunction() = func.getFunction()
411408
)
412409
}
413410

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedStmt.qll

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -442,29 +442,26 @@ class TranslatedReturnVoidStmt extends TranslatedReturnStmt {
442442

443443
/**
444444
* The IR translation of an implicit `return` statement generated by the extractor to handle control
445-
* flow that reaches the end of a non-`void`-returning function body. Since such control flow
446-
* produces undefined behavior, we simply generate an `Unreached` instruction to prevent that flow
447-
* from continuing on to pollute other analysis. The assumption is that the developer is certain
448-
* that the implicit `return` is unreachable, even if the compiler cannot prove it.
445+
* flow that reaches the end of a non-`void`-returning function body. Such control flow
446+
* produces undefined behavior in C++ but not in C. However even in C using the return value is
447+
* undefined behaviour. We make it return uninitialized memory to get as much flow as possible.
449448
*/
450-
class TranslatedUnreachableReturnStmt extends TranslatedReturnStmt {
451-
TranslatedUnreachableReturnStmt() {
449+
class TranslatedNoValueReturnStmt extends TranslatedReturnStmt, TranslatedVariableInitialization {
450+
TranslatedNoValueReturnStmt() {
452451
not stmt.hasExpr() and hasReturnValue(stmt.getEnclosingFunction())
453452
}
454453

455-
override TranslatedElement getChild(int id) { none() }
456-
457-
override Instruction getFirstInstruction() { result = this.getInstruction(OnlyInstructionTag()) }
458-
459-
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
460-
tag = OnlyInstructionTag() and
461-
opcode instanceof Opcode::Unreached and
462-
resultType = getVoidType()
454+
final override Instruction getInitializationSuccessor() {
455+
result = this.getEnclosingFunction().getReturnSuccessorInstruction()
463456
}
464457

465-
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
458+
final override Type getTargetType() { result = this.getEnclosingFunction().getReturnType() }
466459

467-
override Instruction getChildSuccessor(TranslatedElement child) { none() }
460+
final override TranslatedInitialization getInitialization() { none() }
461+
462+
final override IRVariable getIRVariable() {
463+
result = this.getEnclosingFunction().getReturnVariable()
464+
}
468465
}
469466

470467
/**

cpp/ql/test/library-tests/ir/ir/operand_locations.expected

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6207,10 +6207,12 @@
62076207
| ir.cpp:1286:25:1286:49 | ChiPartial | partial:m1286_7 |
62086208
| ir.cpp:1286:25:1286:49 | ChiTotal | total:m1286_4 |
62096209
| ir.cpp:1286:25:1286:49 | SideEffect | ~m1286_4 |
6210-
| ir.cpp:1289:5:1289:22 | Address | &:r1289_9 |
6210+
| ir.cpp:1289:5:1289:22 | Address | &:r1289_10 |
62116211
| ir.cpp:1289:5:1289:22 | ChiPartial | partial:m1289_3 |
62126212
| ir.cpp:1289:5:1289:22 | ChiTotal | total:m1289_2 |
6213-
| ir.cpp:1289:5:1289:22 | Load | m1291_4 |
6213+
| ir.cpp:1289:5:1289:22 | Load | m1289_9 |
6214+
| ir.cpp:1289:5:1289:22 | Phi | from 2:m1291_4 |
6215+
| ir.cpp:1289:5:1289:22 | Phi | from 3:m1293_2 |
62146216
| ir.cpp:1289:5:1289:22 | SideEffect | m1289_3 |
62156217
| ir.cpp:1289:29:1289:29 | Address | &:r1289_5 |
62166218
| ir.cpp:1289:36:1289:36 | Address | &:r1289_7 |
@@ -6221,6 +6223,7 @@
62216223
| ir.cpp:1291:16:1291:16 | Address | &:r1291_2 |
62226224
| ir.cpp:1291:16:1291:16 | Load | m1289_8 |
62236225
| ir.cpp:1291:16:1291:16 | StoreValue | r1291_3 |
6226+
| ir.cpp:1293:1:1293:1 | Address | &:r1293_1 |
62246227
| ir.cpp:1295:6:1295:15 | ChiPartial | partial:m1295_3 |
62256228
| ir.cpp:1295:6:1295:15 | ChiTotal | total:m1295_2 |
62266229
| ir.cpp:1295:6:1295:15 | SideEffect | ~m1296_8 |
@@ -8393,16 +8396,23 @@
83938396
| ir.cpp:1747:39:1747:39 | ChiTotal | total:m1747_20 |
83948397
| ir.cpp:1747:39:1747:39 | SideEffect | ~m1747_4 |
83958398
| ir.cpp:1747:39:1747:39 | SideEffect | ~m1747_15 |
8399+
| ir.cpp:1750:5:1750:34 | Address | &:r1750_5 |
83968400
| ir.cpp:1750:5:1750:34 | ChiPartial | partial:m1750_3 |
83978401
| ir.cpp:1750:5:1750:34 | ChiTotal | total:m1750_2 |
8402+
| ir.cpp:1750:5:1750:34 | Load | m1755_2 |
8403+
| ir.cpp:1750:5:1750:34 | SideEffect | ~m1754_10 |
83988404
| ir.cpp:1751:51:1751:51 | Address | &:r1751_1 |
83998405
| ir.cpp:1751:51:1751:51 | Address | &:r1751_1 |
84008406
| ir.cpp:1751:51:1751:51 | Address | &:r1751_3 |
8407+
| ir.cpp:1751:51:1751:51 | Address | &:r1751_3 |
84018408
| ir.cpp:1751:51:1751:51 | Load | m1751_2 |
8409+
| ir.cpp:1751:51:1751:51 | SideEffect | m1751_4 |
84028410
| ir.cpp:1752:48:1752:48 | Address | &:r1752_1 |
84038411
| ir.cpp:1752:48:1752:48 | Address | &:r1752_1 |
84048412
| ir.cpp:1752:48:1752:48 | Address | &:r1752_3 |
8413+
| ir.cpp:1752:48:1752:48 | Address | &:r1752_3 |
84058414
| ir.cpp:1752:48:1752:48 | Load | m1752_2 |
8415+
| ir.cpp:1752:48:1752:48 | SideEffect | m1752_4 |
84068416
| ir.cpp:1753:40:1753:41 | Address | &:r1753_1 |
84078417
| ir.cpp:1753:40:1753:41 | Address | &:r1753_1 |
84088418
| ir.cpp:1753:40:1753:41 | Arg(this) | this:r1753_1 |
@@ -8435,6 +8445,7 @@
84358445
| ir.cpp:1754:42:1754:42 | SideEffect | ~m1752_4 |
84368446
| ir.cpp:1754:42:1754:42 | Unary | r1754_5 |
84378447
| ir.cpp:1754:42:1754:42 | Unary | r1754_6 |
8448+
| ir.cpp:1755:1:1755:1 | Address | &:r1755_1 |
84388449
| ir.cpp:1757:6:1757:22 | ChiPartial | partial:m1757_3 |
84398450
| ir.cpp:1757:6:1757:22 | ChiTotal | total:m1757_2 |
84408451
| ir.cpp:1757:6:1757:22 | SideEffect | m1757_3 |
@@ -9588,22 +9599,27 @@
95889599
| ir.cpp:2021:23:2021:40 | SideEffect | ~m2021_27 |
95899600
| ir.cpp:2021:23:2021:40 | Unary | r2021_20 |
95909601
| ir.cpp:2021:23:2021:40 | Unary | r2021_28 |
9602+
| ir.cpp:2026:14:2026:22 | Address | &:r2026_7 |
95919603
| ir.cpp:2026:14:2026:22 | ChiPartial | partial:m2026_3 |
95929604
| ir.cpp:2026:14:2026:22 | ChiTotal | total:m2026_2 |
9605+
| ir.cpp:2026:14:2026:22 | Load | m2031_2 |
9606+
| ir.cpp:2026:14:2026:22 | SideEffect | ~m2028_6 |
95939607
| ir.cpp:2026:37:2026:37 | Address | &:r2026_5 |
95949608
| ir.cpp:2027:16:2027:16 | Address | &:r2027_1 |
9595-
| ir.cpp:2028:3:2028:3 | Address | &:r2028_9 |
9609+
| ir.cpp:2028:3:2028:3 | Address | &:r2028_10 |
95969610
| ir.cpp:2028:7:2028:7 | Address | &:r2028_1 |
95979611
| ir.cpp:2028:7:2028:7 | Left | r2028_2 |
95989612
| ir.cpp:2028:7:2028:7 | Load | m2026_6 |
95999613
| ir.cpp:2028:7:2028:13 | Condition | r2028_4 |
9600-
| ir.cpp:2028:7:2030:28 | Address | &:r2028_7 |
9601-
| ir.cpp:2028:7:2030:28 | Address | &:r2028_11 |
9602-
| ir.cpp:2028:7:2030:28 | Address | &:r2028_13 |
9603-
| ir.cpp:2028:7:2030:28 | Load | m2028_6 |
9604-
| ir.cpp:2028:7:2030:28 | Phi | from 2:m2028_12 |
9605-
| ir.cpp:2028:7:2030:28 | Phi | from 3:m2028_14 |
9606-
| ir.cpp:2028:7:2030:28 | StoreValue | r2028_8 |
9614+
| ir.cpp:2028:7:2030:28 | Address | &:r2028_8 |
9615+
| ir.cpp:2028:7:2030:28 | Address | &:r2028_12 |
9616+
| ir.cpp:2028:7:2030:28 | Address | &:r2028_14 |
9617+
| ir.cpp:2028:7:2030:28 | Load | m2028_7 |
9618+
| ir.cpp:2028:7:2030:28 | Phi | from 2:m2028_13 |
9619+
| ir.cpp:2028:7:2030:28 | Phi | from 2:~m2029_6 |
9620+
| ir.cpp:2028:7:2030:28 | Phi | from 3:m2028_15 |
9621+
| ir.cpp:2028:7:2030:28 | Phi | from 3:~m2030_6 |
9622+
| ir.cpp:2028:7:2030:28 | StoreValue | r2028_9 |
96079623
| ir.cpp:2028:11:2028:13 | Right | r2028_3 |
96089624
| ir.cpp:2029:6:2029:20 | CallTarget | func:r2029_1 |
96099625
| ir.cpp:2029:6:2029:20 | ChiPartial | partial:m2029_5 |
@@ -9626,6 +9642,7 @@
96269642
| ir.cpp:2030:22:2030:22 | Arg(0) | 0:r2030_3 |
96279643
| ir.cpp:2030:22:2030:22 | Load | m2026_6 |
96289644
| ir.cpp:2030:26:2030:27 | Unary | r2030_7 |
9645+
| ir.cpp:2031:1:2031:1 | Address | &:r2031_1 |
96299646
| ir.cpp:2033:6:2033:17 | ChiPartial | partial:m2033_3 |
96309647
| ir.cpp:2033:6:2033:17 | ChiTotal | total:m2033_2 |
96319648
| ir.cpp:2033:6:2033:17 | SideEffect | ~m2036_6 |
@@ -9721,8 +9738,11 @@
97219738
| ir.cpp:2051:32:2051:32 | Address | &:r2051_7 |
97229739
| ir.cpp:2051:32:2051:32 | Load | m2051_6 |
97239740
| ir.cpp:2051:32:2051:32 | SideEffect | m2051_8 |
9741+
| ir.cpp:2056:5:2056:18 | Address | &:r2056_5 |
97249742
| ir.cpp:2056:5:2056:18 | ChiPartial | partial:m2056_3 |
97259743
| ir.cpp:2056:5:2056:18 | ChiTotal | total:m2056_2 |
9744+
| ir.cpp:2056:5:2056:18 | Load | m2066_2 |
9745+
| ir.cpp:2056:5:2056:18 | SideEffect | ~m2065_6 |
97269746
| ir.cpp:2058:12:2058:13 | Address | &:r2058_1 |
97279747
| ir.cpp:2058:17:2058:27 | Address | &:r2058_4 |
97289748
| ir.cpp:2058:17:2058:27 | Address | &:r2058_8 |
@@ -9796,6 +9816,7 @@
97969816
| ir.cpp:2065:12:2065:12 | Address | &:r2065_2 |
97979817
| ir.cpp:2065:12:2065:12 | Arg(0) | 0:r2065_3 |
97989818
| ir.cpp:2065:12:2065:12 | Load | m2064_15 |
9819+
| ir.cpp:2066:1:2066:1 | Address | &:r2066_1 |
97999820
| ir.cpp:2070:6:2070:26 | ChiPartial | partial:m2070_3 |
98009821
| ir.cpp:2070:6:2070:26 | ChiTotal | total:m2070_2 |
98019822
| ir.cpp:2070:6:2070:26 | SideEffect | ~m2072_5 |

cpp/ql/test/library-tests/ir/ir/raw_consistency.expected

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ unnecessaryPhiInstruction
1212
memoryOperandDefinitionIsUnmodeled
1313
operandAcrossFunctions
1414
instructionWithoutUniqueBlock
15+
missingCanonicalLanguageType
16+
multipleCanonicalLanguageTypes
1517
containsLoopOfForwardEdges
18+
missingIRType
19+
multipleIRTypes
1620
lostReachability
1721
backEdgeCountMismatch
1822
useNotDominatedByDefinition
1923
| ir.cpp:1486:8:1486:8 | Unary | Operand 'Unary' is not dominated by its definition in function '$@'. | ir.cpp:1486:8:1486:8 | void StructuredBindingDataMemberStruct::StructuredBindingDataMemberStruct() | void StructuredBindingDataMemberStruct::StructuredBindingDataMemberStruct() |
20-
| ir.cpp:1751:51:1751:51 | Address | Operand 'Address' is not dominated by its definition in function '$@'. | ir.cpp:1750:5:1750:34 | int implicit_copy_constructor_test(CopyConstructorTestNonVirtualClass const&, CopyConstructorTestVirtualClass const&) | int implicit_copy_constructor_test(CopyConstructorTestNonVirtualClass const&, CopyConstructorTestVirtualClass const&) |
21-
| ir.cpp:1752:48:1752:48 | Address | Operand 'Address' is not dominated by its definition in function '$@'. | ir.cpp:1750:5:1750:34 | int implicit_copy_constructor_test(CopyConstructorTestNonVirtualClass const&, CopyConstructorTestVirtualClass const&) | int implicit_copy_constructor_test(CopyConstructorTestNonVirtualClass const&, CopyConstructorTestVirtualClass const&) |
2224
| try_except.c:13:13:13:13 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.c:6:6:6:6 | void f() | void f() |
2325
| try_except.c:13:13:13:13 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.c:6:6:6:6 | void f() | void f() |
2426
| try_except.c:39:15:39:15 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.c:32:6:32:6 | void h(int) | void h(int) |
@@ -35,8 +37,4 @@ nonUniqueEnclosingIRFunction
3537
fieldAddressOnNonPointer
3638
thisArgumentIsNonPointer
3739
nonUniqueIRVariable
38-
missingCanonicalLanguageType
39-
multipleCanonicalLanguageTypes
40-
missingIRType
41-
multipleIRTypes
4240
missingCppType

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

Lines changed: 59 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7201,21 +7201,26 @@ ir.cpp:
72017201
# 1290| r1290_1(glval<bool>) = VariableAddress[b] :
72027202
# 1290| r1290_2(bool) = Load[b] : &:r1290_1, ~m?
72037203
# 1290| v1290_3(void) = ConditionalBranch : r1290_2
7204-
#-----| False -> Block 2
7205-
#-----| True -> Block 1
7204+
#-----| False -> Block 3
7205+
#-----| True -> Block 2
72067206

7207-
# 1291| Block 1
7208-
# 1291| r1291_1(glval<int>) = VariableAddress[#return] :
7209-
# 1291| r1291_2(glval<int>) = VariableAddress[x] :
7210-
# 1291| r1291_3(int) = Load[x] : &:r1291_2, ~m?
7211-
# 1291| mu1291_4(int) = Store[#return] : &:r1291_1, r1291_3
7207+
# 1289| Block 1
72127208
# 1289| r1289_8(glval<int>) = VariableAddress[#return] :
72137209
# 1289| v1289_9(void) = ReturnValue : &:r1289_8, ~m?
72147210
# 1289| v1289_10(void) = AliasedUse : ~m?
72157211
# 1289| v1289_11(void) = ExitFunction :
72167212

7217-
# 1293| Block 2
7218-
# 1293| v1293_1(void) = Unreached :
7213+
# 1291| Block 2
7214+
# 1291| r1291_1(glval<int>) = VariableAddress[#return] :
7215+
# 1291| r1291_2(glval<int>) = VariableAddress[x] :
7216+
# 1291| r1291_3(int) = Load[x] : &:r1291_2, ~m?
7217+
# 1291| mu1291_4(int) = Store[#return] : &:r1291_1, r1291_3
7218+
#-----| Goto -> Block 1
7219+
7220+
# 1293| Block 3
7221+
# 1293| r1293_1(glval<int>) = VariableAddress[#return] :
7222+
# 1293| mu1293_2(int) = Uninitialized[#return] : &:r1293_1
7223+
#-----| Goto -> Block 1
72197224

72207225
# 1295| void returnVoid(int, int)
72217226
# 1295| Block 0
@@ -9526,15 +9531,14 @@ ir.cpp:
95269531
# 1754| mu1754_9(unknown) = ^CallSideEffect : ~m?
95279532
# 1754| v1754_10(void) = ^BufferReadSideEffect[0] : &:r1754_7, ~m?
95289533
# 1754| mu1754_11(CopyConstructorTestVirtualClass) = ^IndirectMayWriteSideEffect[-1] : &:r1754_1
9529-
# 1755| v1755_1(void) = Unreached :
9530-
9531-
# 1751| Block 1
9532-
# 1751| v1751_5(void) = ReturnIndirection[x] : &:r1751_3, ~m?
9533-
# 1752| v1752_5(void) = ReturnIndirection[y] : &:r1752_3, ~m?
9534-
# 1750| r1750_4(glval<int>) = VariableAddress[#return] :
9535-
# 1750| v1750_5(void) = ReturnValue : &:r1750_4, ~m?
9536-
# 1750| v1750_6(void) = AliasedUse : ~m?
9537-
# 1750| v1750_7(void) = ExitFunction :
9534+
# 1755| r1755_1(glval<int>) = VariableAddress[#return] :
9535+
# 1755| mu1755_2(int) = Uninitialized[#return] : &:r1755_1
9536+
# 1751| v1751_5(void) = ReturnIndirection[x] : &:r1751_3, ~m?
9537+
# 1752| v1752_5(void) = ReturnIndirection[y] : &:r1752_3, ~m?
9538+
# 1750| r1750_4(glval<int>) = VariableAddress[#return] :
9539+
# 1750| v1750_5(void) = ReturnValue : &:r1750_4, ~m?
9540+
# 1750| v1750_6(void) = AliasedUse : ~m?
9541+
# 1750| v1750_7(void) = ExitFunction :
95389542

95399543
# 1757| void if_initialization(int)
95409544
# 1757| Block 0
@@ -10199,24 +10203,32 @@ ir.cpp:
1019910203
# 1900| r1900_3(int) = Constant[10] :
1020010204
# 1900| r1900_4(bool) = CompareLT : r1900_2, r1900_3
1020110205
# 1900| v1900_5(void) = ConditionalBranch : r1900_4
10202-
#-----| False -> Block 2
10203-
#-----| True -> Block 1
10206+
#-----| False -> Block 3
10207+
#-----| True -> Block 2
1020410208

10205-
# 1901| Block 1
10206-
# 1901| r1901_1(glval<int>) = VariableAddress[#return] :
10207-
# 1901| r1901_2(glval<int>) = VariableAddress[x] :
10208-
# 1901| r1901_3(int) = Load[x] : &:r1901_2, ~m?
10209-
# 1901| mu1901_4(int) = Store[#return] : &:r1901_1, r1901_3
10209+
# 1899| Block 1
1021010210
# 1899| r1899_6(glval<int>) = VariableAddress[#return] :
1021110211
# 1899| v1899_7(void) = ReturnValue : &:r1899_6, ~m?
1021210212
# 1899| v1899_8(void) = AliasedUse : ~m?
1021310213
# 1899| v1899_9(void) = ExitFunction :
1021410214

10215-
# 1903| Block 2
10215+
# 1901| Block 2
10216+
# 1901| r1901_1(glval<int>) = VariableAddress[#return] :
10217+
# 1901| r1901_2(glval<int>) = VariableAddress[x] :
10218+
# 1901| r1901_3(int) = Load[x] : &:r1901_2, ~m?
10219+
# 1901| mu1901_4(int) = Store[#return] : &:r1901_1, r1901_3
10220+
#-----| Goto -> Block 1
10221+
10222+
# 1903| Block 3
1021610223
# 1903| r1903_1(glval<unknown>) = FunctionAddress[noreturnFunc] :
1021710224
# 1903| v1903_2(void) = Call[noreturnFunc] : func:r1903_1
1021810225
# 1903| mu1903_3(unknown) = ^CallSideEffect : ~m?
10219-
# 1905| v1905_1(void) = Unreached :
10226+
# 1899| v1899_10(void) = Unreached :
10227+
10228+
# 1905| Block 4
10229+
# 1905| r1905_1(glval<int>) = VariableAddress[#return] :
10230+
# 1905| mu1905_2(int) = Uninitialized[#return] : &:r1905_1
10231+
#-----| Goto -> Block 1
1022010232

1022110233
# 1907| int noreturnTest2(int)
1022210234
# 1907| Block 0
@@ -11069,23 +11081,22 @@ ir.cpp:
1106911081
# 2028| r2028_3(unsigned int) = Constant[100] :
1107011082
# 2028| r2028_4(bool) = CompareLT : r2028_2, r2028_3
1107111083
# 2028| v2028_5(void) = ConditionalBranch : r2028_4
11072-
#-----| False -> Block 4
11073-
#-----| True -> Block 3
11074-
11075-
# 2026| Block 1
11076-
# 2026| r2026_6(glval<unsigned int>) = VariableAddress[#return] :
11077-
# 2026| v2026_7(void) = ReturnValue : &:r2026_6, ~m?
11078-
# 2026| v2026_8(void) = AliasedUse : ~m?
11079-
# 2026| v2026_9(void) = ExitFunction :
11084+
#-----| False -> Block 3
11085+
#-----| True -> Block 2
1108011086

11081-
# 2028| Block 2
11087+
# 2028| Block 1
1108211088
# 2028| r2028_6(glval<unsigned int>) = VariableAddress[#temp2028:7] :
1108311089
# 2028| r2028_7(unsigned int) = Load[#temp2028:7] : &:r2028_6, ~m?
1108411090
# 2028| r2028_8(glval<unsigned int>) = VariableAddress[y] :
1108511091
# 2028| mu2028_9(unsigned int) = Store[y] : &:r2028_8, r2028_7
11086-
# 2031| v2031_1(void) = Unreached :
11087-
11088-
# 2029| Block 3
11092+
# 2031| r2031_1(glval<unsigned int>) = VariableAddress[#return] :
11093+
# 2031| mu2031_2(unsigned int) = Uninitialized[#return] : &:r2031_1
11094+
# 2026| r2026_6(glval<unsigned int>) = VariableAddress[#return] :
11095+
# 2026| v2026_7(void) = ReturnValue : &:r2026_6, ~m?
11096+
# 2026| v2026_8(void) = AliasedUse : ~m?
11097+
# 2026| v2026_9(void) = ExitFunction :
11098+
11099+
# 2029| Block 2
1108911100
# 2029| r2029_1(glval<unknown>) = FunctionAddress[CommaTestHelper] :
1109011101
# 2029| r2029_2(glval<unsigned int>) = VariableAddress[x] :
1109111102
# 2029| r2029_3(unsigned int) = Load[x] : &:r2029_2, ~m?
@@ -11096,9 +11107,9 @@ ir.cpp:
1109611107
# 2029| r2029_8(unsigned int) = CopyValue : r2029_7
1109711108
# 2028| r2028_10(glval<unsigned int>) = VariableAddress[#temp2028:7] :
1109811109
# 2028| mu2028_11(unsigned int) = Store[#temp2028:7] : &:r2028_10, r2029_8
11099-
#-----| Goto -> Block 2
11110+
#-----| Goto -> Block 1
1110011111

11101-
# 2030| Block 4
11112+
# 2030| Block 3
1110211113
# 2030| r2030_1(glval<unknown>) = FunctionAddress[CommaTestHelper] :
1110311114
# 2030| r2030_2(glval<unsigned int>) = VariableAddress[x] :
1110411115
# 2030| r2030_3(unsigned int) = Load[x] : &:r2030_2, ~m?
@@ -11109,7 +11120,7 @@ ir.cpp:
1110911120
# 2030| r2030_8(unsigned int) = Convert : r2030_7
1111011121
# 2028| r2028_12(glval<unsigned int>) = VariableAddress[#temp2028:7] :
1111111122
# 2028| mu2028_13(unsigned int) = Store[#temp2028:7] : &:r2028_12, r2030_8
11112-
#-----| Goto -> Block 2
11123+
#-----| Goto -> Block 1
1111311124

1111411125
# 2033| void NewDeleteMem()
1111511126
# 2033| Block 0
@@ -11295,13 +11306,12 @@ ir.cpp:
1129511306
# 2065| r2065_3(Derived2 *) = Load[d] : &:r2065_2, ~m?
1129611307
# 2065| v2065_4(void) = Call[?] : func:r2065_1, 0:r2065_3
1129711308
# 2065| mu2065_5(unknown) = ^CallSideEffect : ~m?
11298-
# 2066| v2066_1(void) = Unreached :
11299-
11300-
# 2056| Block 1
11301-
# 2056| r2056_4(glval<int>) = VariableAddress[#return] :
11302-
# 2056| v2056_5(void) = ReturnValue : &:r2056_4, ~m?
11303-
# 2056| v2056_6(void) = AliasedUse : ~m?
11304-
# 2056| v2056_7(void) = ExitFunction :
11309+
# 2066| r2066_1(glval<int>) = VariableAddress[#return] :
11310+
# 2066| mu2066_2(int) = Uninitialized[#return] : &:r2066_1
11311+
# 2056| r2056_4(glval<int>) = VariableAddress[#return] :
11312+
# 2056| v2056_5(void) = ReturnValue : &:r2056_4, ~m?
11313+
# 2056| v2056_6(void) = AliasedUse : ~m?
11314+
# 2056| v2056_7(void) = ExitFunction :
1130511315

1130611316
# 2070| void test_constant_folding()
1130711317
# 2070| Block 0

0 commit comments

Comments
 (0)