[PATCH] D17154: Bug fix: use dyn_cast_or_null instead of dyn_cast
Lawrence Hu via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 12 13:54:46 PST 2016
hulx2000 updated this revision to Diff 47853.
Repository:
rL LLVM
http://reviews.llvm.org/D17154
Files:
lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
test/CodeGen/AArch64/gep-nullptr.ll
Index: test/CodeGen/AArch64/gep-nullptr.ll
===================================================================
--- /dev/null
+++ test/CodeGen/AArch64/gep-nullptr.ll
@@ -0,0 +1,27 @@
+; RUN: llc -O3 -aarch64-gep-opt=true < %s
+; REQUIRES: asserts
+target datalayout = "e-m:e-i64:64-i128:128-n8:16:32:64-S128"
+target triple = "aarch64--linux-gnu"
+
+%struct.b_ctxt_t.23.226.487.516.545.661.690.719.748.777.1038.1219 = type { i8, i8, i8, i8, i8, i8, [4 x i8], i8, i8, [2 x i32], [2 x %union.MV.9.212.473.502.531.647.676.705.734.763.1024.1218], [4 x [2 x %union.MV.9.212.473.502.531.647.676.705.734.763.1024.1218]], [4 x [2 x %union.MV.9.212.473.502.531.647.676.705.734.763.1024.1218]], [4 x i8], i8*, i8*, i32, i8* }
+%union.MV.9.212.473.502.531.647.676.705.734.763.1024.1218 = type { i32 }
+
+; Function Attrs: argmemonly nounwind
+declare void @llvm.lifetime.end(i64, i8* nocapture)
+
+; Function Attrs: nounwind
+define void @test(%struct.b_ctxt_t.23.226.487.516.545.661.690.719.748.777.1038.1219* %mi_block) {
+entry:
+ br i1 undef, label %for.body13.us, label %if.else
+
+; CHECK: .text
+for.body13.us: ; preds = %entry
+ %indvars.iv.next40 = or i64 0, 1
+ %packed4.i.us.1 = getelementptr inbounds %struct.b_ctxt_t.23.226.487.516.545.661.690.719.748.777.1038.1219, %struct.b_ctxt_t.23.226.487.516.545.661.690.719.748.777.1038.1219* %mi_block, i64 0, i32 11, i64 0, i64 %indvars.iv.next40, i32 0
+ call void @llvm.lifetime.end(i64 8, i8* nonnull undef) #2
+ unreachable
+
+if.else: ; preds = %entry
+ ret void
+}
+
Index: lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
===================================================================
--- lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
+++ lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
@@ -824,8 +824,8 @@
// If we created a GEP with constant index, and the base is loop invariant,
// then we swap the first one with it, so LICM can move constant GEP out
// later.
- GetElementPtrInst *FirstGEP = dyn_cast<GetElementPtrInst>(FirstResult);
- GetElementPtrInst *SecondGEP = dyn_cast<GetElementPtrInst>(ResultPtr);
+ GetElementPtrInst *FirstGEP = dyn_cast_or_null<GetElementPtrInst>(FirstResult);
+ GetElementPtrInst *SecondGEP = dyn_cast_or_null<GetElementPtrInst>(ResultPtr);
if (isSwapCandidate && isLegalToSwapOperand(FirstGEP, SecondGEP, L))
swapGEPOperand(FirstGEP, SecondGEP);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17154.47853.patch
Type: text/x-patch
Size: 2462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160212/9cb1b361/attachment.bin>
More information about the llvm-commits
mailing list