[llvm] Fix/dxil test issue (PR #122052)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 7 22:25:46 PST 2025


https://github.com/joaosaffran created https://github.com/llvm/llvm-project/pull/122052

This PR fixes 'tools/dxil-dis/debug-info.ll' test that was broken due to this pr https://github.com/llvm/llvm-project/pull/116331 

>From 9fe38df0b1c009887204fc1ad2b65a0a131e5877 Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saffran at microsoft.com>
Date: Wed, 8 Jan 2025 06:20:16 +0000
Subject: [PATCH 1/3] Fixing issues cause by removing function metadata.

---
 llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp |  2 +-
 llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll  | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
index ad079f45c88297..ca877c0f730345 100644
--- a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
+++ b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
@@ -25,6 +25,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
+#include "llvm/IR/Verifier.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -331,7 +332,6 @@ static void translateBranchMetadata(Module &M) {
       BBTerminatorInst->setMetadata("dx.controlflow.hints", MDNode);
       BBTerminatorInst->setMetadata("hlsl.controlflow.hint", nullptr);
     }
-    F.clearMetadata();
   }
 }
 
diff --git a/llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll b/llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll
index fe66e481359bb7..6a5274429930ea 100644
--- a/llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll
+++ b/llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll
@@ -4,7 +4,7 @@
 
 
 ; CHECK: define i32 @test_branch(i32 %X)
-; CHECK-NO: hlsl.controlflow.hint
+; CHECK-NOT: hlsl.controlflow.hint
 ; CHECK: br i1 %cmp, label %if.then, label %if.else, !dx.controlflow.hints [[HINT_BRANCH:![0-9]+]]
 define i32 @test_branch(i32 %X) {
 entry:
@@ -34,7 +34,7 @@ if.end:                                           ; preds = %if.else, %if.then
 
 
 ; CHECK: define i32 @test_flatten(i32 %X)
-; CHECK-NO: hlsl.controlflow.hint
+; CHECK-NOT: hlsl.controlflow.hint
 ; CHECK: br i1 %cmp, label %if.then, label %if.else, !dx.controlflow.hints [[HINT_FLATTEN:![0-9]+]]
 define i32 @test_flatten(i32 %X) {
 entry:
@@ -64,8 +64,8 @@ if.end:                                           ; preds = %if.else, %if.then
 
 
 ; CHECK: define i32 @test_no_attr(i32 %X)
-; CHECK-NO: hlsl.controlflow.hint
-; CHECK-NO: !dx.controlflow.hints
+; CHECK-NOT: hlsl.controlflow.hint
+; CHECK-NOT: !dx.controlflow.hints
 define i32 @test_no_attr(i32 %X) {
 entry:
   %X.addr = alloca i32, align 4
@@ -91,7 +91,7 @@ if.end:                                           ; preds = %if.else, %if.then
   %3 = load i32, ptr %resp, align 4
   ret i32 %3
 }
-; CHECK-NO: hlsl.controlflow.hint
+; CHECK-NOT: hlsl.controlflow.hint
 ; CHECK: [[HINT_BRANCH]] = !{!"dx.controlflow.hints", i32 1}
 ; CHECK: [[HINT_FLATTEN]] = !{!"dx.controlflow.hints", i32 2}
 !0 = !{!"hlsl.controlflow.hint", i32 1}

>From 25d1e0dc164e577614b631fa2c4b545e3e95c5b2 Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saffran at microsoft.com>
Date: Wed, 8 Jan 2025 06:24:31 +0000
Subject: [PATCH 2/3] removing unused header

---
 llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp | 2 +-
 llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
index ca877c0f730345..03b74d4a0b2e2a 100644
--- a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
+++ b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
@@ -25,7 +25,6 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
-#include "llvm/IR/Verifier.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -331,6 +330,7 @@ static void translateBranchMetadata(Module &M) {
 
       BBTerminatorInst->setMetadata("dx.controlflow.hints", MDNode);
       BBTerminatorInst->setMetadata("hlsl.controlflow.hint", nullptr);
+
     }
   }
 }
diff --git a/llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll b/llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll
index 6a5274429930ea..81ab8cfccb2e8a 100644
--- a/llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll
+++ b/llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll
@@ -32,7 +32,7 @@ if.end:                                           ; preds = %if.else, %if.then
   ret i32 %3
 }
 
-
+;CHECK: bnabnasn
 ; CHECK: define i32 @test_flatten(i32 %X)
 ; CHECK-NOT: hlsl.controlflow.hint
 ; CHECK: br i1 %cmp, label %if.then, label %if.else, !dx.controlflow.hints [[HINT_FLATTEN:![0-9]+]]

>From dbd72c1d8cbb1baeaf191339c1edfaebdb2ce02f Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saffran at microsoft.com>
Date: Wed, 8 Jan 2025 06:25:18 +0000
Subject: [PATCH 3/3] removing testing check

---
 llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp | 1 -
 llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll  | 1 -
 2 files changed, 2 deletions(-)

diff --git a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
index 03b74d4a0b2e2a..5fd5c226eef894 100644
--- a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
+++ b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
@@ -330,7 +330,6 @@ static void translateBranchMetadata(Module &M) {
 
       BBTerminatorInst->setMetadata("dx.controlflow.hints", MDNode);
       BBTerminatorInst->setMetadata("hlsl.controlflow.hint", nullptr);
-
     }
   }
 }
diff --git a/llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll b/llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll
index 81ab8cfccb2e8a..0ae3e005489f5b 100644
--- a/llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll
+++ b/llvm/test/CodeGen/DirectX/HLSLControlFlowHint.ll
@@ -32,7 +32,6 @@ if.end:                                           ; preds = %if.else, %if.then
   ret i32 %3
 }
 
-;CHECK: bnabnasn
 ; CHECK: define i32 @test_flatten(i32 %X)
 ; CHECK-NOT: hlsl.controlflow.hint
 ; CHECK: br i1 %cmp, label %if.then, label %if.else, !dx.controlflow.hints [[HINT_FLATTEN:![0-9]+]]



More information about the llvm-commits mailing list