[PATCH] D17154: Bug fix: check nullptr before call dyn_cast

Chad Rosier via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 11 10:22:22 PST 2016


mcrosier added a subscriber: mcrosier.

================
Comment at: lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp:828
@@ +827,3 @@
+  if (FirstResult && ResultPtr) {
+    GetElementPtrInst *FirstGEP = dyn_cast<GetElementPtrInst>(FirstResult);
+    GetElementPtrInst *SecondGEP = dyn_cast<GetElementPtrInst>(ResultPtr);
----------------
You might consider using dyn_cast_or_null(), so you can reduce indent and fold the null checks into the inner if condition.

================
Comment at: test/CodeGen/AArch64/gep-nullptr.ll:6
@@ +5,3 @@
+
+%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 }
----------------
Can you please simplify some of the names, so this is more human readable?

================
Comment at: test/CodeGen/AArch64/gep-nullptr.ll:29
@@ +28,3 @@
+attributes #0 = { argmemonly nounwind }
+attributes #1 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="cortex-a57" "target-features"="+crc,+crypto,+neon" "unsafe-fp-math"="true" "use-soft-float"="false" }
+attributes #2 = { nounwind }
----------------
Please drop the attribute/metadata if it's not relevant to reproducing the issue.


Repository:
  rL LLVM

http://reviews.llvm.org/D17154





More information about the llvm-commits mailing list