[x32] Fix function indirect calls
[oota-llvm.git] / lib / Target / X86 / X86ISelLowering.cpp
index fa804a707e36464d61807e233a1b653bb7c84d84..c6b9ee0370db92b432e4a5fad1e5f485bde7d8bc 100644 (file)
@@ -3119,6 +3119,9 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
 
     Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy(),
                                          OpFlags);
+  } else if (Subtarget->isTarget64BitILP32() && Callee->getValueType(0) == MVT::i32) {
+    // Zero-extend the 32-bit Callee address into a 64-bit according to x32 ABI
+    Callee = DAG.getNode(ISD::ZERO_EXTEND, dl, MVT::i64, Callee);
   }
 
   // Returns a chain & a flag for retval copy to use.