[PATCH] D109565: Teach SimplifyCFG to fold switches into lookup tables in more cases.

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 15 13:09:19 PDT 2021


nikic added inline comments.


================
Comment at: llvm/test/Transforms/SimplifyCFG/switch-to-lookup-gep.ll:80
+bb14:
+  %.sroa.0.0 = phi [0 x i8]* [ getelementptr inbounds ([0 x i8], [0 x i8]* bitcast (<{ [1 x i8] }>* @alloc25 to [0 x i8]*), i32 0), %bb1 ], [ bitcast (<{ [1 x i8] }>* @alloc26 to [0 x i8]*), %bb13 ], [ bitcast (<{ [1 x i8] }>* @alloc27 to [0 x i8]*), %bb12 ], [ bitcast (<{ [1 x i8] }>* @alloc28 to [0 x i8]*), %bb11 ], [ bitcast (<{ [1 x i8] }>* @alloc29 to [0 x i8]*), %bb10 ], [ bitcast (<{ [1 x i8] }>* @alloc30 to [0 x i8]*), %bb9 ], [ bitcast (<{ [1 x i8] }>* @alloc31 to [0 x i8]*), %bb8 ], [ bitcast (<{ [1 x i8] }>* @alloc32 to [0 x i8]*), %bb7 ], [ bitcast (<{ [1 x i8] }>* @alloc33 to [0 x i8]*), %bb6 ], [ bitcast (<{ [1 x i8] }>* @alloc34 to [0 x i8]*), %bb5 ], [ bitcast (<{ [1 x i8] }>* @alloc35 to [0 x i8]*), %bb4 ], [ bitcast (<{ [1 x i8] }>* @alloc36 to [0 x i8]*), %start ]
+  %1 = insertvalue { [0 x i8]*, i64 } undef, [0 x i8]* %.sroa.0.0, 0
----------------
resistor wrote:
> nikic wrote:
> > This only tests a GEP with a zero offset, which is a degenerate case. It would be better to test a non-zero offset.
> > 
> > We could also have a negative test that no lookup table is created if a GEP index is not a constant integer (but rather something like `ptrtoint i8* @g to i64`.
> Updated test to use non-zero offsets. The proposed negative test doesn't fail, and it's not clear to me that it should fail. 
This would effectively correspond to a "global1 + global2" expression, which is not a generally (or at all?) supported relocation type.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109565/new/

https://reviews.llvm.org/D109565



More information about the llvm-commits mailing list