Skip to content

Commit 46d9de5

Browse files
[IPSCCP] Variable not visible at Og:
https://bugs.llvm.org/show_bug.cgi?id=51559 #50901 IPSCCP pass removes the global variable and does not create a constant expression for the initializer value. Drop support for fp128, ppc_fp128 and x86_fp80 types.
1 parent 0637263 commit 46d9de5

File tree

3 files changed

+3
-66
lines changed

3 files changed

+3
-66
lines changed

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3586,13 +3586,12 @@ DIExpression *llvm::getExpressionForConstant(DIBuilder &DIB, const Constant &C,
35863586
return createIntegerExpression(C);
35873587

35883588
auto *FP = dyn_cast<ConstantFP>(&C);
3589-
if (FP && Ty.isFloatingPointTy()) {
3589+
if (FP &&
3590+
(Ty.isBFloatTy() || Ty.isHalfTy() || Ty.isFloatTy() || Ty.isDoubleTy())) {
35903591
const APFloat &APF = FP->getValueAPF();
35913592
APInt const &API = APF.bitcastToAPInt();
35923593
if (auto Temp = API.tryZExtValue())
35933594
return DIB.createConstantValueExpression(static_cast<uint64_t>(*Temp));
3594-
else if (auto Temp = API.trySExtValue())
3595-
return DIB.createConstantValueExpression(static_cast<uint64_t>(*Temp));
35963595
return DIB.createConstantValueExpression(*API.getRawData());
35973596
}
35983597

llvm/test/Transforms/SCCP/pr50901.ll

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,6 @@
6262
; CHECK-DAG: ![[DBGB:[0-9]+]] = distinct !DIGlobalVariable(name: "g_ptr_undef"
6363
; CHECK-DAG: ![[GB:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBGB]], expr: !DIExpression())
6464

65-
; CHECK: ![[G10:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG10:[0-9]+]], expr: !DIExpression(DW_OP_constu, 17293822569102704640, DW_OP_stack_value))
66-
; CHECK-DAG: ![[DBG10]] = distinct !DIGlobalVariable(name: "g_1010", {{.*}}
67-
; CHECK: ![[G11:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG11:[0-9]+]], expr: !DIExpression(DW_OP_constu, 17293822569102704640, DW_OP_stack_value))
68-
; CHECK-DAG: ![[DBG11]] = distinct !DIGlobalVariable(name: "g_1111", {{.*}}
69-
; CHECK: ![[G12:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG12:[0-9]+]], expr: !DIExpression(DW_OP_constu, 14480694097861998592, DW_OP_stack_value))
70-
; CHECK-DAG: ![[DBG12]] = distinct !DIGlobalVariable(name: "g_1212", {{.*}}
71-
7265
@g_1 = dso_local global i32 -4, align 4, !dbg !0
7366
@g_2 = dso_local global float 0x4011C28F60000000, align 4, !dbg !8
7467
@g_3 = dso_local global i8 97, align 1, !dbg !10
@@ -78,9 +71,6 @@
7871
@g_7 = dso_local global ptr null, align 8, !dbg !23
7972
@g_8 = dso_local global half 0xH4321, align 4, !dbg !86
8073
@g_9 = dso_local global bfloat 0xR3F80, align 4, !dbg !90
81-
@g_10 = dso_local global fp128 0xLF0000000000000004000921CAC083126, align 16, !dbg !100
82-
@g_11 = dso_local global ppc_fp128 0xMF0000000000000004000921CAC083126, align 16, !dbg !105
83-
@g_12 = dso_local global x86_fp80 0xK4000C8F5C28F5C28F800, align 16, !dbg !110
8474
@_ZL4g_11 = internal global i32 -5, align 4, !dbg !25
8575
@_ZL4g_22 = internal global float 0x4016333340000000, align 4, !dbg !27
8676
@_ZL4g_33 = internal global i8 98, align 1, !dbg !29
@@ -91,9 +81,6 @@
9181
@g_float_undef = internal global float undef, align 4, !dbg !83
9282
@_ZL4g_88 = internal global half 0xH5678, align 4, !dbg !88
9383
@_ZL4g_99 = internal global bfloat 0xR5CAE, align 4, !dbg !92
94-
@_ZL4g_1010 = internal global fp128 0xLF0000000000000004000921CAC083126, align 16, !dbg !102
95-
@_ZL4g_1111 = internal global ppc_fp128 0xMF0000000000000004000921CAC083126, align 16, !dbg !107
96-
@_ZL4g_1212 = internal global x86_fp80 0xK4000C8F5C28F5C28F800, align 16, !dbg !112
9784
@g_i32_undef = internal global i32 undef, align 4, !dbg !95
9885
@g_ptr_undef = internal global ptr undef, align 8, !dbg !97
9986

@@ -125,12 +112,6 @@ entry:
125112
store i32 %9, ptr @g_1, align 4, !dbg !59
126113
%10 = load ptr, ptr @g_ptr_undef, align 8, !dbg !59
127114
store ptr %10, ptr @g_6, align 8, !dbg !59
128-
%11 = load fp128, ptr @_ZL4g_1010, align 16, !dbg !59
129-
store fp128 %11, ptr @g_10, align 16, !dbg !59
130-
%12 = load ppc_fp128, ptr @_ZL4g_1111, align 16, !dbg !59
131-
store ppc_fp128 %12, ptr @g_11, align 16, !dbg !59
132-
%13 = load x86_fp80, ptr @_ZL4g_1212, align 16, !dbg !59
133-
store x86_fp80 %13, ptr @g_12, align 16, !dbg !59
134115

135116
ret void, !dbg !59
136117
}
@@ -152,7 +133,7 @@ entry:
152133
!4 = !{!5}
153134
!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64)
154135
!6 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
155-
!7 = !{!0, !8, !10, !13, !16, !19, !23, !25, !27, !29, !31, !33, !35, !37, !83, !86, !88, !90, !92, !95, !97, !100, !102, !105, !107, !110, !112}
136+
!7 = !{!0, !8, !10, !13, !16, !19, !23, !25, !27, !29, !31, !33, !35, !37, !83, !86, !88, !90, !92, !95, !97}
156137
!8 = !DIGlobalVariableExpression(var: !9, expr: !DIExpression())
157138
!9 = distinct !DIGlobalVariable(name: "g_2", scope: !2, file: !3, line: 2, type: !6, isLocal: false, isDefinition: true)
158139
!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())
@@ -217,20 +198,3 @@ entry:
217198
!96 = distinct !DIGlobalVariable(name: "g_i32_undef", linkageName: "g_i32_undef", scope: !2, file: !3, line: 9, type: !22, isLocal: true, isDefinition: true)
218199
!97 = !DIGlobalVariableExpression(var: !98, expr: !DIExpression())
219200
!98 = distinct !DIGlobalVariable(name: "g_ptr_undef", linkageName: "g_ptr_undef", scope: !2, file: !3, line: 14, type: !21, isLocal: true, isDefinition: true)
220-
221-
!99 = !DIBasicType(name: "float", size: 128, encoding: DW_ATE_float)
222-
!100 = !DIGlobalVariableExpression(var: !101, expr: !DIExpression())
223-
!101 = distinct !DIGlobalVariable(name: "g_10", scope: !2, file: !3, line: 2, type: !99, isLocal: false, isDefinition: true)
224-
!102 = !DIGlobalVariableExpression(var: !103, expr: !DIExpression())
225-
!103 = distinct !DIGlobalVariable(name: "g_1010", linkageName: "_ZL4g_1010", scope: !2, file: !3, line: 15, type: !99, isLocal: true, isDefinition: true)
226-
227-
!105 = !DIGlobalVariableExpression(var: !106, expr: !DIExpression())
228-
!106 = distinct !DIGlobalVariable(name: "g_11", scope: !2, file: !3, line: 2, type: !99, isLocal: false, isDefinition: true)
229-
!107 = !DIGlobalVariableExpression(var: !108, expr: !DIExpression())
230-
!108 = distinct !DIGlobalVariable(name: "g_1111", linkageName: "_ZL4g_1111", scope: !2, file: !3, line: 15, type: !99, isLocal: true, isDefinition: true)
231-
232-
!109 = !DIBasicType(name: "float", size: 80, encoding: DW_ATE_float)
233-
!110 = !DIGlobalVariableExpression(var: !111, expr: !DIExpression())
234-
!111 = distinct !DIGlobalVariable(name: "g_12", scope: !2, file: !3, line: 2, type: !109, isLocal: false, isDefinition: true)
235-
!112 = !DIGlobalVariableExpression(var: !113, expr: !DIExpression())
236-
!113 = distinct !DIGlobalVariable(name: "g_1212", linkageName: "_ZL4g_1212", scope: !2, file: !3, line: 15, type: !109, isLocal: true, isDefinition: true)

