C++: fix IR global var init for string constants

This commit is contained in:
Robert Marsh
2022-03-30 14:01:59 -04:00
parent e01799827a
commit 3ce7c521d1
9 changed files with 22 additions and 24 deletions

View File

@@ -49,18 +49,18 @@ module Raw {
}
cached
predicate hasTempVariable(Function func, Locatable ast, TempVariableTag tag, CppType type) {
predicate hasTempVariable(Declaration decl, Locatable ast, TempVariableTag tag, CppType type) {
exists(TranslatedElement element |
element.getAst() = ast and
func = element.getFunction() and
decl = element.getFunction() and
element.hasTempVariable(tag, type)
)
}
cached
predicate hasStringLiteral(Function func, Locatable ast, CppType type, StringLiteral literal) {
predicate hasStringLiteral(Declaration decl, Locatable ast, CppType type, StringLiteral literal) {
literal = ast and
literal.getEnclosingFunction() = func and
literal.getEnclosingDeclaration() = decl and
getTypeForPRValue(literal.getType()) = type
}

View File

@@ -24,7 +24,7 @@ class TranslatedGlobalOrNamespaceVarInit extends TranslatedRootElement,
override Instruction getFirstInstruction() { result = this.getInstruction(EnterFunctionTag()) }
override TranslatedElement getChild(int n) {
n = 1 and result = getTranslatedInitialization(var.getInitializer().getExpr())
n = 1 and result = getTranslatedInitialization(var.getInitializer().getExpr().getFullyConverted())
}
override predicate hasInstruction(Opcode op, InstructionTag tag, CppType type) {

View File

@@ -8,7 +8,6 @@ sideEffectWithoutPrimary
instructionWithoutSuccessor
| ir.cpp:1688:24:1690:5 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1683:6:1683:20 | void captured_lambda(int, int&, int&&) | void captured_lambda(int, int&, int&&) |
| ir.cpp:1689:28:1689:54 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1688:46:1688:46 | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const |
| ir.cpp:1709:7:1709:19 | VariableAddress: global_string | Instruction 'VariableAddress: global_string' has no successors in function '$@'. | ir.cpp:1709:7:1709:19 | char* global_string | char* global_string |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction

View File

@@ -8,7 +8,6 @@ sideEffectWithoutPrimary
instructionWithoutSuccessor
| ir.cpp:1688:24:1690:5 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1683:6:1683:20 | void captured_lambda(int, int&, int&&) | void captured_lambda(int, int&, int&&) |
| ir.cpp:1689:28:1689:54 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1688:46:1688:46 | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const |
| ir.cpp:1709:7:1709:19 | VariableAddress: global_string | Instruction 'VariableAddress: global_string' has no successors in function '$@'. | ir.cpp:1709:7:1709:19 | char* global_string | char* global_string |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction

View File

@@ -7753,6 +7753,13 @@
| ir.cpp:1707:28:1707:47 | ChiTotal | total:m1707_8 |
| ir.cpp:1707:28:1707:47 | SideEffect | ~m1707_2 |
| ir.cpp:1707:46:1707:46 | Arg(0) | 0:r1707_5 |
| ir.cpp:1709:7:1709:19 | Address | &:r1709_3 |
| ir.cpp:1709:7:1709:19 | SideEffect | ~m1709_8 |
| ir.cpp:1709:23:1709:37 | ChiPartial | partial:m1709_7 |
| ir.cpp:1709:23:1709:37 | ChiTotal | total:m1709_2 |
| ir.cpp:1709:23:1709:37 | StoreValue | r1709_6 |
| ir.cpp:1709:23:1709:37 | Unary | r1709_4 |
| ir.cpp:1709:23:1709:37 | Unary | r1709_5 |
| 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 |

View File

@@ -15,8 +15,6 @@ instructionWithoutSuccessor
| ir.cpp:1688:24:1690:5 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1683:6:1683:20 | void captured_lambda(int, int&, int&&) | void captured_lambda(int, int&, int&&) |
| ir.cpp:1689:28:1689:54 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1688:46:1688:46 | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const |
| ir.cpp:1689:28:1689:54 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1688:46:1688:46 | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const |
| ir.cpp:1709:7:1709:19 | VariableAddress: global_string | Instruction 'VariableAddress: global_string' has no successors in function '$@'. | ir.cpp:1709:7:1709:19 | char* global_string | char* global_string |
| ir.cpp:1709:23:1709:37 | Convert: (char *)... | Instruction 'Convert: (char *)...' has no successors in function '$@'. | ir.cpp:1709:7:1709:19 | char* global_string | char* global_string |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction

View File

@@ -9070,19 +9070,16 @@ ir.cpp:
# 1709| char* global_string
# 1709| Block 0
# 1709| v1709_1(void) = EnterFunction :
# 1709| mu1709_2(unknown) = AliasedDefinition :
# 1709| r1709_3(glval<char *>) = VariableAddress :
# 1709| Block 1
# 1709| v1709_4(void) = ReturnVoid :
# 1709| v1709_5(void) = AliasedUse : ~m?
# 1709| v1709_6(void) = ExitFunction :
# 1709| Block 2
# 1709| r1709_7(glval<char[14]>) = StringConstant :
# 1709| r1709_8(char *) = Convert : r1709_7
# 1709| r1709_9(char *) = Convert : r1709_8
# 1709| v1709_1(void) = EnterFunction :
# 1709| mu1709_2(unknown) = AliasedDefinition :
# 1709| r1709_3(glval<char *>) = VariableAddress :
# 1709| r1709_4(glval<char[14]>) = StringConstant :
# 1709| r1709_5(char *) = Convert : r1709_4
# 1709| r1709_6(char *) = Convert : r1709_5
# 1709| mu1709_7(char *) = Store[?] : &:r1709_3, r1709_6
# 1709| v1709_8(void) = ReturnVoid :
# 1709| v1709_9(void) = AliasedUse : ~m?
# 1709| v1709_10(void) = ExitFunction :
perf-regression.cpp:
# 6| void Big::Big()

View File

@@ -8,7 +8,6 @@ sideEffectWithoutPrimary
instructionWithoutSuccessor
| ir.cpp:1688:24:1690:5 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1683:6:1683:20 | void captured_lambda(int, int&, int&&) | void captured_lambda(int, int&, int&&) |
| ir.cpp:1689:28:1689:54 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1688:46:1688:46 | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const |
| ir.cpp:1709:7:1709:19 | VariableAddress: global_string | Instruction 'VariableAddress: global_string' has no successors in function '$@'. | ir.cpp:1709:7:1709:19 | char* global_string | char* global_string |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction

View File

@@ -8,7 +8,6 @@ sideEffectWithoutPrimary
instructionWithoutSuccessor
| ir.cpp:1688:24:1690:5 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1683:6:1683:20 | void captured_lambda(int, int&, int&&) | void captured_lambda(int, int&, int&&) |
| ir.cpp:1689:28:1689:54 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1688:46:1688:46 | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const |
| ir.cpp:1709:7:1709:19 | VariableAddress: global_string | Instruction 'VariableAddress: global_string' has no successors in function '$@'. | ir.cpp:1709:7:1709:19 | char* global_string | char* global_string |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction