[llvm-dev] Accessing global variables arrays result in inlined getelementptrs

Michael Kruse via llvm-dev llvm-dev at lists.llvm.org
Thu Jul 25 07:57:35 PDT 2019


Am Mi., 24. Juli 2019 um 18:02 Uhr schrieb Antonin Reitz <antonin.reitz at ens.fr>:
> > The getelementptr has all constant argument, meaning it itself becomes
> > an GetElementPtrConstantExpr. ConstantExprs (in contrast to
> > instructions) are inlined by the IR emitter.
> >> - Is there a way to disable it (ideally while preserving optimisations
> >> disabled)?
>
> Is it something that would be relatively easy to change with a local
> patch for LLVM without introducing a lot of modifications? (only
> disabling GetElementPtrConstantExprs inlining)
>
> This is really something that would help having simpler static analysis,
> even if additional analysis of the code can be used as a (quite ugly)
> workaround.

One preprocess the in-memory IR before passing it to the IR printer:
Walk through all operands of all instructions in the module, if it
contains a GetElementPtrConstantExpr (it could be an argument of
another ConstantExpr), replace it with an GetElementPtrInst, which is
inserted before the instruction using it.

Michael


More information about the llvm-dev mailing list