Skip to content

Commit fcda226

Browse files
committed
Fix setTargetTriple call
setTargetTriple function definition change after llvm/llvm-project#129868 change CaptureInfo::none to be compatible with LLVM21+
1 parent 7b43680 commit fcda226

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

src/compiler/cbs/SubCfgFormation.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,14 @@ bool fillUserHull(llvm::AllocaInst *Alloca, llvm::SmallVectorImpl<llvm::Instruct
11411141
WL.push_back(UI);
11421142
if (auto CI = llvm::dyn_cast<llvm::CallBase>(UI)) {
11431143
auto OperandNo = U.getOperandNo();
1144-
if (!CI->dataOperandHasImpliedAttr(OperandNo, llvm::Attribute::NoCapture) &&
1144+
#if LLVM_VERSION_MAJOR > 20
1145+
if (!CI->dataOperandHasImpliedAttr(
1146+
OperandNo, llvm::Attribute::getWithCaptureInfo(
1147+
CI->getContext(),llvm::CaptureInfo::none()).getKindAsEnum()) &&
1148+
#else
1149+
if (!CI->dataOperandHasImpliedAttr(
1150+
OperandNo, llvm::Attribute::NoCapture) &&
1151+
#endif
11451152
!CI->dataOperandHasImpliedAttr(OperandNo, llvm::Attribute::StructRet)) {
11461153
HIPSYCL_DEBUG_INFO << "[SubCFG] Found function call that captures " << *I << ": "
11471154
<< *CI << " OperandNo: " << OperandNo << "\n";

src/compiler/llvm-to-backend/LLVMToBackend.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ bool linkBitcode(llvm::Module &M, std::unique_ptr<llvm::Module> OtherM,
137137
const std::string &ForcedDataLayout = "",
138138
llvm::Linker::Flags Flags = llvm::Linker::Flags::LinkOnlyNeeded) {
139139
if(!ForcedTriple.empty())
140+
#if LLVM_VERSION_MAJOR > 20
141+
OtherM->setTargetTriple(llvm::Triple(ForcedTriple));
142+
#else
140143
OtherM->setTargetTriple(ForcedTriple);
144+
#endif
141145
if(!ForcedDataLayout.empty())
142146
OtherM->setDataLayout(ForcedDataLayout);
143147

src/compiler/llvm-to-backend/amdgpu/LLVMToAmdgpu.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,12 @@ LLVMToAmdgpuTranslator::LLVMToAmdgpuTranslator(const std::vector<std::string> &K
263263

264264
bool LLVMToAmdgpuTranslator::toBackendFlavor(llvm::Module &M, PassHandler& PH) {
265265

266+
#if LLVM_VERSION_MAJOR > 20
267+
M.setTargetTriple(llvm::Triple(TargetTriple));
268+
#else
266269
M.setTargetTriple(TargetTriple);
270+
#endif
271+
267272
#if LLVM_VERSION_MAJOR >= 18
268273
M.setDataLayout("e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:"
269274
"32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:"

src/compiler/llvm-to-backend/ptx/LLVMToPtx.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,12 @@ bool LLVMToPtxTranslator::toBackendFlavor(llvm::Module &M, PassHandler& PH) {
141141
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-i128:128:128-f32:32:32-"
142142
"f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64";
143143

144+
#if LLVM_VERSION_MAJOR > 20
145+
M.setTargetTriple(llvm::Triple(Triple));
146+
#else
144147
M.setTargetTriple(Triple);
148+
#endif
149+
145150
M.setDataLayout(DataLayout);
146151

147152
// Initialize libdevice parameters. These values are < 0 in case no explicit

src/compiler/llvm-to-backend/spirv/LLVMToSpirv.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,12 @@ LLVMToSpirvTranslator::LLVMToSpirvTranslator(const std::vector<std::string> &KN)
187187
KernelNames{KN} {}
188188

189189
bool LLVMToSpirvTranslator::toBackendFlavor(llvm::Module &M, PassHandler& PH) {
190-
190+
191+
#if LLVM_VERSION_MAJOR > 20
192+
M.setTargetTriple(llvm::Triple("spir64-unknown-unknown"));
193+
#else
191194
M.setTargetTriple("spir64-unknown-unknown");
195+
#endif
192196
M.setDataLayout("e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:"
193197
"1024-A4-n8:16:32:64");
194198

@@ -226,7 +230,11 @@ bool LLVMToSpirvTranslator::toBackendFlavor(llvm::Module &M, PassHandler& PH) {
226230
common::filesystem::join_path(common::filesystem::get_install_directory(),
227231
{"lib", "hipSYCL", "bitcode", "libkernel-sscp-spirv-full.bc"});
228232

233+
#if LLVM_VERSION_MAJOR > 20
234+
if (!this->linkBitcodeFile(M, BuiltinBitcodeFile, M.getTargetTriple().str(), M.getDataLayoutStr()))
235+
#else
229236
if (!this->linkBitcodeFile(M, BuiltinBitcodeFile, M.getTargetTriple(), M.getDataLayoutStr()))
237+
#endif
230238
return false;
231239

232240
// Set up local memory

0 commit comments

Comments
 (0)