Skip to content

Commit a937b23

Browse files
authored
Merge pull request rust-lang#166 from wasmerio/tail_ub
Yup, calling LLVMIsTailCall on a non-CallInst is UB.
2 parents c2e2808 + a2c3559 commit a937b23

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/values/instruction_value.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,14 @@ impl<'ctx> InstructionValue<'ctx> {
182182
BasicBlock::new(value)
183183
}
184184

185-
// REVIEW: See if necessary to check opcode == Call first.
186-
// Does it always return false otherwise?
187185
pub fn is_tail_call(&self) -> bool {
188-
unsafe {
189-
LLVMIsTailCall(self.as_value_ref()) == 1
186+
// LLVMIsTailCall has UB if the value is not an llvm::CallInst*.
187+
if self.get_opcode() == InstructionOpcode::Call {
188+
unsafe {
189+
LLVMIsTailCall(self.as_value_ref()) == 1
190+
}
191+
} else {
192+
false
190193
}
191194
}
192195

0 commit comments

Comments
 (0)