[llvm] r214336 - SimplifyCFG: Avoid miscompilations due to removed lifetime intrinsics.

Björn Steinbrink bsteinbr at gmail.com
Thu Mar 12 17:42:09 PDT 2015


Hi Tom,
Hi Rafael,

Can we get this into 3.5.2? The rust compiler emits lifetime intrinsics
and without this patch the optimized code is broken.

Cheers,
Björn

On 2014.07.30 21:04:00 -0000, Rafael Espindola wrote:
> Author: rafael
> Date: Wed Jul 30 16:04:00 2014
> New Revision: 214336
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=214336&view=rev
> Log:
> SimplifyCFG: Avoid miscompilations due to removed lifetime intrinsics.
> 
> The lifetime intrinsics need some work in order to make it clear which
> optimizations are or are not valid.
> 
> For now dropping this optimization avoids a miscompilation.
> 
> Patch by Bj?rn Steinbrink.
> 
> Modified:
>     llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
>     llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll
> 
> Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=214336&r1=214335&r2=214336&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Wed Jul 30 16:04:00 2014
> @@ -4008,7 +4008,7 @@ bool SimplifyCFGOpt::SimplifyUncondBranc
>      return true;
>  
>    // If the Terminator is the only non-phi instruction, simplify the block.
> -  BasicBlock::iterator I = BB->getFirstNonPHIOrDbgOrLifetime();
> +  BasicBlock::iterator I = BB->getFirstNonPHIOrDbg();
>    if (I->isTerminator() && BB != &BB->getParent()->getEntryBlock() &&
>        TryToSimplifyUncondBranchFromEmptyBlock(BB))
>      return true;
> 
> Modified: llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll?rev=214336&r1=214335&r2=214336&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll (original)
> +++ llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll Wed Jul 30 16:04:00 2014
> @@ -1,11 +1,11 @@
>  ; RUN: opt < %s -simplifycfg -S | FileCheck %s
>  
> -; Test that a lifetime intrinsic doesn't prevent us from simplifying this.
> +; Test that a lifetime intrinsic isn't removed because that would change semantics
>  
>  ; CHECK: foo
>  ; CHECK: entry:
> -; CHECK-NOT: bb0:
> -; CHECK-NOT: bb1:
> +; CHECK: bb0:
> +; CHECK: bb1:
>  ; CHECK: ret
>  define void @foo(i1 %x) {
>  entry:
> 
> 




More information about the llvm-commits mailing list