This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU: Introduce function pass version of LowerIntrinsics
AbandonedPublic

Authored by arsenm on Nov 17 2022, 3:13 PM.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

This is in preparation for a patch which requires use of
a function analysis, which I'm not sure we can get in
a module pass.

Diff Detail

Event Timeline

arsenm created this revision.Nov 17 2022, 3:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 17 2022, 3:13 PM
arsenm requested review of this revision.Nov 17 2022, 3:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 17 2022, 3:13 PM
Herald added a subscriber: wdng. · View Herald Transcript

Looks good to me, I just added few cosmetical remarks.

llvm/lib/Target/AMDGPU/AMDGPULowerIntrinsics.cpp
135

Here too.

181

You could replace the double getParent() by a single call to getFunction()

237

I think you can avoid the switch if you used the return value of expandMemIntrinsic and makeLIDRangeMetadata.

for (Function::iterator I = F.begin(), E = F.end(); I != E;) {
    BasicBlock *BB = &*I++;
    for (BasicBlock::iterator J = BB->begin(), JE = BB->end(); J != JE;) {
      IntrinsicInst *Intrin = dyn_cast<IntrinsicInst>(&*J++);
      if (!Intrin)
        continue;
      if (expandMemIntrinsic(Intrin, TTI)) {
          BB = Intrin->getParent();
          JE = BB->end();
          Intrin->eraseFromParent();
          Changed = true;
          continue;
       }
       Changed |= ST.makeLIDRangeMetadata(Intrin);
    }
}

However, that would also mark the range for the amdgcn_workitem_id_xyz intrinsics and I'm not sure if that's expected.

arsenm abandoned this revision.Jun 9 2023, 7:11 PM

Whole pass is deleted now