llvm/unittests/Transforms/Utils/LocalTest.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,32 +1268,6 @@ TEST(Local, ExpressionForConstant) {
12681268
Expr = createExpression(ConstantExpr::getIntToPtr(K2, PtrTy), PtrTy);
12691269
EXPECT_NE(Expr, nullptr);
12701270
EXPECT_EQ(Expr->getElement(1), 5678U);
1271-
1272-
// FP128.
1273-
Type *FP128Ty = Type::getFP128Ty(Context);
1274-
Expr = createExpression(
1275-
ConstantFP::get(FP128Ty, APFloat(APFloat::IEEEquad(), APInt(128, 12345))),
1276-
FP128Ty);
1277-
EXPECT_NE(Expr, nullptr);
1278-
EXPECT_EQ(Expr->getElement(1), 12345U);
1279-
1280-
// X86_FP80.
1281-
Type *X86_FP80Ty = Type::getX86_FP80Ty(Context);
1282-
Expr = createExpression(
1283-
ConstantFP::get(X86_FP80Ty,
1284-
APFloat(APFloat::x87DoubleExtended(), APInt(80, 67890))),
1285-
X86_FP80Ty);
1286-
EXPECT_NE(Expr, nullptr);
1287-
EXPECT_EQ(Expr->getElement(1), 67890U);
1288-
1289-
// PPC_FP128.
1290-
Type *PPC_FP128Ty = Type::getPPC_FP128Ty(Context);
1291-
Expr = createExpression(
1292-
ConstantFP::get(PPC_FP128Ty,
1293-
APFloat(APFloat::PPCDoubleDouble(), APInt(80, 123890))),
1294-
PPC_FP128Ty);
1295-
EXPECT_NE(Expr, nullptr);
1296-
EXPECT_EQ(Expr->getElement(1), 123890U);
12971271
}
12981272

12991273
TEST(Local, ReplaceDPValue) {

0 commit comments

Comments
 (0)