[PATCH] D117249: [GlobalOpt] Generalize malloc-to-global transformation by discarding type

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 13 13:38:02 PST 2022


reames created this revision.
reames added reviewers: nikic, fhahn, lebedev.ri.
Herald added subscribers: ormris, bollu, hiraditya, mcrosier.
reames requested review of this revision.
Herald added a project: LLVM.

The existing code goes to some length to try to use the type of the malloc.  However, allocation returns *storage* and LLVM's memory model doesn't included typed memory.  As a result, this seems to simply discard cases we can easily handle.   I see no strong reason to prefer a global of one type over another.

As a side effect, we can delete a bunch of complicated code.

This seems too easy.  A skeptical second set of eyes is appreciated.  Am I missing something?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117249

Files:
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/test/Transforms/GlobalOpt/2021-08-03-StoreOnceLoadMultiCasts.ll
  llvm/test/Transforms/GlobalOpt/malloc-promote-5.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117249.399770.patch
Type: text/x-patch
Size: 10246 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220113/a191f5a9/attachment-0001.bin>


More information about the llvm-commits mailing list