[PATCH] D107574: [GlobalOpt] [MemoryBuiltins] Update getMallocType with bitcast on stored pointer

Shimin Cui via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 5 15:07:54 PDT 2021


scui added a comment.

In D107574#2929159 <https://reviews.llvm.org/D107574#2929159>, @efriedma wrote:

> If you going to mess with this code, can you just kill off all the malloc use type heuristics, and just unconditionally create an [i8 x n] array?  The existing type sniffing code won't work with opaque pointers anyway.

The existing code has been there for a while. It tries to get the type for the code in the following pattern:

  %call = call i8* @malloc
   %0 = bitcast i8* to T*
   store T* %0, %T** @g

This somehow can be transformed to the code:

  %call = call i8* @malloc
  store i8* %call, i8** bitcast (%T** @g to i8**)

The code here is trying to recognize the code pattern.

It looks to me the IR code will be sub-optimal for some cases if we simply return Type i8* for getMallocType. I’m thinking maybe we can return just either the only bitcasted type or the malloc return type, ie, no nullptr return, but I’m not sure if this really matters for real cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107574



More information about the llvm-commits mailing list