aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineScheduler.cpp
diff options
context:
space:
mode:
authorVojislav Tomasevic <vojislav.tomasevic@syrmia.com>2024-01-24 18:39:36 +0100
committerGitHub <noreply@github.com>2024-01-24 09:39:36 -0800
commit2a77d92e2e942fb1c7e23b046581531ec464cce5 (patch)
tree6f5020fac404038da8da5a7b53e378c80b64e595 /llvm/lib/CodeGen/MachineScheduler.cpp
parentca654acc16c43191228eadfec8f7241dca10b0c3 (diff)
downloadllvm-2a77d92e2e942fb1c7e23b046581531ec464cce5.zip
llvm-2a77d92e2e942fb1c7e23b046581531ec464cce5.tar.gz
llvm-2a77d92e2e942fb1c7e23b046581531ec464cce5.tar.bz2
[clang] Incorrect IR involving the use of bcopy (#79298)
This patch addresses the issue regarding the call of bcopy function in a conditional expression. It is analogous to the already accepted patch which deals with the same problem, just regarding the bzero function [0]. Here is the testcase which illustrates the issue: ``` void bcopy(const void *, void *, unsigned long); void foo(void); void test_bcopy() { char dst[20]; char src[20]; int _sz = 20, len = 20; return (_sz ? ((_sz >= len) ? bcopy(src, dst, len) : foo()) : bcopy(src, dst, len)); } ``` When processing it with clang, following issue occurs: Instruction does not dominate all uses! %arraydecay2 = getelementptr inbounds [20 x i8], ptr %dst, i64 0, i64 0, !dbg !38 %cond = phi ptr [ %arraydecay2, %cond.end ], [ %arraydecay5, %cond.false3 ], !dbg !33 fatal error: error in backend: Broken module found, compilation aborted! This happens because an incorrect phi node is created. It is created because bcopy function call is lowered to the call of llvm.memmove intrinsic and function memmove returns void *. Since llvm.memmove is called in two places in the same return statement, clang creates a phi node in the final basic block for the return value and that phi node is incorrect. However, bcopy function should return void in the first place, so this phi node is unnecessary. This is what this patch addresses. An appropriate test is also added and no existing tests fail when applying this patch. Also, this crash only happens when LLVM is configured with -DLLVM_ENABLE_ASSERTIONS=On option. [0] https://reviews.llvm.org/D39746
Diffstat (limited to 'llvm/lib/CodeGen/MachineScheduler.cpp')
0 files changed, 0 insertions, 0 deletions