Skip to content

Commit e3f9344

Browse files
committed
change asmwriter
1 parent b24c6d7 commit e3f9344

File tree

4 files changed

+9
-26
lines changed

4 files changed

+9
-26
lines changed

clang/lib/CodeGen/Targets/DirectX.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ llvm::Type *DirectXTargetCodeGenInfo::getHLSLType(CodeGenModule &CGM,
4545

4646
llvm::Type *ElemType = CGM.getTypes().ConvertType(ContainedTy);
4747

48-
// target ext type parameters may not be named struct types
49-
// so we should convert any named struct types to anonymous
50-
// struct types in the parameter list
51-
llvm::Type *ConvertedElemType = ElemType;
52-
if (auto *STy = dyn_cast<llvm::StructType>(ElemType)) {
53-
if (STy->hasName())
54-
ConvertedElemType =
55-
llvm::StructType::get(Ctx, STy->elements(), /*isPacked=*/false);
56-
}
57-
5848
llvm::StringRef TypeName =
5949
ResAttrs.RawBuffer ? "dx.RawBuffer" : "dx.TypedBuffer";
6050
SmallVector<unsigned, 3> Ints = {/*IsWriteable*/ ResAttrs.ResourceClass ==
@@ -63,7 +53,7 @@ llvm::Type *DirectXTargetCodeGenInfo::getHLSLType(CodeGenModule &CGM,
6353
if (!ResAttrs.RawBuffer)
6454
Ints.push_back(/*IsSigned*/ ContainedTy->isSignedIntegerType());
6555

66-
return llvm::TargetExtType::get(Ctx, TypeName, {ConvertedElemType}, Ints);
56+
return llvm::TargetExtType::get(Ctx, TypeName, {ElemType}, Ints);
6757
}
6858
case llvm::dxil::ResourceClass::CBuffer:
6959
llvm_unreachable("dx.CBuffer handles are not implemented yet");

clang/test/AST/HLSL/StructuredBuffer-AST-2.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple dxil-unknown-shadermodel6.6-compute -S -finclude-default-header -o - %s | FileCheck %s
1+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-compute -S -finclude-default-header -o - %s | FileCheck %s
22

33
// The purpose of this test is to ensure that the target
44
// extension type associated with the structured buffer only
@@ -9,7 +9,7 @@
99
// body is emitted on the RHS because we are already in the context of a
1010
// target extension type definition (class.hlsl::StructuredBuffer)
1111

12-
// CHECK: %"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", { <4 x float> }, 0, 0), %struct.mystruct }
12+
// CHECK: %"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", %struct.mystruct, 0, 0), %struct.mystruct }
1313
// CHECK: %struct.mystruct = type { <4 x float> }
1414
// CHECK: %dx.types.Handle = type { ptr }
1515
// CHECK: %dx.types.ResBind = type { i32, i32, i32, i8 }

llvm/lib/IR/AsmWriter.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,10 @@ void TypePrinting::print(Type *Ty, raw_ostream &OS) {
649649
OS << "target(\"";
650650
printEscapedString(Ty->getTargetExtName(), OS);
651651
OS << "\"";
652-
for (Type *Inner : TETy->type_params())
653-
OS << ", " << *Inner;
652+
for (Type *Inner : TETy->type_params()) {
653+
OS << ", ";
654+
Inner->print(OS, /*IsForDebug=*/false, /*NoDetails=*/true);
655+
}
654656
for (unsigned IntParam : TETy->int_params())
655657
OS << ", " << IntParam;
656658
OS << ")";

llvm/lib/IR/Type.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -794,17 +794,8 @@ TargetExtType::TargetExtType(LLVMContext &C, StringRef Name,
794794
// Parameter storage immediately follows the class in allocation.
795795
Type **Params = reinterpret_cast<Type **>(this + 1);
796796
ContainedTys = Params;
797-
for (Type *T : Types) {
798-
// target ext type parameters may not be named struct types
799-
// so we should convert any named struct types to anonymous
800-
// struct types in the parameter list
801-
Type *ConvertedTy = T;
802-
if (auto *STy = dyn_cast<StructType>(T))
803-
assert(!STy->hasName() &&
804-
"named structs are not allowed in target extension types");
805-
806-
*Params++ = ConvertedTy;
807-
}
797+
for (Type *T : Types)
798+
*Params++ = T;
808799

809800
setSubclassData(Ints.size());
810801
unsigned *IntParamSpace = reinterpret_cast<unsigned *>(Params);

0 commit comments

Comments
 (0)