Skip to content

Commit 0063330

Browse files
committed
[Attributor] Use getAllocaAddrSpace to get address space for AllocaInst
1 parent b5f7d3d commit 0063330

File tree

5 files changed

+898
-286
lines changed

5 files changed

+898
-286
lines changed

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12603,6 +12603,18 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
1260312603
auto CheckAddressSpace = [&](Value &Obj) {
1260412604
if (isa<UndefValue>(&Obj))
1260512605
return true;
12606+
// Some targets relax the requirement for alloca to be in an exact address
12607+
// space, allowing it in certain other address spaces instead. These
12608+
// targets later lower alloca to the correct address space in the
12609+
// pipeline. Therefore, we need to query TTI to determine the appropriate
12610+
// address space.
12611+
if (auto *AI = dyn_cast<AllocaInst>(&Obj)) {
12612+
Function *Fn = AI->getFunction();
12613+
auto *TTI =
12614+
A.getInfoCache().getAnalysisResultForFunction<TargetIRAnalysis>(
12615+
*Fn);
12616+
return takeAddressSpace(TTI->getAssumedAddrSpace(AI));
12617+
}
1260612618
// If an argument in flat address space only has addrspace cast uses, and
1260712619
// those casts are same, then we take the dst addrspace.
1260812620
if (auto *Arg = dyn_cast<Argument>(&Obj)) {

0 commit comments

Comments
 (0)