Skip to content

[WebAssembly] Change placeholder from undef to poison #131536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025

Conversation

pedroclobo
Copy link
Member

Use poison instead of undef as a placeholder for phi entries of unreachable predecessors.

Use `poison` instead of `undef` as a placeholder for phi entries of
unreachable predecessors.
@llvmbot
Copy link
Member

llvmbot commented Mar 16, 2025

@llvm/pr-subscribers-backend-webassembly

Author: Pedro Lobo (pedroclobo)

Changes

Use poison instead of undef as a placeholder for phi entries of unreachable predecessors.


Full diff: https://github.com/llvm/llvm-project/pull/131536.diff

1 Files Affected:

  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp (+2-2)
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
index 2d11019291a7a..0e79a13d4ccaa 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -1767,7 +1767,7 @@ void WebAssemblyLowerEmscriptenEHSjLj::handleLongjmpableCallsForWasmSjLj(
     I->eraseFromParent();
 
   // Add entries for new predecessors to phis in unwind destinations. We use
-  // 'undef' as a placeholder value. We should make sure the phis have a valid
+  // 'poison' as a placeholder value. We should make sure the phis have a valid
   // set of predecessors before running SSAUpdater, because SSAUpdater
   // internally can use existing phis to gather predecessor info rather than
   // scanning the actual CFG (See FindPredecessorBlocks in SSAUpdater.cpp for
@@ -1776,7 +1776,7 @@ void WebAssemblyLowerEmscriptenEHSjLj::handleLongjmpableCallsForWasmSjLj(
     for (PHINode &PN : UnwindDest->phis()) {
       for (auto *NewPred : NewPreds) {
         assert(PN.getBasicBlockIndex(NewPred) == -1);
-        PN.addIncoming(UndefValue::get(PN.getType()), NewPred);
+        PN.addIncoming(PoisonValue::get(PN.getType()), NewPred);
       }
     }
   }

@aheejin
Copy link
Member

aheejin commented Mar 16, 2025

Are there any differences in these two options in this case? I think the value is used only as a placeholder that is to be replaced later.

@pedroclobo
Copy link
Member Author

Are there any differences in these two options in this case? I think the value is used only as a placeholder that is to be replaced later.

Conceptually, as the value is later replaced, there is no difference between using poison or undef here.
Nonetheless, we should prefer poison, helping the ongoing effort to remove undef and replace it with poison.

@pedroclobo pedroclobo merged commit 8c939f5 into llvm:main Mar 17, 2025
13 checks passed
@pedroclobo pedroclobo deleted the wasm-poison branch March 17, 2025 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants