[PATCH] D16986: [LICM] Don't assert on volatile accesses
Matthew Simpson via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 8 07:33:34 PST 2016
mssimpso created this revision.
mssimpso added reviewers: reames, majnemer, sanjoy.
mssimpso added subscribers: llvm-commits, mcrosier.
A constant pointer in a non-volatile alias set (e.g., null) may be used by volatile accesses. For such cases, we might should bail out instead of asserting. This should fix PR25628.
Contributed-by: Ed Baunton
http://reviews.llvm.org/D16986
Files:
lib/Transforms/Scalar/LICM.cpp
test/Transforms/LICM/PR25628.ll
Index: test/Transforms/LICM/PR25628.ll
===================================================================
--- /dev/null
+++ test/Transforms/LICM/PR25628.ll
@@ -0,0 +1,29 @@
+; RUN: opt -S -tbaa -licm < %s | FileCheck %s
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK-NOT: %load2 = load i32*, i32** @b
+
+ at b = external global i32*, align 8
+
+define void @f(i1 %B, i1 %D) {
+entry:
+ br i1 %B, label %for.body, label %for.end4
+
+for.body:
+ store i32* null, i32** @b, align 8, !tbaa !0
+ store i32 1, i32* null, align 8
+ %load2 = load i32*, i32** @b, align 8, !tbaa !0
+ %load3 = load volatile i32, i32* %load2, align 8, !tbaa !4
+ br i1 %D, label %for.body, label %for.end4
+
+for.end4:
+ ret void
+}
+
+!0 = !{!1, !1, i64 0}
+!1 = !{!"any pointer", !2, i64 0}
+!2 = !{!"omnipotent char", !3, i64 0}
+!3 = !{!"Simple C/C++ TBAA"}
+!4 = !{!5, !5, i64 0}
+!5 = !{!"int", !2, i64 0}
Index: lib/Transforms/Scalar/LICM.cpp
===================================================================
--- lib/Transforms/Scalar/LICM.cpp
+++ lib/Transforms/Scalar/LICM.cpp
@@ -954,16 +954,14 @@
// If there is an non-load/store instruction in the loop, we can't promote
// it.
if (const LoadInst *Load = dyn_cast<LoadInst>(UI)) {
- assert(!Load->isVolatile() && "AST broken");
- if (!Load->isSimple())
+ if (!Load->isSimple() || !Load->isUnordered())
return Changed;
} else if (const StoreInst *Store = dyn_cast<StoreInst>(UI)) {
// Stores *of* the pointer are not interesting, only stores *to* the
// pointer.
if (UI->getOperand(1) != ASIV)
continue;
- assert(!Store->isVolatile() && "AST broken");
- if (!Store->isSimple())
+ if (!Store->isSimple() || !Store->isUnordered())
return Changed;
// Don't sink stores from loops without dedicated block exits. Exits
// containing indirect branches are not transformed by loop simplify,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16986.47197.patch
Type: text/x-patch
Size: 2042 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160208/5e01d4b6/attachment.bin>
More information about the llvm-commits
mailing list