|
34 | 34 | #include "llvm/IR/Module.h"
|
35 | 35 | #include "llvm/IR/PatternMatch.h"
|
36 | 36 | #include "llvm/Pass.h"
|
| 37 | +#include "llvm/Support/ModRef.h" |
37 | 38 | #include "llvm/Support/raw_ostream.h"
|
38 | 39 |
|
39 | 40 | #include <cctype>
|
@@ -1046,12 +1047,20 @@ static Instruction *generateGenXCall(Instruction *EEI, StringRef IntrinName,
|
1046 | 1047 | ? GenXIntrinsic::getGenXDeclaration(
|
1047 | 1048 | EEI->getModule(), ID, FixedVectorType::get(I32Ty, MAX_DIMS))
|
1048 | 1049 | : GenXIntrinsic::getGenXDeclaration(EEI->getModule(), ID);
|
| 1050 | + // llvm::Attribute::ReadNone must not be used for call statements anymore. |
| 1051 | + bool FixReadNone = |
| 1052 | + NewFDecl->getFnAttribute(llvm::Attribute::ReadNone).isValid(); |
| 1053 | + if (FixReadNone) |
| 1054 | + NewFDecl->removeFnAttr(llvm::Attribute::ReadNone); |
| 1055 | + |
1049 | 1056 | // Use hardcoded prefix when EEI has no name.
|
1050 | 1057 | std::string ResultName =
|
1051 | 1058 | ((EEI->hasName() ? Twine(EEI->getName()) : Twine("Res")) + "." +
|
1052 | 1059 | FullIntrinName)
|
1053 | 1060 | .str();
|
1054 | 1061 | Instruction *Inst = IntrinsicInst::Create(NewFDecl, {}, ResultName, EEI);
|
| 1062 | + if (FixReadNone) |
| 1063 | + (cast<CallInst>(Inst))->setMemoryEffects(MemoryEffects::none()); |
1055 | 1064 | Inst->setDebugLoc(EEI->getDebugLoc());
|
1056 | 1065 |
|
1057 | 1066 | if (IsVectorCall) {
|
@@ -1394,14 +1403,21 @@ static void translateESIMDIntrinsicCall(CallInst &CI) {
|
1394 | 1403 | GenXOverloadedTypes);
|
1395 | 1404 | }
|
1396 | 1405 |
|
1397 |
| - Instruction *NewCI = IntrinsicInst::Create( |
| 1406 | + // llvm::Attribute::ReadNone must not be used for call statements anymore. |
| 1407 | + bool FixReadNone = |
| 1408 | + NewFDecl->getFnAttribute(llvm::Attribute::ReadNone).isValid(); |
| 1409 | + if (FixReadNone) |
| 1410 | + NewFDecl->removeFnAttr(llvm::Attribute::ReadNone); |
| 1411 | + CallInst *NewCI = IntrinsicInst::Create( |
1398 | 1412 | NewFDecl, GenXArgs,
|
1399 | 1413 | NewFDecl->getReturnType()->isVoidTy() ? "" : CI.getName() + ".esimd",
|
1400 | 1414 | &CI);
|
1401 |
| - if (CI.getDebugLoc()) |
1402 |
| - NewCI->setDebugLoc(CI.getDebugLoc()); |
1403 |
| - NewCI = addCastInstIfNeeded(&CI, NewCI); |
1404 |
| - CI.replaceAllUsesWith(NewCI); |
| 1415 | + if (FixReadNone) |
| 1416 | + NewCI->setMemoryEffects(MemoryEffects::none()); |
| 1417 | + NewCI->setDebugLoc(CI.getDebugLoc()); |
| 1418 | + |
| 1419 | + Instruction *NewInst = addCastInstIfNeeded(&CI, NewCI); |
| 1420 | + CI.replaceAllUsesWith(NewInst); |
1405 | 1421 | CI.eraseFromParent();
|
1406 | 1422 | }
|
1407 | 1423 |
|
|
0 commit comments