Inline for proof without creating extra objects
The GNATprove tool now avoids creating unnecessary object declarations when inlining subprograms for proof, streamlining its process.
This commit modifies the GNATprove mode in the Ada compiler to optimize how it handles inlined subprogram calls. Previously, the tool would generate extra object declarations to ensure certain checks were performed after object renamings. With Ada 2022’s updated requirements, GNATprove now inherently generates these checks, eliminating the need for these superfluous temporary objects and simplifying the inlining process during proof generation.
In Details
The inline.adb module in the Ada front-end handles subprogram inlining. This specific change targets the Establish_Actual_Mapping_For_Inlined_Call function during GNATprove mode. The issue stemmed from the need to enforce certain runtime checks (e.g., against out-of-range values or null dereferences) during property proving. Previously, the inliner would introduce temporary object declarations to ensure these checks were performed even after variable renaming. With Ada 2022 rules, GNATprove now inherently emits these checks for renamed objects, making the explicit creation of temporary ob…
For Context
When a computer program is 'inlined,' it means that instead of calling a separate function, the compiler copies the function's code directly into the place where it's called. This can make the program run faster. 'GNATprove' is a specialized tool used with Ada to formally prove that a program will behave correctly and won't have certain kinds of errors. Previously, when GNATprove inlined code, it would sometimes create extra, temporary variables just to make sure all the necessary checks (like ensuring a number is within its valid range) were still being performed correctly even after the code was moved around. This commit simplifies that process: because the rules of Ada 2022 now ensure that GNATprove automatically performs these checks, the tool no longer needs to create those unnecessary temporary variables, making the inlining and proving process more efficient.