[llvm] [IPSCCP] Variable not visible at Og: (PR #77901)

Carlos Alberto Enciso via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 8 04:45:43 PDT 2024


================
@@ -52,13 +52,35 @@
 ; CHECK:     = !DIGlobalVariableExpression(var: ![[DBG_FLOAT_UNDEF:.+]], expr: !DIExpression())
 ; CHECK-DAG: ![[DBG_FLOAT_UNDEF]]  = distinct !DIGlobalVariable(name: "g_float_undef"
 
+; CHECK: ![[G8:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG8:[0-9]+]], expr: !DIExpression(DW_OP_constu, 22136, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG8]] = distinct !DIGlobalVariable(name: "g_88", {{.*}}
+; CHECK: ![[G9:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG9:[0-9]+]], expr: !DIExpression(DW_OP_constu, 23726, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG9]] = distinct !DIGlobalVariable(name: "g_99", {{.*}}
+
+; CHECK-DAG: ![[DBGA:[0-9]+]] = distinct !DIGlobalVariable(name: "g_i32_undef"
+; CHECK-DAG: ![[GA:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBGA]], expr: !DIExpression())
+; CHECK-DAG: ![[DBGB:[0-9]+]] = distinct !DIGlobalVariable(name: "g_ptr_undef"
+; CHECK-DAG: ![[GB:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBGB]], expr: !DIExpression())
+
+; CHECK: ![[G10:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG10:[0-9]+]], expr: !DIExpression(DW_OP_constu, 17293822569102704640, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG10]] = distinct !DIGlobalVariable(name: "g_1010", {{.*}}
+; CHECK: ![[G11:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG11:[0-9]+]], expr: !DIExpression(DW_OP_constu, 17293822569102704640, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG11]] = distinct !DIGlobalVariable(name: "g_1111", {{.*}}
+; CHECK: ![[G12:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG12:[0-9]+]], expr: !DIExpression(DW_OP_constu, 14480694097861998592, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG12]] = distinct !DIGlobalVariable(name: "g_1212", {{.*}}
----------------
CarlosAlbertoEnciso wrote:

Thanks for your detailed comment. You are correct.
In the following code:
```
  if (FP && Ty.isFloatingPointTy()) {
    const APFloat &APF = FP->getValueAPF();
    APInt const &API = APF.bitcastToAPInt();
    if (auto Temp = API.tryZExtValue())
      return DIB.createConstantValueExpression(static_cast<uint64_t>(*Temp));
    else if (auto Temp = API.trySExtValue())
      return DIB.createConstantValueExpression(static_cast<uint64_t>(*Temp));
    return DIB.createConstantValueExpression(*API.getRawData());
```
`tryZExtValue()` and `trySExtValue()` return `std::nullopt` as the `getSignificantBits()` is `>64
`
and then `getRawData()` returns just the upper 64-bits of the original value, which is the value used for the `DW_OP_constu`.


https://github.com/llvm/llvm-project/pull/77901


More information about the llvm-commits mailing list