[llvm] r286300 - GlobalISel: make sure debugging variables are appropriately elided in release builds.

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 10 14:53:31 PST 2016


Hi David,

> On Nov 8, 2016, at 2:03 PM, David L. Jones via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> Author: dlj
> Date: Tue Nov  8 16:03:23 2016
> New Revision: 286300
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=286300&view=rev
> Log:
> GlobalISel: make sure debugging variables are appropriately elided in release builds.
> 
> Summary:
> There are two variables here that break. This change constrains both of them to
> debug builds (via DEBUG() or #ifndef NDEBUG).
> 
> Reviewers: bkramer, t.p.northover
> 
> Subscribers: mehdi_amini, vkalintiris
> 
> Differential Revision: https://reviews.llvm.org/D26421
> 
> Modified:
>    llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelect.cpp
> 
> Modified: llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelect.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelect.cpp?rev=286300&r1=286299&r2=286300&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelect.cpp (original)
> +++ llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelect.cpp Tue Nov  8 16:03:23 2016
> @@ -69,6 +69,8 @@ bool InstructionSelect::runOnMachineFunc
>   // FIXME: freezeReservedRegs is now done in IRTranslator, but there are many
>   // other MF/MFI fields we need to initialize.
> 
> +  const MachineRegisterInfo &MRI = MF.getRegInfo();
> +
> #ifndef NDEBUG
>   // Check that our input is fully legal: we require the function to have the
>   // Legalized property, so it should be.
> @@ -77,7 +79,6 @@ bool InstructionSelect::runOnMachineFunc
>   // The RegBankSelected property is already checked in the verifier. Note
>   // that it has the same layering problem, but we only use inline methods so
>   // end up not needing to link against the GlobalISel library.
> -  const MachineRegisterInfo &MRI = MF.getRegInfo();
>   if (const LegalizerInfo *MLI = MF.getSubtarget().getLegalizerInfo())
>     for (const MachineBasicBlock &MBB : MF)
>       for (const MachineInstr &MI : MBB)
> @@ -99,9 +100,10 @@ bool InstructionSelect::runOnMachineFunc
>     bool ReachedBegin = false;
>     for (auto MII = std::prev(MBB->end()), Begin = MBB->begin();
>          !ReachedBegin;) {
> +#ifndef NDEBUG
>       // Keep track of the insertion range for debug printing.
>       const auto AfterIt = std::next(MII);
> -
> +#endif

Isn’t the idiom to use "(void)” in such cases instead of introducing ifdefs?

>       // Select this instruction.
>       MachineInstr &MI = *MII;
> 
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list