[llvm] [WebAssembly] Represent trap instructions as `poison` (PR #134553)

Pedro Lobo via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 6 10:35:07 PDT 2025


https://github.com/pedroclobo created https://github.com/llvm/llvm-project/pull/134553

The WebAssemblyLowerRefTypesIntPtrConv pass currently uses `undef` to represent trap instructions. These can instead be represented by the `poison` value.

>From fcb40d1ac2a5c92f3ac2695f571d6dc4ba2b0bc1 Mon Sep 17 00:00:00 2001
From: Pedro Lobo <pedro.lobo at tecnico.ulisboa.pt>
Date: Sun, 6 Apr 2025 18:31:29 +0100
Subject: [PATCH] [WebAssembly] Represent trap instructions as `poison`

The WebAssemblyLowerRefTypesIntPtrConv pass currently uses `undef` to
represent trap instructions. These can instead be represented by the
`poison` value.
---
 .../Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp  | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
index c61aa5eff4a70..be500de67e320 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
@@ -68,8 +68,7 @@ bool WebAssemblyLowerRefTypesIntPtrConv::runOnFunction(Function &F) {
         !(ITP && WebAssembly::isWebAssemblyReferenceType(ITP->getDestTy())))
       continue;
 
-    UndefValue *U = UndefValue::get(I->getType());
-    I->replaceAllUsesWith(U);
+    I->replaceAllUsesWith(PoisonValue::get(I->getType()));
 
     Function *TrapIntrin =
         Intrinsic::getOrInsertDeclaration(F.getParent(), Intrinsic::debugtrap);



More information about the llvm-commits mailing list