Issue |
117724
|
Summary |
SimplfyCFG removes needed path of computed goto
|
Labels |
new issue
|
Assignees |
|
Reporter |
FlameTop
|
We have determined a case where required code in a computed goto flow is removed incorrectly. The included source has been cut-down from a more complex example and appears to be the simplest we can create to reproduce the fault. In the code the [0]th part of the computed goto is removed and replaced by the [2]nd path of the goto (can be determined by the the constant -0XDEADBEEF being absent from the assembly output).
It appears the commit
@
> commit fc6bdb8549842613da51b9d570b29e27cc709f69
Author: XChy <xxs_...@outlook.com>
Date: Sat Oct 28 17:10:20 2023 +0800
[SimplifyCFG] Reland transform for redirecting phis between unmergeable BB and SuccBB (#68473)
Reland #67275 with #68953 resolved.
introduced this regression.
Small.CPP: '-S -O2' will reproduce.
```
#typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef short int int16_t;
typedef unsigned int uint32_t;
typedef int int32_t;
typedef unsigned long long uint64_t;
using u8 = uint8_t;
using s16 = int16_t;
using u16 = uint16_t;
using s32 = int32_t;
using u32 = uint32_t;
union u128 {
struct
{
uint32_t w0, w1;
uint32_t w2, w3;
};
struct
{
uint64_t d0;
uint64_t d1;
};
};
namespace IDX{
enum _enum_t : u8
{
x0 = 0,
x1, x2,
x3, x4, x5,
Invalid,
};
}
template< typename T >
union eState_t
{
struct
{
T x0, x1, x2,
x3, x4, x5;
};
T m_r[IDX::Invalid];
};
using Pack128 = u128;
using eState128 = eState_t<Pack128>;
struct State
{
eState128 sdta;
};
void qaz(uint8_t *mem, State &__restrict data){
uint32_t switchval = ~0;
data.sdta.m_r[(IDX::x5)].d0 = data.sdta.m_r[(IDX::x3)].d0;
switchval = data.sdta.m_r[(IDX::x2)].d0;
static constexpr void *switchdispatch[] = {
&&L10,
&&L20,
&&L30,
&&L40,
};
goto *switchdispatch[switchval];
return;
L10:
data.sdta.m_r[(IDX::x3)].d0 = 0xDEADBEEF;
goto L200;
L20:
if (auto reason = (data.sdta.m_r[(IDX::x1)].d0) == (data.sdta.m_r[(IDX::x0)].d0); (data.sdta.m_r[(IDX::x1)].d0 = (0x005b << 16)), reason) { goto L100; };
if (auto reason = (0 == 0); (data.sdta.m_r[(IDX::x3)].d0 = (int32_t((data.sdta.m_r[(IDX::x1)].w0) + 0x5d00))), reason) { goto L200; };
L30:
data.sdta.m_r[(IDX::x1)].d0 = (0x005b << 16) ;
if (auto reason = (0 == 0); (data.sdta.m_r[(IDX::x3)].d0 = (int32_t((data.sdta.m_r[(IDX::x1)].d0) + 0x5d40))), reason) { goto L200; };
L40:
if(auto reason = ((data.sdta.m_r[(IDX::x1)].d0) != ( 0 )); reason) { (data.sdta.m_r[(IDX::x3)].d0 = (s32)((s32 &)mem[(u32)(((IDX::x5)) + (0x398))])); goto L200; };
L100:
data.sdta.m_r[(IDX::x1)].d0 = (0x005b << 16);
data.sdta.m_r[(IDX::x3)].d0 = data.sdta.m_r[(IDX::x1)].w0 + 0x5ce0;
L200:
if(auto reason = ((data.sdta.m_r[(IDX::x3)].d0) == ( 0 )); data.sdta.m_r[(IDX::x1)].d0 = ((data.sdta.m_r[(IDX::x3)].d0) + 0), reason) { goto L300; };
data.sdta.m_r[(IDX::x2)].d0 = (uint32_t)(uint32_t((u16)((s16 &)mem[(u32)(( data.sdta.m_r[(IDX::x3)].d0) + (0xa))])));
L300:
return;
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs