[PATCH] D94355: [Passes] Add relative lookup table converter pass

Gulfem Savrun Yeniceri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 12 18:12:06 PST 2021


gulfem marked 7 inline comments as done.
gulfem added inline comments.


================
Comment at: llvm/include/llvm/CodeGen/BasicTTIImpl.h:384
 
+  bool shouldBuildRelLookupTables() {
+    const TargetMachine &TM = getTLI()->getTargetMachine();
----------------
leonardchan wrote:
> Sorry, I think you might have explained this offline, but what was the reason for needing this in TTI? I would've though this information could be found in the `Module` (PIC/no PIC, 64-bit or not, code model). If it turns out all of this is available in `Module`, then we could greatly simplify some logic here by just checking this at the start of the pass run.
> 
> If TTI is needed, then perhaps it may be better to just inline all these checks in `convertToRelativeLookupTables` since this is the only place this is called. I think we would only want to keep this here as a virtual method if we plan to have multiple TTI-impls overriding this.
Code model or PIC/noPIC is only set in the module if the user explicitly specifies them.
TTI hook is necessary to access target machine information like the default code model.
TTI is basically the interface to communicate between IR transformations and codegen. 

I think the checks cannot be moved into the pass because it uses the TargetMachine which is only available/visible in the TTI implementation itself.
That's why I added a function into TTI to do target machine specific checks.
Similar approach is used during lookup table generation (`shouldBuildLookupTables`) to check codegen info.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94355



More information about the cfe-commits mailing list