From 63499dbd7dd5c8ea814d07e0e6f5c254ff403a5b Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Fri, 19 Aug 2022 16:25:45 +0000 Subject: [PATCH] [Ada] Disable if expression optimization for LLVM gcc/ada/ * exp_ch4.adb (Expand_N_If_Expression): Disable optimization for LLVM. --- gcc/ada/exp_ch4.adb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 18fb88f3f9f4..0b7e3911c6a9 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -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))); -- 2.47.3