[PATCH] D97971: [IPSCCP] don't propagate constant in section when caller/callee sections mismatch

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 5 17:28:17 PST 2021


jdoerfert added a comment.

In D97971#2607999 <https://reviews.llvm.org/D97971#2607999>, @MaskRay wrote:

>>> This does not sound right to me.
>>> If the kernel wants to have an optimization barrier on the arguments, it should use some attributes if it does not want to use `alwaysinline`.
>>
>> Are there existing attributes we can use on parameters or arguments?
>
> Hope @jdoerfert can shed some light on the attribute usage here...

The only existing one to disable this would be `optnone`, IIRC, not that it is a solution here. More than once people asked for `noipa` to disable interprocedural optimization across a call edge. While that might help we'd still need to attach it all over the place and the way I understand the problem we are only concerned with constant prop, not things like inlining.

I guess I would have put something like this into `TargetTransformInfo` only because helpers like `areFunctionArgsABICompatible` and `areInlineCompatible` are there as well:

  /// TODO
  bool isConstantCompatibleWithCallee(Constant &C, CallBase &CB) {
    Function *Callee = CB.getCalledFunction();
    if (auto *GV = dyn_cast<GlobalValue>(C.stripInBoundsConstantOffsets()))
      return Callee && Callee->getSection() == GV->getSection();
    return true;
  }

I can add the AbstractCallSite version after.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97971



More information about the llvm-commits mailing list