================ @@ -0,0 +1,105 @@ +; Test that BasicAA conservatively returns MayAlias for local allocas in +; functions containing returns_twice calls (e.g. setjmp/sigsetjmp), to prevent +; miscompilation via longjmp re-entry paths invisible in the forward CFG. +; +; Reproduces: https://github.com/llvm/llvm-project/issues/198967 +; +; Without the fix, GVN incorrectly concludes that the store through %p_val +; (which may alias %i via a longjmp re-entry) cannot modify %i, then DSE +; eliminates the "store i32 13, ptr %i" as dead. The fix makes +; EarliestEscapeAnalysis conservatively bail out at the point where +; isNotCapturedBefore would otherwise return true, if the function contains +; any returns_twice call. + +; RUN: opt < %s -aa-pipeline=basic-aa -passes=gvn,dse -S | FileCheck %s + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@x = external global i32 +@ii = external global i32 +@p = external global ptr + +declare void @redo() +declare void @checkpoint() #0 + +; Control case: function has the same CFG structure but calls no +; returns_twice function. GVN/DSE can legally eliminate "store i32 13, ptr %i" +; because in the forward CFG the only path to if.else does not pass through +; if.then (where &i is stored to @p). BasicAA correctly returns NoAlias for +; (%i, %p_val) here. +; +; Fix case CHECK directives are listed here so that CHECK-NOT is correctly +; scoped between the two CHECK-LABELs: it checks that the store is absent in +; bar_no_returns_twice and present in bar_with_returns_twice. +; +; CHECK-LABEL: define void @bar_no_returns_twice( +; CHECK-NOT: store i32 13, ptr %i +; CHECK-LABEL: define void @bar_with_returns_twice( +; CHECK: store i32 13, ptr %i ---------------- midhuncodes7 wrote:
CHECKs Generated using the script https://github.com/llvm/llvm-project/pull/212297 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
