diff --git a/deps.json b/deps.json index 797b29d74..7963c66cd 100644 --- a/deps.json +++ b/deps.json @@ -6,7 +6,7 @@ "subrepo" : "llvm/llvm-project", "branch" : "main", "subdir" : "third_party/llvm", - "commit" : "d5a3de4aeef4f4f1c52692533ddb9fdf45aef9d3" + "commit" : "0f1847cb2c5462a09d65a9b5ac24904ac3c15a0f" }, { "name" : "SPIRV-Headers", diff --git a/lib/ClusterPodKernelArgumentsPass.cpp b/lib/ClusterPodKernelArgumentsPass.cpp index 95554b560..1054d8dee 100644 --- a/lib/ClusterPodKernelArgumentsPass.cpp +++ b/lib/ClusterPodKernelArgumentsPass.cpp @@ -238,6 +238,7 @@ clspv::ClusterPodKernelArgumentsPass::run(Module &M, ModuleAnalysisManager &) { // Create the new function and set key properties. auto NewFunc = Function::Create(NewFuncTy, F->getLinkage()); + NewFunc->setIsNewDbgInfoFormat(true); // The new function adopts the real name so that linkage to the outside // world remains the same. NewFunc->setName(F->getName()); diff --git a/lib/Compiler.cpp b/lib/Compiler.cpp index bf593f497..5838dc8ca 100644 --- a/lib/Compiler.cpp +++ b/lib/Compiler.cpp @@ -1049,9 +1049,19 @@ bool LinkBuiltinLibrary(llvm::Module *module) { Err.print("internal_additional_library:", llvm::errs()); return false; } + for (auto &F : *add_library) { + if (!F.isDeclaration()) { + F.setIsNewDbgInfoFormat(true); + } + } L.linkInModule(std::move(add_library), 0); } + for (auto &F : *library) { + if (!F.isDeclaration()) { + F.setIsNewDbgInfoFormat(true); + } + } L.linkInModule(std::move(library), 0); return true; diff --git a/lib/DefineOpenCLWorkItemBuiltinsPass.cpp b/lib/DefineOpenCLWorkItemBuiltinsPass.cpp index 7cf83dd60..e31b7eb22 100644 --- a/lib/DefineOpenCLWorkItemBuiltinsPass.cpp +++ b/lib/DefineOpenCLWorkItemBuiltinsPass.cpp @@ -79,6 +79,7 @@ Function *getFunctionIfNeeded(Module &M, StringRef Name, if (D) { // function must be inserted for use by dependent F = cast(M.getOrInsertFunction(Name, FType).getCallee()); + F->setIsNewDbgInfoFormat(true); F->setCallingConv(CallingConv::SPIR_FUNC); return F; } diff --git a/lib/HideConstantLoadsPass.cpp b/lib/HideConstantLoadsPass.cpp index f711075c3..03c148675 100644 --- a/lib/HideConstantLoadsPass.cpp +++ b/lib/HideConstantLoadsPass.cpp @@ -82,6 +82,7 @@ PreservedAnalyses clspv::HideConstantLoadsPass::run(Module &M, FunctionType *fnTy = FunctionType::get(loadedTy, {loadedTy}, false); auto fn_constant = M.getOrInsertFunction(fn_name, fnTy); fn = cast(fn_constant.getCallee()); + fn->setIsNewDbgInfoFormat(true); fn->setOnlyReadsMemory(); } diff --git a/lib/LongVectorLoweringPass.cpp b/lib/LongVectorLoweringPass.cpp index a24a2a602..f792ea06e 100644 --- a/lib/LongVectorLoweringPass.cpp +++ b/lib/LongVectorLoweringPass.cpp @@ -306,6 +306,7 @@ Function *getBIFScalarVersion(Function &Builtin) { if (ScalarFn == nullptr) { ScalarFn = Function::Create(FunctionTy, Builtin.getLinkage(), ScalarName); + ScalarFn->setIsNewDbgInfoFormat(true); ScalarFn->setCallingConv(Builtin.getCallingConv()); ScalarFn->copyAttributesFrom(&Builtin); @@ -503,6 +504,7 @@ Function *createFunctionWithMappedTypes(Function &F, assert(!F.isVarArg() && "varargs not supported"); auto *Wrapper = Function::Create(EquivalentFunctionTy, F.getLinkage()); + Wrapper->setIsNewDbgInfoFormat(true); Wrapper->takeName(&F); Wrapper->setCallingConv(F.getCallingConv()); Wrapper->copyAttributesFrom(&F); @@ -584,6 +586,7 @@ Value *convertOpAnyOrAllOperation(CallInst &VectorCall, FunctionType::get(VectorCall.getFunctionType()->getReturnType(), ParamTys, false), OpAnyOrAllInitialFunction->getLinkage(), OpAnyOrAllFunctionName); + OpAnyOrAllFunction->setIsNewDbgInfoFormat(true); OpAnyOrAllFunction->setCallingConv( OpAnyOrAllInitialFunction->getCallingConv()); diff --git a/lib/LowerAddrSpaceCastPass.cpp b/lib/LowerAddrSpaceCastPass.cpp index 4af6b1e0b..efe7d78bf 100644 --- a/lib/LowerAddrSpaceCastPass.cpp +++ b/lib/LowerAddrSpaceCastPass.cpp @@ -264,6 +264,7 @@ llvm::Value *clspv::LowerAddrSpaceCastPass::visitCallInst(llvm::CallInst &I) { return eqF; eqF = Function::Create(FunctionTy, F->getLinkage(), Name); + eqF->setIsNewDbgInfoFormat(true); FunctionMap[F] = eqF; M->getFunctionList().push_front(eqF); diff --git a/lib/MultiVersionUBOFunctionsPass.cpp b/lib/MultiVersionUBOFunctionsPass.cpp index 5311a2cc1..dd87234b0 100644 --- a/lib/MultiVersionUBOFunctionsPass.cpp +++ b/lib/MultiVersionUBOFunctionsPass.cpp @@ -240,6 +240,7 @@ Function *clspv::MultiVersionUBOFunctionsPass::AddExtraArguments( auto pair = module->getOrInsertFunction(fn->getName(), new_type, fn->getAttributes()); Function *new_function = cast(pair.getCallee()); + new_function->setIsNewDbgInfoFormat(true); new_function->setCallingConv(fn->getCallingConv()); new_function->copyMetadata(fn, 0); diff --git a/lib/PhysicalPointerArgsPass.cpp b/lib/PhysicalPointerArgsPass.cpp index 252aa9feb..caaa0cde9 100644 --- a/lib/PhysicalPointerArgsPass.cpp +++ b/lib/PhysicalPointerArgsPass.cpp @@ -72,6 +72,7 @@ PreservedAnalyses clspv::PhysicalPointerArgsPass::run(Module &M, FunctionType::get(F.getReturnType(), NewParamTypes, false); auto NewFunc = Function::Create(NewFuncTy, F.getLinkage()); + NewFunc->setIsNewDbgInfoFormat(true); // The new function adopts the real name so that linkage to the outside // world remains the same. NewFunc->setName(F.getName()); diff --git a/lib/PrintfPass.cpp b/lib/PrintfPass.cpp index 8d77a5a66..b927dcca0 100644 --- a/lib/PrintfPass.cpp +++ b/lib/PrintfPass.cpp @@ -86,6 +86,7 @@ void clspv::PrintfPass::DefinePrintfInstance(Module &M, CallInst *CI, auto FuncCallee = M.getOrInsertFunction(FuncName, FuncTy); auto *Func = dyn_cast(FuncCallee.getCallee()); assert(Func); + Func->setIsNewDbgInfoFormat(true); auto *NewCI = CallInst::Create(Func, NewArgs, "", CI); CI->replaceAllUsesWith(NewCI); diff --git a/lib/RemoveUnusedArguments.cpp b/lib/RemoveUnusedArguments.cpp index 82f22f367..4555f0c0a 100644 --- a/lib/RemoveUnusedArguments.cpp +++ b/lib/RemoveUnusedArguments.cpp @@ -94,6 +94,7 @@ void clspv::RemoveUnusedArguments::removeUnusedParameters( auto inserted = M.getOrInsertFunction(f->getName(), new_type, fn_attrs).getCallee(); Function *new_function = cast(inserted); + new_function->setIsNewDbgInfoFormat(true); new_function->setCallingConv(f->getCallingConv()); new_function->copyMetadata(f, 0); diff --git a/lib/ReplaceLLVMIntrinsicsPass.cpp b/lib/ReplaceLLVMIntrinsicsPass.cpp index 9890cc66a..58ea74206 100644 --- a/lib/ReplaceLLVMIntrinsicsPass.cpp +++ b/lib/ReplaceLLVMIntrinsicsPass.cpp @@ -93,6 +93,8 @@ bool clspv::ReplaceLLVMIntrinsicsPass::runOnFunction(Function &F) { return replaceAddSubSat(F, true, false); case Intrinsic::sadd_sat: return replaceAddSubSat(F, true, true); + case Intrinsic::is_fpclass: + return replaceIsFpClass(F); // SPIR-V OpAssumeTrueKHR requires ExpectAssumeKHR capability in SPV_KHR_expect_assume extension. // Vulkan doesn't support that, so remove assume declaration. case Intrinsic::assume: @@ -130,6 +132,22 @@ bool clspv::ReplaceLLVMIntrinsicsPass::replaceCallsWithValue( return !ToRemove.empty(); } +bool clspv::ReplaceLLVMIntrinsicsPass::replaceIsFpClass(Function &F) { + return replaceCallsWithValue(F, [](CallInst *call) { + auto mask = cast(call->getArgOperand(1))->getZExtValue(); + Value *result = nullptr; + IRBuilder<> builder(call); + // TODO(#1307): handle other codes + if (mask & 0x40) { + return builder.CreateFCmpOEQ( + call->getArgOperand(0), + Constant::getNullValue(call->getArgOperand(0)->getType())); + } + assert(false); + return result; + }); +} + bool clspv::ReplaceLLVMIntrinsicsPass::replaceBswap(Function &F) { return replaceCallsWithValue(F, [](CallInst *call) { Type *Ty = call->getType(); diff --git a/lib/ReplaceLLVMIntrinsicsPass.h b/lib/ReplaceLLVMIntrinsicsPass.h index 3c558a8f0..95f3725eb 100644 --- a/lib/ReplaceLLVMIntrinsicsPass.h +++ b/lib/ReplaceLLVMIntrinsicsPass.h @@ -35,6 +35,7 @@ struct ReplaceLLVMIntrinsicsPass bool replaceCountZeroes(llvm::Function &F, bool leading); bool replaceCopysign(llvm::Function &F); bool replaceAddSubSat(llvm::Function &F, bool is_signed, bool is_add); + bool replaceIsFpClass(llvm::Function &F); bool replaceCallsWithValue( llvm::Function &F, diff --git a/lib/RewriteInsertsPass.cpp b/lib/RewriteInsertsPass.cpp index 1c2882f3e..4df883c8c 100644 --- a/lib/RewriteInsertsPass.cpp +++ b/lib/RewriteInsertsPass.cpp @@ -214,6 +214,7 @@ clspv::RewriteInsertsPass::GetConstructFunction(Module &M, FunctionType *fnTy = FunctionType::get(constructed_type, elements, false); auto fn_constant = M.getOrInsertFunction(fn_name, fnTy); fn = cast(fn_constant.getCallee()); + fn->setIsNewDbgInfoFormat(true); fn->setOnlyReadsMemory(); } return fn; diff --git a/lib/SpecializeImageTypes.cpp b/lib/SpecializeImageTypes.cpp index eb360727f..c15e6de4b 100644 --- a/lib/SpecializeImageTypes.cpp +++ b/lib/SpecializeImageTypes.cpp @@ -368,6 +368,7 @@ void SpecializeImageTypesPass::RewriteFunction(Function *f) { auto callee = module->getOrInsertFunction(f->getName(), func_type, f->getAttributes()); auto new_func = cast(callee.getCallee()); + new_func->setIsNewDbgInfoFormat(true); new_func->setCallingConv(f->getCallingConv()); new_func->copyMetadata(f, 0); diff --git a/lib/ThreeElementVectorLoweringPass.cpp b/lib/ThreeElementVectorLoweringPass.cpp index 3f4c35f36..0053c9949 100644 --- a/lib/ThreeElementVectorLoweringPass.cpp +++ b/lib/ThreeElementVectorLoweringPass.cpp @@ -158,6 +158,7 @@ Function *createFunctionWithMappedTypes(Function &F, assert(!F.isVarArg() && "varargs not supported"); auto *Wrapper = Function::Create(EquivalentFunctionTy, F.getLinkage()); + Wrapper->setIsNewDbgInfoFormat(F.IsNewDbgInfoFormat); Wrapper->takeName(&F); Wrapper->setCallingConv(F.getCallingConv()); Wrapper->copyAttributesFrom(&F); @@ -1102,6 +1103,7 @@ Value *clspv::ThreeElementVectorLoweringPass::convertSIMDBuiltinCall( Function *Fct = Function::Create(FunctionType::get(EquivalentReturnTy, ParamTys, false), InitialFunction->getLinkage(), FunctionName); + Fct->setIsNewDbgInfoFormat(true); Fct->setCallingConv(InitialFunction->getCallingConv()); Fct->copyAttributesFrom(InitialFunction); diff --git a/lib/UBOTypeTransformPass.cpp b/lib/UBOTypeTransformPass.cpp index e28798cbf..00685fc0c 100644 --- a/lib/UBOTypeTransformPass.cpp +++ b/lib/UBOTypeTransformPass.cpp @@ -278,6 +278,7 @@ bool clspv::UBOTypeTransformPass::RemapFunctions( auto inserted = M.getOrInsertFunction(func->getName(), replacement_type, func->getAttributes()); Function *replacement = cast(inserted.getCallee()); + replacement->setIsNewDbgInfoFormat(true); function_replacements_[func] = replacement; replacement->setCallingConv(func->getCallingConv()); replacement->copyMetadata(func, 0); diff --git a/lib/UndoByvalPass.cpp b/lib/UndoByvalPass.cpp index a6c77df86..fc4dbee8e 100644 --- a/lib/UndoByvalPass.cpp +++ b/lib/UndoByvalPass.cpp @@ -65,6 +65,7 @@ PreservedAnalyses clspv::UndoByvalPass::run(Module &M, // Create new function. Function *NewFunc = Function::Create(NewFuncTy, F->getLinkage()); + NewFunc->setIsNewDbgInfoFormat(true); NewFunc->takeName(F); // Insert the function just after the original to preserve the ordering of diff --git a/lib/UndoSRetPass.cpp b/lib/UndoSRetPass.cpp index 5367d22ea..56a093b6c 100644 --- a/lib/UndoSRetPass.cpp +++ b/lib/UndoSRetPass.cpp @@ -74,6 +74,7 @@ PreservedAnalyses clspv::UndoSRetPass::run(Module &M, ModuleAnalysisManager &) { // Create new function. Function *NewFunc = Function::Create(NewFuncTy, F->getLinkage()); + NewFunc->setIsNewDbgInfoFormat(true); NewFunc->takeName(F); // Insert the function just after the original to preserve the ordering diff --git a/lib/WrapKernelPass.cpp b/lib/WrapKernelPass.cpp index b72e3f82f..116f610f6 100644 --- a/lib/WrapKernelPass.cpp +++ b/lib/WrapKernelPass.cpp @@ -20,6 +20,7 @@ void clspv::WrapKernelPass::runOnFunction(Module &M, llvm::Function *F) { auto *NewFuncTy = FunctionType::get(F->getReturnType(), NewParamTypes, false); auto NewFunc = Function::Create(NewFuncTy, F->getLinkage()); + NewFunc->setIsNewDbgInfoFormat(true); NewFunc->setName(F->getName().str()); F->setName(F->getName().str() + ".inner"); NewFunc->setCallingConv(F->getCallingConv()); diff --git a/test/debug-information-control-flow.cl b/test/debug-information-control-flow.cl index 8ca226885..bc348208b 100644 --- a/test/debug-information-control-flow.cl +++ b/test/debug-information-control-flow.cl @@ -13,7 +13,6 @@ void kernel foo(global uint *dst, global uint *srcA, global uint *srcB) { // CHECK: OpLine [[filename:%[^ ]+]] 7 0 // CHECK-NEXT: OpLoad -// CHECK-NEXT: OpLine [[filename]] 0 0 // CHECK-NEXT: OpNoLine // CHECK-NEXT: OpAccessChain // CHECK-NEXT: OpLine [[filename]] 8 0 diff --git a/test/debug-information.cl b/test/debug-information.cl index 1ce04158c..04391732a 100644 --- a/test/debug-information.cl +++ b/test/debug-information.cl @@ -10,7 +10,6 @@ void kernel foo(global uint *dst, global uint *src) { // CHECK: OpLine [[filename:%[^ ]+]] 7 0 // CHECK-NEXT: OpLoad -// CHECK-NEXT: OpLine [[filename]] 0 0 // CHECK-NEXT: OpNoLine // CHECK-NEXT: OpAccessChain // CHECK-NEXT: OpLine [[filename]] 8 0