Skip to content

Commit 7946e9f

Browse files
committed
fix
Signed-off-by: Sidorov, Dmitry <[email protected]>
1 parent 391e344 commit 7946e9f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,7 @@ void SYCLToolChain::AddImpliedTargetArgs(const llvm::Triple &Triple,
17201720
// -foffload-fp32-prec-div JIT
17211721
Args.AddLastArg(BeArgs, options::OPT_foffload_fp32_prec_div);
17221722
// -foffload-fp32-prec-sqrt JIT
1723-
Args.AddLastArg(BeArgs, options::OPT_OPT_foffload_fp32_prec_sqrt);
1723+
Args.AddLastArg(BeArgs, options::OPT_foffload_fp32_prec_sqrt);
17241724
}
17251725
if (IsGen) {
17261726
for (auto [DeviceName, BackendArgStr] : PerDeviceArgs) {

llvm/lib/SYCLLowerIR/SYCLSqrtFDivMaxErrorCleanUp.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ SYCLSqrtFDivMaxErrorCleanUpPass::run(Module &M,
106106
// Replace @llvm.fpbuiltin.sqrt call with @llvm.sqrt. llvm-spirv will handle
107107
// it later.
108108
SmallSet<Function *, 2> DeclToRemove;
109+
SmallVector<IntrinsicInst *, 16> InstsToRemove;
109110
for (auto *Sqrt : WorkListSqrt) {
110111
DeclToRemove.insert(Sqrt->getCalledFunction());
111112
IRBuilder Builder(Sqrt);
@@ -125,8 +126,7 @@ SYCLSqrtFDivMaxErrorCleanUpPass::run(Module &M,
125126
FastMathFlags FMF = FPOp->getFastMathFlags();
126127
NewSqrt->setFastMathFlags(FMF);
127128
Sqrt->replaceAllUsesWith(NewSqrt);
128-
Sqrt->dropAllReferences();
129-
Sqrt->eraseFromParent();
129+
InstsToRemove.push_back(Sqrt);
130130
}
131131

132132
// Replace @llvm.fpbuiltin.fdiv call with fdiv.
@@ -144,8 +144,13 @@ SYCLSqrtFDivMaxErrorCleanUpPass::run(Module &M,
144144
FastMathFlags FMF = FPOp->getFastMathFlags();
145145
NewFDiv->setFastMathFlags(FMF);
146146
FDiv->replaceAllUsesWith(NewFDiv);
147-
FDiv->dropAllReferences();
148-
FDiv->eraseFromParent();
147+
InstsToRemove.push_back(FDiv);
148+
}
149+
150+
// Clear instructions.
151+
for (auto *Inst : llvm::reverse(InstsToRemove)) {
152+
Inst->dropAllReferences();
153+
Inst->eraseFromParent();
149154
}
150155

151156
// Clear old declarations.

0 commit comments

Comments
 (0)