[Lldb-commits] [clang] [lldb] [clang][RecordLayoutBuilder] Be stricter about inferring packed-ness in ExternalLayouts (PR #97443)

2024-07-07 Thread Eli Friedman via lldb-commits

https://github.com/efriedma-quic commented:

If I'm understanding correctly, the way this currently works is that you do 
normal field layout, then if you discover that the actual offset of a field is 
less than the offset normal field layout would produce, you assume the struct 
is packed.  This misses cases where a struct is packed, but the packing doesn't 
affect the offset of any of the fields.  But as you note, this can't be fixed 
without adjusting the overall architecture.

There's an issue with the current implementation: it skips fields which 
actually are packed, I think.  Consider the following:

```
struct Empty {};
struct __attribute((packed)) S {
  [[no_unique_address]] Empty a,b,c,d;
  char x;
  int y;
};
S s;
```

In this case, the field "y" is both overlapping, and at a packed offset.  
Really, you don't want to check for overlap; you want to ignore empty fields.  
(Non-empty fields can't overlap.)

https://github.com/llvm/llvm-project/pull/97443
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)

2024-07-07 Thread Chris B via lldb-commits

https://github.com/llvm-beanz commented:

Few comments, but mostly I really like this direction!

https://github.com/llvm/llvm-project/pull/97362
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)

2024-07-07 Thread Chris B via lldb-commits

https://github.com/llvm-beanz edited 
https://github.com/llvm/llvm-project/pull/97362
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)

2024-07-07 Thread Chris B via lldb-commits


@@ -8001,6 +8001,12 @@ NamedDecl *Sema::ActOnVariableDeclarator(
 }
   }
 
+  if (getLangOpts().HLSL) {
+if (R->isHLSLSpecificType() && !NewVD->isImplicit()) {
+  Diag(D.getBeginLoc(), diag::err_hlsl_intangible_type_cannot_be_declared);

llvm-beanz wrote:

Is the intent here to basically say that you can't create these types unless 
the declaration is implicit? I know we don't expose handle types in DXC, but do 
we really need to force these to be invalid in source?

https://github.com/llvm/llvm-project/pull/97362
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)

2024-07-07 Thread Chris B via lldb-commits


@@ -3428,6 +3428,12 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << 'u' << type_name.size() << type_name;   
\
 break;
 #include "clang/Basic/AMDGPUTypes.def"
+#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId)
\
+  case BuiltinType::Id:
\
+type_name = #Name; 
\
+Out << type_name.size() << type_name;  
\

llvm-beanz wrote:

```suggestion
Out << 'u' << type_name.size() << type_name;   \
```

The `u` is significant here because it denotes a vendor-specific builtin type 
(see: https://itanium-cxx-abi.github.io/cxx-abi/abi-mangling.html).

https://github.com/llvm/llvm-project/pull/97362
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)

2024-07-07 Thread Chris B via lldb-commits


@@ -12335,6 +12335,10 @@ def warn_hlsl_availability_unavailable :
   Warning,
   InGroup, DefaultError;
 
+def err_hlsl_intangible_type_cannot_be_declared : Error<
+"HLSL intangible type cannot be declared here">;
+def err_hlsl_intangible_type_as_function_arg_or_return : Error<
+"HLSL intangible type cannot be used as function %select{argument|return 
value}0">;

llvm-beanz wrote:

I don't think this is correct. We do allow resources as argument and return 
types.

https://github.com/llvm/llvm-project/pull/97362
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)

2024-07-07 Thread Chris B via lldb-commits


@@ -0,0 +1,33 @@
+//===-- HLSLIntangibleTypes.def - HLSL standard intangible types *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines HLSL standard intangible types. These are implementation-
+// defined types such as handle types that have no defined object 
+// representation or value representation and their size is unknown at compile
+// time.
+//
+// The macro is:
+//
+//HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId)
+//
+// where:
+//
+//  - Name is the name of the builtin type.
+//
+//  - BuiltinType::Id is the enumerator defining the type.
+//
+//  - Context.SingletonId is the global singleton of this type.
+//
+// To include this file, define HLSL_INTANGIBLE_TYPE.
+// The macro will be undefined after inclusion.
+//
+//===--===//
+
+HLSL_INTANGIBLE_TYPE(__builtin_hlsl_resource_t, HLSLResource, HLSLResourceTy)

llvm-beanz wrote:

I don't know if we have any cases where a type is prefixed by `__builtin`, 
usually types are `__clang` or  `__` (e.g. `__arm`, `__amdgpu`). Maybe 
we should just do `__hlsl`?

https://github.com/llvm/llvm-project/pull/97362
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix printing of unsigned enum bitfields when they contain the max value (PR #96202)

2024-07-07 Thread Michael Buch via lldb-commits

Michael137 wrote:

FYI, the new test seems to be failing on the matrix LLDB bot that's testing 
DWARFv2:
```
==
FAIL: test_bitfield_enums_dsym (TestBitfieldEnums.TestBitfieldEnum)
--
Traceback (most recent call last):
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 1756, in test_method
return attrvalue(self)
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/test/API/commands/expression/bitfield_enums/TestBitfieldEnums.py",
 line 20, in test_bitfield_enums
self.expect_expr(
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 2512, in expect_expr
value_check.check_value(self, eval_result, str(eval_result))
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 326, in check_value
self.check_value_children(test_base, val, error_msg)
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 349, in check_value_children
expected_child.check_value(test_base, actual_child, child_error)
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 311, in check_value
test_base.assertEqual(self.expect_value, val.GetValue(), this_error_msg)
AssertionError: 'max' != '-1'
- max
+ -1
 : Checking child with index 5:
(BitfieldStruct) $0 = {
  signed_min = min
  signed_other = -1
  signed_max = max
  unsigned_min = min
  unsigned_other = 1
  unsigned_max = -1
}
Checking SBValue: (UnsignedEnum:2) unsigned_max = -1
```
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake-matrix/459/execution/node/59/log/?consoleFull

(both the dSYM and non-dSYM variants of the test are failing)

AFAICT, this seems to just be an existing bug in the DWARFv2 support that this 
test uncovered.

With my system LLDB (compiling the test with `-gdwarf-2`):
```
(lldb) v bfs
(BitfieldStruct) bfs = {
  signed_min = min
  signed_other = -1
  signed_max = max
  unsigned_min = min
  unsigned_other = 1
  unsigned_max = -1
}
```

https://github.com/llvm/llvm-project/pull/96202
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits