]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Disable if expression optimization for LLVM
authorArnaud Charlet <charlet@adacore.com>
Fri, 19 Aug 2022 16:25:45 +0000 (16:25 +0000)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 6 Sep 2022 07:14:22 +0000 (09:14 +0200)
gcc/ada/

* exp_ch4.adb (Expand_N_If_Expression): Disable optimization
for LLVM.

gcc/ada/exp_ch4.adb

index 18fb88f3f9f42eaaba63049e0b25f85f2f21acf3..0b7e3911c6a94503982abeb822f7442005b122ee 100644 (file)
@@ -6135,6 +6135,10 @@ package body Exp_Ch4 is
       --  itself such a slice, in order to catch if expressions with more than
       --  two dependent expressions in the source code.
 
+      --  Also note that this creates variables on branches without an explicit
+      --  scope, causing troubles with e.g. the LLVM IR, so disable this
+      --  optimization when Unnest_Subprogram_Mode (enabled for LLVM).
+
       elsif Is_Array_Type (Typ)
         and then Number_Dimensions (Typ) = 1
         and then not Is_Constrained (Typ)
@@ -6151,6 +6155,7 @@ package body Exp_Ch4 is
              and then
                OK_For_Single_Subtype (Etype (Thenx), Etype (Prefix (Elsex)))))
         and then not Generate_C_Code
+        and then not Unnest_Subprogram_Mode
       then
          declare
             Ityp : constant Entity_Id := Base_Type (Etype (First_Index (Typ)));