Skip to content

Commit 392bd34

Browse files
committed
[WebAssembly] use poison instead of undef as placeholder for missing args [NFC]
1 parent 5208bc3 commit 392bd34

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ static void findUses(Value *V, Function &F,
8686
// Create a wrapper function with type Ty that calls F (which may have a
8787
// different type). Attempt to support common bitcasted function idioms:
8888
// - Call with more arguments than needed: arguments are dropped
89-
// - Call with fewer arguments than needed: arguments are filled in with undef
89+
// - Call with fewer arguments than needed: arguments are filled in with poison
9090
// - Return value is not needed: drop it
91-
// - Return value needed but not present: supply an undef
91+
// - Return value needed but not present: supply a poison value
9292
//
9393
// If the all the argument types of trivially castable to one another (i.e.
9494
// 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) {
161161

162162
if (WrapperNeeded && !TypeMismatch) {
163163
for (; PI != PE; ++PI)
164-
Args.push_back(UndefValue::get(*PI));
164+
Args.push_back(PoisonValue::get(*PI));
165165
if (F->isVarArg())
166166
for (; AI != AE; ++AI)
167167
Args.push_back(&*AI);
@@ -175,7 +175,7 @@ static Function *createWrapper(Function *F, FunctionType *Ty) {
175175
ReturnInst::Create(M->getContext(), BB);
176176
} else if (ExpectedRtnType->isVoidTy()) {
177177
LLVM_DEBUG(dbgs() << "Creating dummy return: " << *RtnType << "\n");
178-
ReturnInst::Create(M->getContext(), UndefValue::get(RtnType), BB);
178+
ReturnInst::Create(M->getContext(), PoisonValue::get(RtnType), BB);
179179
} else if (RtnType == ExpectedRtnType) {
180180
ReturnInst::Create(M->getContext(), Call, BB);
181181
} else if (CastInst::isBitOrNoopPointerCastable(ExpectedRtnType, RtnType,
@@ -255,8 +255,8 @@ bool FixFunctionBitcasts::runOnModule(Module &M) {
255255
if (shouldFixMainFunction(F.getFunctionType(), MainTy)) {
256256
LLVM_DEBUG(dbgs() << "Found `main` function with incorrect type: "
257257
<< *F.getFunctionType() << "\n");
258-
Value *Args[] = {UndefValue::get(MainArgTys[0]),
259-
UndefValue::get(MainArgTys[1])};
258+
Value *Args[] = {PoisonValue::get(MainArgTys[0]),
259+
PoisonValue::get(MainArgTys[1])};
260260
CallMain = CallInst::Create(MainTy, Main, Args, "call_main");
261261
Uses.push_back(std::make_pair(CallMain, &F));
262262
}

0 commit comments

Comments
 (0)