COBOL

COBOL

COBOL

COBOL is responsible for the efficient, reliable, secure, and unseen day-to-day operations of the world's economy.

 View Only
Expand all | Collapse all

IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

  • 1.  IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted Mon October 06, 2025 04:16 PM

    Hi,

    I note that the IBM Enterprise COBOL compiler's binary code optimizations seem to be completely disabled when the CICS compiler option is enabled:
    - no inlining, despite the INLINE option
    - almost identical code in OPTIMIZE(0), OPTIMIZE(1), OPTIMIZE(2) modes

    The only effect of the OPTIMIZE(1) / OPTIMIZE(2) options is the removal of unreachable code.
    OPTIMIZE(2) reorders certain MOVE / INITIALIZE instructions according to memory addresses.

    The CICS options used are:
    - CICS("APOST")
    - CICS("COBOL3")
    - CICS("SP")

    Without the CICS compiler option, and same other compilation options, optimizations are indeed enabled by the INLINE and OPTIMIZE(1) or OPTIMIZE(2) options.

    I tested with the compiler versions available to me:
    - COBOL V6R4 'P230615'
    - COBOL V6R4 'P240416'
    - COBOL V6R4 'P241216'
    - COBOL V6R5 'P250507'

    No conflicts or restrictions are indicated regarding the use of the CICS compilation option in the reference documentation...
    Is this an oversight?
    Is this a compiler flaw?
    Do you see the same thing? (Compile with the CICS options, OPTIMIZE(1|2), INLINE, and LIST to get binary code expansion).

    Thanks.



    ------------------------------
    Denis FALLAI
    BPCE SI, BPCE group.
    ------------------------------


  • 2.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted Tue October 07, 2025 03:53 PM

    Simply using the CICS option vs. not using it shouldn't have any effect on which optimizations the compiler attempts. The presence of actual CICS calls in a program might have some effect - not in the sense of globally disabling any optimization, but causing optimizations to make different decisions in the presence of differences in the code. But no, I know of no reason why the CICS option would have any impact on the behaviour of paragraphs being inlined or of any of the other numerous optimizations we attempt. Most optimizations are situational, so we certainly can't conclude that NO optimizations are being run without further investigation.

    I can't comment in any more detail without seeing the actual program(s) in question, along with compiler options, etc. Can you please open a Case?



    ------------------------------
    Mike Chase
    Lead Developer, watsonx Code Assistant For z Code Optimization Advice
    Developer, Enterprise COBOL
    mike.chase@ca.ibm.com
    ------------------------------



  • 3.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted Sun October 12, 2025 11:44 AM

    Hi,

    I opened a case under the reference TS020510459

    Thanks.



    ------------------------------
    Denis FALLAI
    BPCE SI, BPCE group.
    ------------------------------



  • 4.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted Tue October 14, 2025 10:31 AM

    Hi,

    By removing the EXEC CICS statements and compiling without the CICS option, I see the same lack of PERFORM inlining.
    So it's not the CICS compilation option that disables inlining, but the program structure.
    Analysis in progress...



    ------------------------------
    Denis FALLAI
    BPCE SI, BPCE group.
    ------------------------------



  • 5.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted Tue October 14, 2025 10:42 AM

    Hi Denis,

    Thank you for opening the Case. The optimizer team will take a look at this. We have both logging tools for the optimizer that aren't available to clients and an understanding of how the inlining of PERFORMed paragraphs and sections is supposed to be done, so I don't think there's a need for you to analyze further.

    Thanks,
    Mike



    ------------------------------
    Mike Chase
    Lead Developer, watsonx Code Assistant For z Code Optimization Advice
    Developer, Enterprise COBOL
    mike.chase@ca.ibm.com
    ------------------------------



  • 6.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted Fri October 17, 2025 02:27 PM
    Edited by Denis FALLAI Sun October 19, 2025 05:05 AM

    Hi,

    I found the source of the problem, and it's indeed (indirectly) related to the fact that this is a CICS program:

    * Since this is a CICS program, there is no GOBACK: the program exits with an EXEC CICS RETURN
    * If I add a goback after the EXEC CICS RETURN (a goback that will never be executed), then the PERFORM inlining is performed as expected (at least more so than without GOBACK).

    In fact, without GOBACK, the instructions will falsely appear as executed in sequence in addition to being executed by PERFORM.

    In an optimized version for the same CICS program:
    * 574 COBOL statements in Procedure Division, including 90 PERFORM instructions
    * The complexity index is reduced, so the compiler runs faster and consumes less cpu.
    * The load module size is reduced from 24kb to 13kb, (unexpected improvement!)

    Thanks.



    ------------------------------
    Denis FALLAI
    BPCE SI, BPCE group.
    ------------------------------



  • 7.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted Fri October 17, 2025 02:37 PM

    Wow!  Excellent troubleshooting!  Makes total sense.  Makes me wonder how many CICS programs we have out there that are under-optimized because of this.



    ------------------------------
    Frank Swarbrick
    ------------------------------



  • 8.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted Fri October 17, 2025 03:03 PM

    Hi, 

    Our CICS programs are all built on the same model:
    * a program start that PERFORMs the level 1 routines, which themselves can PERFORM other routines
    * an EXEC CICS RETRUN after this program start, but no GOBACK

             PROCEDURE DIVISION.                                                 
            PRINCIPAL SECTION.                                                  
               perform   INITIALISATIONS-WORKING                               
                         with test before until WORKING-INITIALISEES           
               perform S-DEBUT                                                 
               perform   INITIALISATIONS                                       
               perform S-AVANT-ITERATION                                       
               perform   ITERATION-QUESTION until FIN-QUESTIONS                
               perform S-TRAITEMENT                                            
               .                                                               
           FIN-TRAITEMENT.                                                     
               perform S-AVANT-FINALISATION                                    
               perform   FINALISATION                                          
               exec cics                                                       
                 return                                                        
               end-exec                                                        
               .                                                               

    All the rest of the code consists of just Sections called by PERFORM.



    ------------------------------
    Denis FALLAI
    BPCE SI, BPCE group.
    ------------------------------



  • 9.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted Fri October 17, 2025 03:50 PM

    We have programs going back to the mid-80s that, unfortunately, were written more in the "dropdown" style, and also with several different invocations of both CICS RETURN and CICS XCTL statements.  The only real usage of PERFORM in many of these programs is when a set of code is used more than once.  Otherwise it's drop through or GO TO.

    In other words, depending on which code path is followed it will reach one of many possible "exit" points.  No single design model was ever created.

    Just a comment, apropos of nothing really.



    ------------------------------
    Frank Swarbrick
    ------------------------------



  • 10.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted Sun October 19, 2025 04:53 AM
    Edited by Denis FALLAI Sun October 19, 2025 05:43 AM

    Hi,

    I discovered another case where PERFORM inlining is disabled: the presence of EXEC CICS HANDLE ABEND LABEL commands (and it must be the same with other EXEC CICS HANDLE commands that generate branching).


    If I remove the EXEC CICS HANDLE LABEL commands from the source code, PERFORM inlining is re-enabled.


    For the moment, I haven't found a workaround (adding GOBACK in the source code after the target of EXEC CICS HANDLE LABEL commands to force a break in sequence execution doesn't solve the problem).

    We use two kinds of EXEC CICS HANDLE ABEND LABEL :

    • a « global » handle abend label to catch any abend in the program.

    This handle abend label is isolated in a paragraph that is PERFORMed from many point : start of program and after activating a « local » handle abend. The target routine of this handle abend will clean memory (QUEUE TS) and terminate the run by reemitting the abend.

    • a « local » handle to protect an EXEC CICS LINK.

    This handle abend is an « continue even if abend », activated before the EXEC CICS LINK to branch after it, (in sequence), and the « global » handle is reactivated after the LINK, (PERFORM to the paragraph containing the « global » handle abend label).

    Note that EXEC CICS HANDLE are commands evaluated at runtime and not compilation directive evaluated at compilation time, (as EXEC SQL WHENEVER are).

    Target of an EXEC CICS HANDLE can be considered as an alternate entry point in program, (and generate a SERVICE LABEL compilation directive).

    Perhaps rejecting target of EXEC CICS HANDLE at end of source code would help in code optimisation but at time this is not compatible with our development framework.

    Thanks. 



    ------------------------------
    Denis FALLAI
    BPCE SI, BPCE group.
    ------------------------------



  • 11.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted Sun October 19, 2025 10:15 AM

    There's a distinction between PERFORM inlining being disabled - turned off and not attempted - vs. the optimization running but not doing any transformations. I know that we do account for CICS exception handling in our model of how execution can flow through a program, so it's more likely that there's something about your specific program. Could you add it to the Case you have opened? Thanks!



    ------------------------------
    Mike Chase
    Lead Developer, watsonx Code Assistant For z Code Optimization Advice
    Developer, Enterprise COBOL
    mike.chase@ca.ibm.com
    ------------------------------



  • 12.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 28 days ago
    Edited by Denis FALLAI 28 days ago

    Hi,

    I managed to improve the inlining of PERFORM by replacing the HANDLE ABEND protection of a LINK by adding NOHANDLE RESP(xxxx) RESP2(yyyy) options.

    Before :

       SET NORMAL-TERMINATION TO FALSE

        EXEC CICS PUSH HANDLE

        EXEC CICS HANDLE ABEND LABEL (PROGRAM-HAS-ABENDED)

        EXEC CICS LINK PROGRAM(PROGRAM)

        SET NORMAL-TERMINATION TO TRUE.

    PROGRAM-HAS-ABENDED.

        IF NOT NORMAL-TERMINATION THEN

        <do something>

       END-IF

    After :

        SET NORMAL-TERMINATION TO FALSE

        EXEC CICS LINK PROGRAM(PROGRAM) NOHANDLE RESP(RESP) RESP2(RESP2) 

        IF RESP = DFHRESP(NORMAL) THEN    

          SET NORMAL-TERMINATION TO TRUE

        END-IF

        IF NOT NORMAL-TERMINATION THEN

        <do something>

        END-IF

    but I'm not sure that the NOHANDLE / RESP / RESP2 option intercepts abends in the called program and ultimately has the same behavior...



    ------------------------------
    Denis FALLAI
    BPCE SI, BPCE group.
    ------------------------------



  • 13.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 27 days ago

    Dennis,

    You are on the right track.  I never use HANDLE conditions, and as you have done, always check the EIB block Responses to see if something i ammis with an EXEC CICS command.  In fact, in your case, your need to check inside the LINKED TO program for errors, as the test you have coded will only tell you if the LINK itself worked.  It's quite possible the LINK worked fine, but the LINKED TO module had errors you don't see..  

     



    ------------------------------
    Jon Butler
    ------------------------------



  • 14.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 27 days ago

    I don't know CICS enough to verify Denis' most recent solution.

    I DO however recommend Enterprise COBOL users don't change their source code to work around issues in the optimizer. A Case has been opened; the compiler team needs time to address it and put out a PTF.



    ------------------------------
    Mike Chase
    Lead Developer, watsonx Code Assistant For z Code Optimization Advice
    Developer, Enterprise COBOL
    mike.chase@ca.ibm.com
    ------------------------------



  • 15.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 22 days ago

    Hi Mike,

    I agree that it's not the developer's responsibility to modify the source code to achieve the compiler's expected result regarding code optimization, and specifically the inlining of PERFORM statements.

    However, there are cases where the compiler cannot make these decisions on its own. For example, a subprogram call that triggers an abend to terminate execution.

    To manage this, we would need a way to tell the compiler that this code will be a sequence break, or a program exit.

    Note that in my specific context, I'm developing a COBOL framework based on program skeletons and technical architecture copybooks.

    For this reason, I do not have the option of positioning the problematic code (for inlining) at the end of the source code, which could be a way to manage the problem.

    Thanks,



    ------------------------------
    Denis FALLAI
    BPCE SI, BPCE group.
    ------------------------------



  • 16.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 22 days ago
    Dennis,

    If I understand your problem, you want an intentional ABEND, not one generated by the hardware.   

    Let me suggest that at the point in the subroutine you want to force an abend, you set a semaphore to pass back to the invoking program and issue a RETURN at that point. Of course, you could branch to an internal subroutine or paragraph to complete any final work you need to do, then issue the RETURN.  You might include other parameters to help debug the problem that led you to think an abend was necessary.  

    The invoking program could then interrogate the semaphore and issue the ABEND.  This could be used recursively if you need to go more than one level deep.

    This is also a good time to think about why you want to issue an ABEND and design the system so it is not necessary. I've spent many years trying to convince programmers no to issue an intentional abend, but the answer is invariably..."It's easier"...easier for whom?


    Cheers,





  • 17.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 21 days ago

    Hi Denis,

    I don't have the background developing COBOL applications so I won't comment on Jon's suggestion, but I'm confused as to what your actual problem is.

    First, to be clear, there are two types of inlining that happen in Enterprise COBOL. We sometimes inline full programs into others; this is most often done for things like the artificial methods the compiler generates (for example, to initialize the WORKING-STORAGE or LOCAL STORAGE sections, or to calculate the address of variably-located data items whose position depends on one or more OCCURS DEPENDING ON clauses). We CAN inline COBOL programs into other programs, provided the programs are nested or possibly within the same source file; we definitely can't inline programs if they exist in different files, as the compiler only knows about one source file (not counting files referenced by COPY statements) at once.

    The much more common form of inlining for COBOL, the form governed by the INLINE option and >INLINE directive, is inlining of paragraphs that are PERFORMed.


    You mentioned subprograms, but in the rest of this thread, you've been talking about paragraphs and PERFORM inlining, so I'm not sure what case you're specifically talking about in your latest comment. Are you still referring to the fact that the compiler doesn't seem to do what you expect when EXEC CICS RETURN statements are used instead of GOBACK/STOP RUN statements? Wouldn't the solution be for the compiler to treat those as equivalent, as far as optimizations go?

    That said, it's only with a proper investigation of specific programs and what the compiler does to them that we can be certain what's actually going on. You've certainly found a program that seems to break inlining, but there are other factors our algorithm considers that you might not have thought about. For one thing, the fact that paragraphs may flow linearly to the next paragraph and may also be PERFORMed isn't, in and of itself, a reason not to inline the paragraphs; I'm sure we DO inline paragraphs sometimes where there's flow to the next paragraph (though certainly a GOBACK would make it MORE likely we'd inline that paragraph since we know we won't have to have an inlined copy plus one to fall through.) The compiler team really needs to look more closely at your case to know what's going on; anything else, even from me at this point, is a bit speculative.



    ------------------------------
    Mike Chase
    Lead Developer, watsonx Code Assistant For z Code Optimization Advice
    Developer, Enterprise COBOL
    mike.chase@ca.ibm.com
    ------------------------------



  • 18.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 21 days ago
    Edited by Denis FALLAI 21 days ago

    Hi Mike,

    Please disregard my message about the external subprogram call intended to trigger an abend: it was just a digression to point out that the compiler cannot always know when there will be a break in the processing sequence. This could be a difficulty in inlining Sections/Paragraphs placed after the call instruction because the compiler might think they will be executed sequentially after the call. That's made things confusing, sorry.

    My real concern is the inlining of Sections/Paragraphs called by PERFORM, which doesn't occur as expected (despite the OPTIMIZE > 1 and the INLINE options) in the presence of certain CICS commands: 

    • EXEC CICS RETURN (workaround solution to allow inlining of Sections/Paragraphs called by PERFORM statements placed after this CICS command: add a COBOL GOBACK instruction avec the EXEC CICS RETURN command)
    • EXEC CICS HANDLE ABEND LABEL (no identified workaround solution to allow inlining of sections/paragraphs called by PERFORM statements placed after this CICS command)

    Let's focus on these.
    A case has been opened and it is currently being investigated by IBM.

    I have provided two programs for the case to illustrate the problem:

    • a program that does not use the EXEC CICS HANDLE ABEND LABEL command but only the EXEC CICS RETURN command
    • a program that uses both the EXEC CICS HANDLE ABEND LABEL and EXEC CICS RETURN commands

    Both programs are built on the same model, and this is the model that is applied to all our (new) COBOL / CICS programs:

    • a program prologue that calls main sections using PERFORM
    • an EXEC CICS RETURN command following this prologue 
    • the sections called by PERFORM, which in turn call other sections using PERFORM.

    It seems to me that this is a classic and common construction in structured COBOL (not using GO TO instructions).

    In the past, our COBOL CICS programs were produced by a code generator that used a linear code, with GO TO statements, either to return to the beginning of a loop or to skip blocks. The use of PERFORM remained relatively limited, and by design, the Sections/Paragraphs called by PERFORM were placed at the end of the source code. The lack of inlining of PERFORM statements was neither noticeable nor significant.
    Thanks.



    ------------------------------
    Denis FALLAI
    BPCE SI, BPCE group.
    ------------------------------



  • 19.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 7 days ago

    PS :

    @Mike: 

    The case of calling a subroutine to trigger the end of a process (among other things), and therefore a call without any return after the call, must be quite common in application processing.

    We have subroutines dedicated to this type of processing, both in batch and CICS.

    I think we should have a COBOL compilation directive to tell the compiler that there will be no return after the call (and the application processing must commit to this), so that it can do its optimization work as effectively as possible, without having to resort to coding tricks like adding GOBACK statements.

    This directive could potentially implement an abend handling in the event that there is a return after the call (as, for example, I believe is the case when the process tries to continue after the last instruction in the source code).



    ------------------------------
    Denis FALLAI
    BPCE SI, BPCE group.
    ------------------------------



  • 20.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 6 days ago

    Denis,

    I'm going to stick my nose in here and say BUGGER that.  Code the RETURN for all subroutines.  Period.  Full Stop.

    You want to code an Compiler Option rather than coding a RETURN?  Do you test your code as you write it?  COBOL and CICS have worked this way forever, so what were you doing last year or the year before? 

    I once had a programmer complain that his subroutine did not return the correct value.  When we looked at his code we discovered he forgot the parameter list in the CALL.  He then argued the subroutine should have notified him there was no parameter to return!   A parameter to indicate there is no parameter?

    Cheers,



    ------------------------------
    Jon Butler
    ------------------------------



  • 21.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 6 days ago

    I see both sides of this.

    Adding a directive (not an option! It'd need to be done in-place) could potentially help the optimizer produce better code in some cases. I do see the benefit in that. If this was brought as an RFE, we might accept it, but given the other things the compiler team has to work on, and that it's just a situational performance boost, I imagine this would be very low priority. If the potential performance gains are a more immediate concern, I wouldn't wait around for this. Even if we chose to implement it, it'd still take a good while before it was released, as we'd work on more significant work first.

    On the other hand, coding a GOBACK, which would be needed in every place the terminating program is called, is a less-good fix but can be done immediately.

    Another possibility that might situationally work is to refactor the terminating subprogram into a copybook so it's PERFORMed instead of CALLed. Obviously that might not work in the EXEC CICS ABEND case we've been discussing (though again, the compiler team hasn't confirmed yet that there's ALWAYS an EXEC CICS ABEND problem as opposed to it making a difference in your particular program) but it would work for others.

    I've seen many client programs that put their abend code in a paragraph, and that too makes it less likely the compiler team will implement a directive, as it wouldn't be of use for many of our clients.



    ------------------------------
    Mike Chase
    Lead Developer, watsonx Code Assistant For z Code Optimization Advice
    Developer, Enterprise COBOL
    mike.chase@ca.ibm.com
    ------------------------------



  • 22.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 6 days ago
    Edited by Denis FALLAI 6 days ago

    Hi Mike,

    Thank you for taking the time to respond to my posts.

    Regarding the compilation directive that tells the compiler about a non-explicit sequence break in the code, I create an Idea: COBOLVUE-I-425
    IBM Enterprise COBOL V6R4+ - Compilation directive to inform the compiler of the end of sequential code execution (call to exit / abend routine)

    Ibm remove preview
    IBM Enterprise COBOL V6R4+ - Compilation directive to | IBM Z Software
    View this on Ibm >

     

    Regarding the handling of a deliberate program termination due to abnormal termination, it all depends on what we want to do. 

    In our context, we have the simple abnormal termination, which is a paragraph to be PERFORMed, placed at the end of the source code. However, we also have more sophisticated abnormal termination cases, with processing that we don't want to duplicate in each program (for maintenance reasons). Therefore, we use dynamic CALLs for this.


    Note that I was able to resolve some cases by workaround (EXEC CICS RETURN, EXEC CICS ABEND), but I am stuck on the case of EXEC CICS HANDLE ABEND LABEL.


    Thanks.



    ------------------------------
    Denis FALLAI
    BPCE SI, BPCE group.
    ------------------------------



  • 23.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 21 days ago
    Mke,

    You are working on the compiler, so I think your perspective is different than those on the development side.  First, although the included COBOL CICS translator and SQL Processors have been available for 25 years, many shops continue to use the external versions.  Perhaps they don't trust something that has only soaked for 25 years, or perhaps they don't want to change their Endevor or Changeman scripts, but that's life in the real world.  I'm sure you are familiar with the COBOL 4.2 to 5 & 6.n move problems, which to (mis-)quote Tom Ross...."We had no idea people did not follow the rules".  

     If someone CALLs a subroutine in a CICS program, there is no CICS involved because the subroutine's executable is included in the Calling Program Object (NODYNAM).   Of course in a subroutine, if you need to use CICS facilities you have to pass the EIB block as the first argument, before your programs' parameters.   

    This may or may not be true in Batch, due to the several COBOL options available when the Calling program was compiled and Bound. (DYNAM, NODYNAM,  CALL 'literal", variable.)

     In a COBOL/CICS program, a LINK is often referred to as a subroutine, but it operates differently than a CALL.  You have to pass a Channel/Container or the DFHCOMMARA....whereas PL/I for example only needs a pointer...but that's a "feature" of COBOL

    I took the OP's problem to be that he was CALLing a subroutine; If so he should use a RETURN, GOBACK...or..."yikes"...even a STOP RUN. No doubt the compiler could parse the object and treat the code included by translator for the CICS RETURN as the RETURN point, but it might be more difficult to get it right in practice than theory because the CICS RETURN may not be at the logical or physical end of the program.  And suppose the OP decides to use a GOBACK to satisfy the compiler... which was the first problem....do you honour the GOBACK or the CICS RETURN?

    Cheers,

    Jon Butler





  • 24.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 20 days ago
    Edited by Denis FALLAI 20 days ago

    Hi Jon,

    For information, I just did a test using the same programs with the independent CICS preprocessor and the CICS coprocessor integrated into (or driven by) the IBM Enterprise COBOL compiler: no difference in the final binary code and in the processing of PERFORM inlining.

    The problem I raised concerns the inlining of PERFORM, and the use case of the CALL to a program that does not return (because it triggers an abend, but also does many other things) has only added confusion to the subject.

    As for the rest, I think Mike was referring to programs compiled in the same stream, including nested programs.

    The compiler cannot include separately compiled programs; that's the job of linkedit process (binder). And as far as we're concerned, we ensure that CALL in CICS program are always dynamic (this doesn't apply to the CICS stub DFHEI1 or the Db2 DSNALI stub): either by using the CALL DATA-ITEM syntax or the new >>callinterface directives.


    My analysis on this issue is that the compiler doesn't correctly detect sequence breaks in the COBOL instruction flow when CICS commands are present. These breaks are effectively executed as CALLS to the CICS stub, with potential return to caller, which limits its ability to inline PERFORM statements.

    Furthermore, even CICS commands that are supposed to cause sequence breaks (EXEC CICS RETURN, EXEC CICS XCTL, etc.) may fail to do so at runtime if they are unsuccessful (for example, due to a program not being found). This makes it very difficult for the compiler to decide... hence my attempts to implement safeguards to prevent inappropriate sequential execution, which remains true regardless of PERFORM statement inlining.


    After further consideration, I believe the compiler is acting as it should (considering potential sequential execution despite an intention to break the sequence), and that it's actually up to the program to handle these sequence breaks explicitly at the COBOL level. However, my CICS skills are too limited to know how to proceed...



    Thanks.



    ------------------------------
    Denis FALLAI
    BPCE SI, BPCE group.
    ------------------------------



  • 25.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 20 days ago

    > You are working on the compiler, so I think your perspective is different than those on the development side.  I'm sure you are familiar with the COBOL 4.2 to 5 & 6.n move problems

    I do have some familiarity with client perspectives, but not as much as someone who's ever worked as a COBOL developer would have. I am extremely familiar with the COBOL 4/earlier to COBOL 5+ migration issues; I was involved in many of the compiler fixes to mitigate those and was the one giving the monthly public COBOL Migration presentations up until COBOL 4.2 went out of service. That said, the team is always interested to hear more about how clients actually do things!


    > Please disregard my message about the external subprogram call intended to trigger an abend: it was just a digression to point out that the compiler cannot always know when there will be a break in the processing sequence. This could be a difficulty in inlining Sections/Paragraphs placed after the call instruction because the compiler might think they will be executed sequentially after the call.

    Ok, I see what you mean. Again though, paragraphs that can be flowed into from the preceding paragraphs aren't automatically excluded from being inlined, though they're perhaps less likely to be chosen for inlining.

    > After further consideration, I believe the compiler is acting as it should (considering potential sequential execution despite an intention to break the sequence)

    Not sure I agree, actually. In cases where the compiler can't be 100% sure there's a sequence break, yes, we must consider sequential flow as a possibility or else we can end up generating incorrect code. The abend-in-a-CALLed-subprogram case is a perfect example of this. But we could look at whether we handle EXEC CICS ABEND and similar as effectively as we should; there may be room for improvement.



    ------------------------------
    Mike Chase
    Lead Developer, watsonx Code Assistant For z Code Optimization Advice
    Developer, Enterprise COBOL
    mike.chase@ca.ibm.com
    ------------------------------



  • 26.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted 19 days ago

    Denis,

    Of course you are correct and I should have written the Binder includes subroutines in the Program Object depending on the compiler options.  

    Cheers,



    ------------------------------
    Jon Butler
    ------------------------------



  • 27.  RE: IBM Enterprise COBOL V6+ - Disabling optimizations when the CICS option is active

    Posted Mon October 20, 2025 08:39 AM

    Ah, yes.  The compiler expects you to end the program with a COBOL termination statement...GOBACK rather than STOP RUN in a CICS module.  



    ------------------------------
    Jon Butler
    ------------------------------