[llvm] 55fd9ae - [DirectX] Delay converting to old-style debug info (#201336)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 08:38:21 PDT 2026
Author: Harald van Dijk
Date: 2026-06-08T16:38:16+01:00
New Revision: 55fd9ae197033d3c74bd729891ab6ab904d4643a
URL: https://github.com/llvm/llvm-project/commit/55fd9ae197033d3c74bd729891ab6ab904d4643a
DIFF: https://github.com/llvm/llvm-project/commit/55fd9ae197033d3c74bd729891ab6ab904d4643a.diff
LOG: [DirectX] Delay converting to old-style debug info (#201336)
This has no impact at the moment, but upcoming work relies on debug info
still using new-style debug records after DXILPrepare.
Added:
Modified:
llvm/lib/Target/DirectX/DXILPrepare.cpp
llvm/lib/Target/DirectX/DirectX.h
llvm/lib/Target/DirectX/DirectXIRPasses/DXILDebugInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/DirectX/DXILPrepare.cpp b/llvm/lib/Target/DirectX/DXILPrepare.cpp
index 81f4d3da48362..7aafc926a5c5a 100644
--- a/llvm/lib/Target/DirectX/DXILPrepare.cpp
+++ b/llvm/lib/Target/DirectX/DXILPrepare.cpp
@@ -33,55 +33,71 @@
using namespace llvm;
using namespace llvm::dxil;
-namespace {
-
-constexpr bool isValidForDXIL(Attribute::AttrKind Attr) {
- return is_contained({Attribute::Alignment,
- Attribute::AlwaysInline,
- Attribute::Builtin,
- Attribute::ByVal,
- Attribute::InAlloca,
- Attribute::Cold,
- Attribute::Convergent,
- Attribute::InlineHint,
- Attribute::InReg,
- Attribute::JumpTable,
- Attribute::MinSize,
- Attribute::Naked,
- Attribute::Nest,
- Attribute::NoAlias,
- Attribute::NoBuiltin,
- Attribute::NoDuplicate,
- Attribute::NoImplicitFloat,
- Attribute::NoInline,
- Attribute::NonLazyBind,
- Attribute::NonNull,
- Attribute::Dereferenceable,
- Attribute::DereferenceableOrNull,
- Attribute::Memory,
- Attribute::NoRedZone,
- Attribute::NoReturn,
- Attribute::NoUnwind,
- Attribute::OptimizeForSize,
- Attribute::OptimizeNone,
- Attribute::ReadNone,
- Attribute::ReadOnly,
- Attribute::Returned,
- Attribute::ReturnsTwice,
- Attribute::SExt,
- Attribute::StackAlignment,
- Attribute::StackProtect,
- Attribute::StackProtectReq,
- Attribute::StackProtectStrong,
- Attribute::SafeStack,
- Attribute::StructRet,
- Attribute::SanitizeAddress,
- Attribute::SanitizeThread,
- Attribute::SanitizeMemory,
- Attribute::UWTable,
- Attribute::ZExt},
- Attr);
+namespace llvm {
+namespace dxil {
+const AttributeMask &getNonDXILAttributeMask() {
+ static const AttributeMask Result = [] {
+ AttributeMask DXILAttributeMask;
+ for (Attribute::AttrKind Kind : {Attribute::Alignment,
+ Attribute::AlwaysInline,
+ Attribute::Builtin,
+ Attribute::ByVal,
+ Attribute::InAlloca,
+ Attribute::Cold,
+ Attribute::Convergent,
+ Attribute::InlineHint,
+ Attribute::InReg,
+ Attribute::JumpTable,
+ Attribute::MinSize,
+ Attribute::Naked,
+ Attribute::Nest,
+ Attribute::NoAlias,
+ Attribute::NoBuiltin,
+ Attribute::NoDuplicate,
+ Attribute::NoImplicitFloat,
+ Attribute::NoInline,
+ Attribute::NonLazyBind,
+ Attribute::NonNull,
+ Attribute::Dereferenceable,
+ Attribute::DereferenceableOrNull,
+ Attribute::Memory,
+ Attribute::NoRedZone,
+ Attribute::NoReturn,
+ Attribute::NoUnwind,
+ Attribute::OptimizeForSize,
+ Attribute::OptimizeNone,
+ Attribute::ReadNone,
+ Attribute::ReadOnly,
+ Attribute::Returned,
+ Attribute::ReturnsTwice,
+ Attribute::SExt,
+ Attribute::StackAlignment,
+ Attribute::StackProtect,
+ Attribute::StackProtectReq,
+ Attribute::StackProtectStrong,
+ Attribute::SafeStack,
+ Attribute::StructRet,
+ Attribute::SanitizeAddress,
+ Attribute::SanitizeThread,
+ Attribute::SanitizeMemory,
+ Attribute::UWTable,
+ Attribute::ZExt})
+ DXILAttributeMask.addAttribute(Kind);
+ AttributeMask Result;
+ for (Attribute::AttrKind Kind = Attribute::None;
+ Kind != Attribute::EndAttrKinds;
+ Kind = Attribute::AttrKind(Kind + 1)) {
+ if (!DXILAttributeMask.contains(Kind))
+ Result.addAttribute(Kind);
+ }
+ return Result;
+ }();
+ return Result;
}
+} // namespace dxil
+} // namespace llvm
+
+namespace {
static void collectDeadStringAttrs(AttributeMask &DeadAttrs, AttributeSet &&AS,
const StringSet<> &LiveKeys,
@@ -177,15 +193,8 @@ class DXILPrepareModule : public ModulePass {
public:
bool runOnModule(Module &M) override {
- M.convertFromNewDbgValues();
-
PointerTypeMap PointerTypes = PointerTypeAnalysis::run(M);
- AttributeMask AttrMask;
- for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
- I = Attribute::AttrKind(I + 1)) {
- if (!isValidForDXIL(I))
- AttrMask.addAttribute(I);
- }
+ const AttributeMask &AttrMask = getNonDXILAttributeMask();
const dxil::ModuleMetadataInfo MetadataInfo =
getAnalysis<DXILMetadataAnalysisWrapperPass>().getModuleMetadata();
diff --git a/llvm/lib/Target/DirectX/DirectX.h b/llvm/lib/Target/DirectX/DirectX.h
index dfeb1ab12665d..3aa91ca75dd4b 100644
--- a/llvm/lib/Target/DirectX/DirectX.h
+++ b/llvm/lib/Target/DirectX/DirectX.h
@@ -12,6 +12,7 @@
#define LLVM_LIB_TARGET_DIRECTX_DIRECTX_H
namespace llvm {
+class AttributeMask;
class FunctionPass;
class ModulePass;
class PassRegistry;
@@ -126,6 +127,9 @@ void initializeDXILFinalizeLinkageLegacyPass(PassRegistry &);
/// Pass to finalize linkage of functions.
ModulePass *createDXILFinalizeLinkageLegacyPass();
+namespace dxil {
+const AttributeMask &getNonDXILAttributeMask();
+} // namespace dxil
} // namespace llvm
#endif // LLVM_LIB_TARGET_DIRECTX_DIRECTX_H
diff --git a/llvm/lib/Target/DirectX/DirectXIRPasses/DXILDebugInfo.cpp b/llvm/lib/Target/DirectX/DirectXIRPasses/DXILDebugInfo.cpp
index 0c589bc45e2fe..e8565129e8cd9 100644
--- a/llvm/lib/Target/DirectX/DirectXIRPasses/DXILDebugInfo.cpp
+++ b/llvm/lib/Target/DirectX/DirectXIRPasses/DXILDebugInfo.cpp
@@ -7,7 +7,9 @@
//===----------------------------------------------------------------------===//
#include "DXILDebugInfo.h"
+#include "DirectX.h"
#include "llvm/BinaryFormat/Dwarf.h"
+#include "llvm/IR/AttributeMask.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicsDirectX.h"
@@ -64,11 +66,19 @@ static void replaceDbgValue(Module &M, DXILDebugInfoMap &Res) {
}
DXILDebugInfoMap DXILDebugInfoPass::run(Module &M) {
+ M.convertFromNewDbgValues();
+
DXILDebugInfoMap Res;
DebugInfoFinder DIF;
DIF.processModule(M);
+ const AttributeMask &AttrMask = getNonDXILAttributeMask();
for (auto &F : M) {
+ F.removeFnAttrs(AttrMask);
+ F.removeRetAttrs(AttrMask);
+ for (unsigned ArgNo = 0; ArgNo != F.arg_size(); ++ArgNo)
+ F.removeParamAttrs(ArgNo, AttrMask);
+
for (auto &BB : F) {
for (auto &I : make_early_inc_range(reverse(BB))) {
if (auto *DL = dyn_cast<DbgLabelInst>(&I)) {
More information about the llvm-commits
mailing list