[PATCH] D104950: [OpaquePtr] Support forward references in textual IR

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 25 13:59:58 PDT 2021


nikic created this revision.
nikic added a reviewer: opaque-pointers.
Herald added subscribers: ormris, dexonsmith, okura, kuter, hiraditya, jgravelle-google, sbc100, dschuff.
nikic requested review of this revision.
Herald added subscribers: llvm-commits, bbn, aheejin.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a reviewer: baziotis.
Herald added a project: LLVM.

Currently, LLParser will create a Function/GlobalVariable forward reference based on the desired pointer type and then modify it when it is declared. With opaque pointers, we generally do not know the correct type to use until we see the declaration.

Solve this by creating the forward reference with a dummy type, and then performing a RAUW with the correct Function/GlobalVariable when it is declared. The approach is shamelessly stolen from https://github.com/TNorthover/llvm-project/commit/b5b55963f62038319fa7a8b1b232226ba1d8ef3c.

This results in a change to the use list order, which is why we see test changes on some module passes that are not stable under reordering.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104950

Files:
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/test/CodeGen/WebAssembly/add-prototypes-conflict.ll
  llvm/test/Other/force-opaque-ptrs.ll
  llvm/test/Transforms/Attributor/IPConstantProp/PR16052.ll
  llvm/test/Transforms/Attributor/misc.ll
  llvm/test/Transforms/FunctionSpecialization/function-specialization3.ll
  llvm/test/Transforms/FunctionSpecialization/function-specialization4.ll
  llvm/test/Transforms/LowerTypeTests/function-weak.ll
  llvm/test/Transforms/LowerTypeTests/icall-branch-funnel.ll
  llvm/test/Transforms/OpenMP/parallel_deletion_remarks.ll
  llvm/test/Transforms/WholeProgramDevirt/branch-funnel.ll
  llvm/test/Transforms/WholeProgramDevirt/virtual-const-prop-begin.ll
  llvm/test/Transforms/WholeProgramDevirt/virtual-const-prop-check.ll
  llvm/test/Transforms/WholeProgramDevirt/virtual-const-prop-end.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104950.354599.patch
Type: text/x-patch
Size: 37375 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210625/8354fcfe/attachment-0001.bin>


More information about the llvm-commits mailing list