C++: add AliasedDefinition to IR global var inits

This commit is contained in:
Robert Marsh
2022-03-28 14:53:43 -04:00
parent 12ccf3662a
commit 5811d0b2ad
5 changed files with 101 additions and 91 deletions

View File

@@ -32,6 +32,10 @@ class TranslatedGlobalOrNamespaceVarInit extends TranslatedInstructionContainer,
tag = EnterFunctionTag() and
type = getVoidType()
or
op instanceof Opcode::AliasedDefinition and
tag = AliasedDefinitionTag() and
type = getUnknownType()
or
op instanceof Opcode::VariableAddress and
tag = InitializerVariableAddressTag() and
type = getTypeForGLValue(var.getType())
@@ -40,23 +44,33 @@ class TranslatedGlobalOrNamespaceVarInit extends TranslatedInstructionContainer,
tag = ReturnTag() and
type = getVoidType()
or
op instanceof Opcode::AliasedUse and
tag = AliasedUseTag() and
type = getVoidType()
or
op instanceof Opcode::ExitFunction and
tag = ExitFunctionTag() and
type = getVoidType()
}
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) {
tag = EnterFunctionTag() and
kind instanceof GotoEdge and
result = getInstruction(InitializerVariableAddressTag())
or
tag = InitializerVariableAddressTag() and
kind instanceof GotoEdge and
result = getChild(1).getFirstInstruction()
or
tag = ReturnTag() and
kind instanceof GotoEdge and
result = getInstruction(ExitFunctionTag())
(
tag = EnterFunctionTag() and
result = getInstruction(AliasedDefinitionTag())
or
tag = AliasedDefinitionTag() and
result = getInstruction(InitializerVariableAddressTag())
or
tag = InitializerVariableAddressTag() and
result = getChild(1).getFirstInstruction()
or
tag = ReturnTag() and
result = getInstruction(AliasedUseTag())
or
tag = AliasedUseTag() and
result = getInstruction(ExitFunctionTag())
)
}
override Instruction getChildSuccessor(TranslatedElement child) {
@@ -64,6 +78,14 @@ class TranslatedGlobalOrNamespaceVarInit extends TranslatedInstructionContainer,
result = getInstruction(ReturnTag())
}
final override CppType getInstructionMemoryOperandType(
InstructionTag tag, TypedOperandTag operandTag
) {
tag = AliasedUseTag() and
operandTag instanceof SideEffectOperandTag and
result = getUnknownType()
}
override IRUserVariable getInstructionVariable(InstructionTag tag) {
tag = InitializerVariableAddressTag() and
result.getVariable() = var

View File

@@ -3,10 +3,6 @@ unexpectedOperand
duplicateOperand
missingPhiOperand
missingOperandType
| ir.cpp:1038:12:1038:18 | ChiTotal | Operand 'ChiTotal' of instruction 'Chi' is missing a type in function '$@'. | ir.cpp:1038:6:1038:8 | (lambda [] type at line 1038, col. 12) lam | (lambda [] type at line 1038, col. 12) lam |
| ir.cpp:1695:16:1695:16 | ChiTotal | Operand 'ChiTotal' of instruction 'Chi' is missing a type in function '$@'. | ir.cpp:1695:5:1695:12 | int global_2 | int global_2 |
| ir.cpp:1697:22:1697:22 | ChiTotal | Operand 'ChiTotal' of instruction 'Chi' is missing a type in function '$@'. | ir.cpp:1697:11:1697:18 | int const global_3 | int const global_3 |
| struct_init.cpp:10:7:10:9 | ChiTotal | Operand 'ChiTotal' of instruction 'Chi' is missing a type in function '$@'. | struct_init.cpp:9:13:9:25 | Info infos_in_file[] | Info infos_in_file[] |
duplicateChiOperand
sideEffectWithoutPrimary
instructionWithoutSuccessor
@@ -25,14 +21,6 @@ useNotDominatedByDefinition
switchInstructionWithoutDefaultEdge
notMarkedAsConflated
wronglyMarkedAsConflated
| ir.cpp:1038:12:1038:18 | Chi: [...](...){...} | Instruction 'Chi: [...](...){...}' should not be marked as having a conflated result in function '$@'. | ir.cpp:1038:6:1038:8 | (lambda [] type at line 1038, col. 12) lam | (lambda [] type at line 1038, col. 12) lam |
| ir.cpp:1038:12:1038:18 | Chi: [...](...){...} | Instruction 'Chi: [...](...){...}' should not be marked as having a conflated result in function '$@'. | ir.cpp:1038:6:1038:8 | (lambda [] type at line 1038, col. 12) lam | (lambda [] type at line 1038, col. 12) lam |
| ir.cpp:1695:16:1695:16 | Chi: 1 | Instruction 'Chi: 1' should not be marked as having a conflated result in function '$@'. | ir.cpp:1695:5:1695:12 | int global_2 | int global_2 |
| ir.cpp:1697:22:1697:22 | Chi: 2 | Instruction 'Chi: 2' should not be marked as having a conflated result in function '$@'. | ir.cpp:1697:11:1697:18 | int const global_3 | int const global_3 |
| struct_init.cpp:10:7:10:9 | Chi: array to pointer conversion | Instruction 'Chi: array to pointer conversion' should not be marked as having a conflated result in function '$@'. | struct_init.cpp:9:13:9:25 | Info infos_in_file[] | Info infos_in_file[] |
| struct_init.cpp:10:12:10:19 | Chi: handler1 | Instruction 'Chi: handler1' should not be marked as having a conflated result in function '$@'. | struct_init.cpp:9:13:9:25 | Info infos_in_file[] | Info infos_in_file[] |
| struct_init.cpp:11:7:11:9 | Chi: array to pointer conversion | Instruction 'Chi: array to pointer conversion' should not be marked as having a conflated result in function '$@'. | struct_init.cpp:9:13:9:25 | Info infos_in_file[] | Info infos_in_file[] |
| struct_init.cpp:11:12:11:20 | Chi: & ... | Instruction 'Chi: & ...' should not be marked as having a conflated result in function '$@'. | struct_init.cpp:9:13:9:25 | Info infos_in_file[] | Info infos_in_file[] |
invalidOverlap
nonUniqueEnclosingIRFunction
fieldAddressOnNonPointer

View File

@@ -3,10 +3,6 @@ unexpectedOperand
duplicateOperand
missingPhiOperand
missingOperandType
| ir.cpp:1038:12:1038:18 | ChiTotal | Operand 'ChiTotal' of instruction 'Chi' is missing a type in function '$@'. | ir.cpp:1038:6:1038:8 | (lambda [] type at line 1038, col. 12) lam | (lambda [] type at line 1038, col. 12) lam |
| ir.cpp:1695:16:1695:16 | ChiTotal | Operand 'ChiTotal' of instruction 'Chi' is missing a type in function '$@'. | ir.cpp:1695:5:1695:12 | int global_2 | int global_2 |
| ir.cpp:1697:22:1697:22 | ChiTotal | Operand 'ChiTotal' of instruction 'Chi' is missing a type in function '$@'. | ir.cpp:1697:11:1697:18 | int const global_3 | int const global_3 |
| struct_init.cpp:10:7:10:9 | ChiTotal | Operand 'ChiTotal' of instruction 'Chi' is missing a type in function '$@'. | struct_init.cpp:9:13:9:25 | Info infos_in_file[] | Info infos_in_file[] |
duplicateChiOperand
sideEffectWithoutPrimary
instructionWithoutSuccessor
@@ -25,14 +21,6 @@ useNotDominatedByDefinition
switchInstructionWithoutDefaultEdge
notMarkedAsConflated
wronglyMarkedAsConflated
| ir.cpp:1038:12:1038:18 | Chi: [...](...){...} | Instruction 'Chi: [...](...){...}' should not be marked as having a conflated result in function '$@'. | ir.cpp:1038:6:1038:8 | (lambda [] type at line 1038, col. 12) lam | (lambda [] type at line 1038, col. 12) lam |
| ir.cpp:1038:12:1038:18 | Chi: [...](...){...} | Instruction 'Chi: [...](...){...}' should not be marked as having a conflated result in function '$@'. | ir.cpp:1038:6:1038:8 | (lambda [] type at line 1038, col. 12) lam | (lambda [] type at line 1038, col. 12) lam |
| ir.cpp:1695:16:1695:16 | Chi: 1 | Instruction 'Chi: 1' should not be marked as having a conflated result in function '$@'. | ir.cpp:1695:5:1695:12 | int global_2 | int global_2 |
| ir.cpp:1697:22:1697:22 | Chi: 2 | Instruction 'Chi: 2' should not be marked as having a conflated result in function '$@'. | ir.cpp:1697:11:1697:18 | int const global_3 | int const global_3 |
| struct_init.cpp:10:7:10:9 | Chi: array to pointer conversion | Instruction 'Chi: array to pointer conversion' should not be marked as having a conflated result in function '$@'. | struct_init.cpp:9:13:9:25 | Info infos_in_file[] | Info infos_in_file[] |
| struct_init.cpp:10:12:10:19 | Chi: handler1 | Instruction 'Chi: handler1' should not be marked as having a conflated result in function '$@'. | struct_init.cpp:9:13:9:25 | Info infos_in_file[] | Info infos_in_file[] |
| struct_init.cpp:11:7:11:9 | Chi: array to pointer conversion | Instruction 'Chi: array to pointer conversion' should not be marked as having a conflated result in function '$@'. | struct_init.cpp:9:13:9:25 | Info infos_in_file[] | Info infos_in_file[] |
| struct_init.cpp:11:12:11:20 | Chi: & ... | Instruction 'Chi: & ...' should not be marked as having a conflated result in function '$@'. | struct_init.cpp:9:13:9:25 | Info infos_in_file[] | Info infos_in_file[] |
invalidOverlap
nonUniqueEnclosingIRFunction
fieldAddressOnNonPointer

View File

@@ -4666,15 +4666,16 @@
| ir.cpp:1034:6:1034:20 | ChiTotal | total:m1034_2 |
| ir.cpp:1034:6:1034:20 | SideEffect | m1034_3 |
| ir.cpp:1035:15:1035:15 | Address | &:r1035_1 |
| ir.cpp:1038:6:1038:8 | Address | &:r1038_2 |
| ir.cpp:1038:12:1038:18 | Address | &:r1038_3 |
| ir.cpp:1038:12:1038:18 | Address | &:r1038_3 |
| ir.cpp:1038:12:1038:18 | ChiPartial | partial:m1038_4 |
| ir.cpp:1038:12:1038:18 | ChiPartial | partial:m1038_7 |
| ir.cpp:1038:12:1038:18 | ChiTotal | total:m1038_5 |
| ir.cpp:1038:12:1038:18 | ChiTotal | total:~m? |
| ir.cpp:1038:12:1038:18 | Load | ~m1038_5 |
| ir.cpp:1038:12:1038:18 | StoreValue | r1038_6 |
| ir.cpp:1038:6:1038:8 | Address | &:r1038_3 |
| ir.cpp:1038:6:1038:8 | SideEffect | ~m1038_9 |
| ir.cpp:1038:12:1038:18 | Address | &:r1038_4 |
| ir.cpp:1038:12:1038:18 | Address | &:r1038_4 |
| ir.cpp:1038:12:1038:18 | ChiPartial | partial:m1038_5 |
| ir.cpp:1038:12:1038:18 | ChiPartial | partial:m1038_8 |
| ir.cpp:1038:12:1038:18 | ChiTotal | total:m1038_2 |
| ir.cpp:1038:12:1038:18 | ChiTotal | total:m1038_6 |
| ir.cpp:1038:12:1038:18 | Load | ~m1038_6 |
| ir.cpp:1038:12:1038:18 | StoreValue | r1038_7 |
| ir.cpp:1038:14:1038:14 | Address | &:r1038_5 |
| ir.cpp:1038:14:1038:14 | Address | &:r1038_5 |
| ir.cpp:1038:14:1038:14 | Address | &:r1038_5 |
@@ -7536,14 +7537,16 @@
| ir.cpp:1689:50:1689:50 | Load | m1689_6 |
| ir.cpp:1689:50:1689:50 | SideEffect | m1689_3 |
| ir.cpp:1689:50:1689:50 | SideEffect | m1689_8 |
| ir.cpp:1695:5:1695:12 | Address | &:r1695_2 |
| ir.cpp:1695:16:1695:16 | ChiPartial | partial:m1695_4 |
| ir.cpp:1695:16:1695:16 | ChiTotal | total:~m? |
| ir.cpp:1695:16:1695:16 | StoreValue | r1695_3 |
| ir.cpp:1697:11:1697:18 | Address | &:r1697_2 |
| ir.cpp:1697:22:1697:22 | ChiPartial | partial:m1697_4 |
| ir.cpp:1697:22:1697:22 | ChiTotal | total:~m? |
| ir.cpp:1697:22:1697:22 | StoreValue | r1697_3 |
| ir.cpp:1695:5:1695:12 | Address | &:r1695_3 |
| ir.cpp:1695:5:1695:12 | SideEffect | ~m1695_6 |
| ir.cpp:1695:16:1695:16 | ChiPartial | partial:m1695_5 |
| ir.cpp:1695:16:1695:16 | ChiTotal | total:m1695_2 |
| ir.cpp:1695:16:1695:16 | StoreValue | r1695_4 |
| ir.cpp:1697:11:1697:18 | Address | &:r1697_3 |
| ir.cpp:1697:11:1697:18 | SideEffect | ~m1697_6 |
| ir.cpp:1697:22:1697:22 | ChiPartial | partial:m1697_5 |
| ir.cpp:1697:22:1697:22 | ChiTotal | total:m1697_2 |
| ir.cpp:1697:22:1697:22 | StoreValue | r1697_4 |
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
| perf-regression.cpp:6:3:6:5 | Address | &:r6_7 |
@@ -7787,18 +7790,19 @@
| smart_ptr.cpp:47:43:47:63 | SideEffect | ~m47_16 |
| smart_ptr.cpp:47:43:47:63 | Unary | r47_5 |
| smart_ptr.cpp:47:43:47:63 | Unary | r47_6 |
| struct_init.cpp:9:13:9:25 | Left | r9_2 |
| struct_init.cpp:9:13:9:25 | Left | r9_2 |
| struct_init.cpp:9:31:12:1 | Right | r9_3 |
| struct_init.cpp:9:31:12:1 | Right | r9_5 |
| struct_init.cpp:9:31:12:1 | Unary | r9_4 |
| struct_init.cpp:9:31:12:1 | Unary | r9_4 |
| struct_init.cpp:9:31:12:1 | Unary | r9_6 |
| struct_init.cpp:9:31:12:1 | Unary | r9_6 |
| struct_init.cpp:9:13:9:25 | Left | r9_3 |
| struct_init.cpp:9:13:9:25 | Left | r9_3 |
| struct_init.cpp:9:13:9:25 | SideEffect | ~m11_10 |
| struct_init.cpp:9:31:12:1 | Right | r9_4 |
| struct_init.cpp:9:31:12:1 | Right | r9_6 |
| struct_init.cpp:9:31:12:1 | Unary | r9_5 |
| struct_init.cpp:9:31:12:1 | Unary | r9_5 |
| struct_init.cpp:9:31:12:1 | Unary | r9_7 |
| struct_init.cpp:9:31:12:1 | Unary | r9_7 |
| struct_init.cpp:10:5:10:21 | Address | &:r10_1 |
| struct_init.cpp:10:5:10:21 | Address | &:r10_6 |
| struct_init.cpp:10:7:10:9 | ChiPartial | partial:m10_4 |
| struct_init.cpp:10:7:10:9 | ChiTotal | total:~m? |
| struct_init.cpp:10:7:10:9 | ChiTotal | total:m9_2 |
| struct_init.cpp:10:7:10:9 | StoreValue | r10_3 |
| struct_init.cpp:10:7:10:9 | Unary | r10_2 |
| struct_init.cpp:10:12:10:19 | ChiPartial | partial:m10_8 |

View File

@@ -5622,14 +5622,16 @@ ir.cpp:
# 1038| (lambda [] type at line 1038, col. 12) lam
# 1038| Block 0
# 1038| v1038_1(void) = EnterFunction :
# 1038| r1038_2(glval<decltype([...](...){...})>) = VariableAddress :
# 1038| r1038_3(glval<decltype([...](...){...})>) = VariableAddress :
# 1038| mu1038_4(decltype([...](...){...})) = Uninitialized : &:r1038_3
# 1038| r1038_5(decltype([...](...){...})) = Load[?] : &:r1038_3, ~m?
# 1038| mu1038_6(decltype([...](...){...})) = Store[?] : &:r1038_2, r1038_5
# 1038| v1038_7(void) = ReturnVoid :
# 1038| v1038_8(void) = ExitFunction :
# 1038| v1038_1(void) = EnterFunction :
# 1038| mu1038_2(unknown) = AliasedDefinition :
# 1038| r1038_3(glval<decltype([...](...){...})>) = VariableAddress :
# 1038| r1038_4(glval<decltype([...](...){...})>) = VariableAddress :
# 1038| mu1038_5(decltype([...](...){...})) = Uninitialized : &:r1038_4
# 1038| r1038_6(decltype([...](...){...})) = Load[?] : &:r1038_4, ~m?
# 1038| mu1038_7(decltype([...](...){...})) = Store[?] : &:r1038_3, r1038_6
# 1038| v1038_8(void) = ReturnVoid :
# 1038| v1038_9(void) = AliasedUse : ~m?
# 1038| v1038_10(void) = ExitFunction :
# 1038| void (lambda [] type at line 1038, col. 12)::operator()() const
# 1038| Block 0
@@ -8861,21 +8863,25 @@ ir.cpp:
# 1695| int global_2
# 1695| Block 0
# 1695| v1695_1(void) = EnterFunction :
# 1695| r1695_2(glval<int>) = VariableAddress :
# 1695| r1695_3(int) = Constant[1] :
# 1695| mu1695_4(int) = Store[?] : &:r1695_2, r1695_3
# 1695| v1695_5(void) = ReturnVoid :
# 1695| v1695_6(void) = ExitFunction :
# 1695| v1695_1(void) = EnterFunction :
# 1695| mu1695_2(unknown) = AliasedDefinition :
# 1695| r1695_3(glval<int>) = VariableAddress :
# 1695| r1695_4(int) = Constant[1] :
# 1695| mu1695_5(int) = Store[?] : &:r1695_3, r1695_4
# 1695| v1695_6(void) = ReturnVoid :
# 1695| v1695_7(void) = AliasedUse : ~m?
# 1695| v1695_8(void) = ExitFunction :
# 1697| int const global_3
# 1697| Block 0
# 1697| v1697_1(void) = EnterFunction :
# 1697| r1697_2(glval<int>) = VariableAddress :
# 1697| r1697_3(int) = Constant[2] :
# 1697| mu1697_4(int) = Store[?] : &:r1697_2, r1697_3
# 1697| v1697_5(void) = ReturnVoid :
# 1697| v1697_6(void) = ExitFunction :
# 1697| v1697_1(void) = EnterFunction :
# 1697| mu1697_2(unknown) = AliasedDefinition :
# 1697| r1697_3(glval<int>) = VariableAddress :
# 1697| r1697_4(int) = Constant[2] :
# 1697| mu1697_5(int) = Store[?] : &:r1697_3, r1697_4
# 1697| v1697_6(void) = ReturnVoid :
# 1697| v1697_7(void) = AliasedUse : ~m?
# 1697| v1697_8(void) = ExitFunction :
perf-regression.cpp:
# 6| void Big::Big()
@@ -9101,28 +9107,30 @@ struct_init.cpp:
# 9| Info infos_in_file[]
# 9| Block 0
# 9| v9_1(void) = EnterFunction :
# 9| r9_2(glval<Info[]>) = VariableAddress :
# 9| r9_3(int) = Constant[0] :
# 9| r9_4(glval<Info>) = PointerAdd[16] : r9_2, r9_3
# 10| r10_1(glval<char *>) = FieldAddress[name] : r9_4
# 9| mu9_2(unknown) = AliasedDefinition :
# 9| r9_3(glval<Info[]>) = VariableAddress :
# 9| r9_4(int) = Constant[0] :
# 9| r9_5(glval<Info>) = PointerAdd[16] : r9_3, r9_4
# 10| r10_1(glval<char *>) = FieldAddress[name] : r9_5
# 10| r10_2(glval<char[2]>) = StringConstant :
# 10| r10_3(char *) = Convert : r10_2
# 10| mu10_4(char *) = Store[?] : &:r10_1, r10_3
# 10| r10_5(glval<..(*)(..)>) = FieldAddress[handler] : r9_4
# 10| r10_5(glval<..(*)(..)>) = FieldAddress[handler] : r9_5
# 10| r10_6(..(*)(..)) = FunctionAddress[handler1] :
# 10| mu10_7(..(*)(..)) = Store[?] : &:r10_5, r10_6
# 9| r9_5(int) = Constant[1] :
# 9| r9_6(glval<Info>) = PointerAdd[16] : r9_2, r9_5
# 11| r11_1(glval<char *>) = FieldAddress[name] : r9_6
# 9| r9_6(int) = Constant[1] :
# 9| r9_7(glval<Info>) = PointerAdd[16] : r9_3, r9_6
# 11| r11_1(glval<char *>) = FieldAddress[name] : r9_7
# 11| r11_2(glval<char[2]>) = StringConstant :
# 11| r11_3(char *) = Convert : r11_2
# 11| mu11_4(char *) = Store[?] : &:r11_1, r11_3
# 11| r11_5(glval<..(*)(..)>) = FieldAddress[handler] : r9_6
# 11| r11_5(glval<..(*)(..)>) = FieldAddress[handler] : r9_7
# 11| r11_6(glval<..()(..)>) = FunctionAddress[handler2] :
# 11| r11_7(..(*)(..)) = CopyValue : r11_6
# 11| mu11_8(..(*)(..)) = Store[?] : &:r11_5, r11_7
# 9| v9_7(void) = ReturnVoid :
# 9| v9_8(void) = ExitFunction :
# 9| v9_8(void) = ReturnVoid :
# 9| v9_9(void) = AliasedUse : ~m?
# 9| v9_10(void) = ExitFunction :
# 14| Info* global_pointer