[PATCH] D152328: InstrProf - don't emit 64 bit atomic operations on 32 bit platforms

Sean Mollet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 20 18:01:40 PDT 2023

SeanMollet added a comment.

In D152328#4436337 <https://reviews.llvm.org/D152328#4436337>, @ellis wrote:

> Even with a static flag, that doesn't stop the warning from showing up from each clang invocation if you aren't using LTO.

True. At least it would only be once per file. Without a flag, it would throw at least twice per file. I don't know the call pattern into PGO, so maybe more than that. At least twice though, which seems worth a flag. Open to suggestions, I only want to do the "right" thing..

> By the way, why not simply use `-fprofile-update=single` (which I think will set `Options.Atomic = false`) for your use case? Now that I look closely, all the atomic flags seem to be false by default. Where are you seeing atomic instructions emitted for you?

Forgive me if I get the exact wording of this wrong, this is the my first foray into LLVM.

Because the intrinsics aren't being emitted by the backend. They're being converted to an atomic directly by InstrProfiling.cpp which doesn't look at that option.

PassBuilderPipelines.cpp line 787 effectively sets the default for InstrProfiling.cpp to true. DoCounterPromotion=true uses atomics.

  // Add the profile lowering pass.
  InstrProfOptions Options;
  if (!ProfileFile.empty())
    Options.InstrProfileOutput = ProfileFile;
  // Do counter promotion at Level greater than O0.
  Options.DoCounterPromotion = true;
  Options.UseBFIInPromotion = IsCS;
  MPM.addPass(InstrProfiling(Options, IsCS));



More information about the llvm-commits mailing list