[llvm] 392bd34 - [WebAssembly] use poison instead of undef as placeholder for missing args [NFC]

Nuno Lopes via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 28 04:11:56 PST 2024


Author: Nuno Lopes
Date: 2024-11-28T12:11:51Z
New Revision: 392bd3404b98c2be74e4e94d2019dffaa85919eb

URL: https://github.com/llvm/llvm-project/commit/392bd3404b98c2be74e4e94d2019dffaa85919eb
DIFF: https://github.com/llvm/llvm-project/commit/392bd3404b98c2be74e4e94d2019dffaa85919eb.diff

LOG: [WebAssembly] use poison instead of undef as placeholder for missing args [NFC]

Added: 
    

Modified: 
    llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
index 7c3e8d18ad276b..4fe1df0ab3e42c 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
@@ -86,9 +86,9 @@ static void findUses(Value *V, Function &F,
 // Create a wrapper function with type Ty that calls F (which may have a
 // 
diff erent type). Attempt to support common bitcasted function idioms:
 //  - Call with more arguments than needed: arguments are dropped
-//  - Call with fewer arguments than needed: arguments are filled in with undef
+//  - Call with fewer arguments than needed: arguments are filled in with poison
 //  - Return value is not needed: drop it
-//  - Return value needed but not present: supply an undef
+//  - Return value needed but not present: supply a poison value
 //
 // If the all the argument types of trivially castable to one another (i.e.
 // I32 vs pointer type) then we don't create a wrapper at all (return nullptr
@@ -161,7 +161,7 @@ static Function *createWrapper(Function *F, FunctionType *Ty) {
 
   if (WrapperNeeded && !TypeMismatch) {
     for (; PI != PE; ++PI)
-      Args.push_back(UndefValue::get(*PI));
+      Args.push_back(PoisonValue::get(*PI));
     if (F->isVarArg())
       for (; AI != AE; ++AI)
         Args.push_back(&*AI);
@@ -175,7 +175,7 @@ static Function *createWrapper(Function *F, FunctionType *Ty) {
       ReturnInst::Create(M->getContext(), BB);
     } else if (ExpectedRtnType->isVoidTy()) {
       LLVM_DEBUG(dbgs() << "Creating dummy return: " << *RtnType << "\n");
-      ReturnInst::Create(M->getContext(), UndefValue::get(RtnType), BB);
+      ReturnInst::Create(M->getContext(), PoisonValue::get(RtnType), BB);
     } else if (RtnType == ExpectedRtnType) {
       ReturnInst::Create(M->getContext(), Call, BB);
     } else if (CastInst::isBitOrNoopPointerCastable(ExpectedRtnType, RtnType,
@@ -255,8 +255,8 @@ bool FixFunctionBitcasts::runOnModule(Module &M) {
       if (shouldFixMainFunction(F.getFunctionType(), MainTy)) {
         LLVM_DEBUG(dbgs() << "Found `main` function with incorrect type: "
                           << *F.getFunctionType() << "\n");
-        Value *Args[] = {UndefValue::get(MainArgTys[0]),
-                         UndefValue::get(MainArgTys[1])};
+        Value *Args[] = {PoisonValue::get(MainArgTys[0]),
+                         PoisonValue::get(MainArgTys[1])};
         CallMain = CallInst::Create(MainTy, Main, Args, "call_main");
         Uses.push_back(std::make_pair(CallMain, &F));
       }


        


More information about the llvm-commits mailing list