diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h --- a/llvm/include/llvm-c/Core.h +++ b/llvm/include/llvm-c/Core.h @@ -3942,13 +3942,20 @@ */ unsigned LLVMGetNumMaskElements(LLVMValueRef ShuffleVectorInst); +/** + * \returns a constant that specifies that the result of a \c ShuffleVectorInst + * is undefined. + */ +int LLVMGetUndefMaskElem(void); + /** * Get the mask value at position Elt in the mask of a ShuffleVector - * instruction. Return LLVMUndefMaskElem if the mask value is undef at that - * position. + * instruction. + * + * \Returns the result of \c LLVMGetUndefMaskElem() if the mask value is undef + * at that position. */ int LLVMGetMaskValue(LLVMValueRef ShuffleVectorInst, unsigned Elt); -extern const int LLVMUndefMaskElem; LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst); void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread); diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -3963,9 +3963,8 @@ ShuffleVectorInst *I = cast(P); return I->getMaskValue(Elt); } -const int LLVMUndefMaskElem = - -1; // not actually accessible as ShuffleVectorInst::UndefMaskElem, so we - // hardcode it here + +int LLVMGetUndefMaskElem(void) { return ShuffleVectorInst::UndefMaskElem; } LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst) { Value *P = unwrap(AtomicInst); diff --git a/llvm/tools/llvm-c-test/echo.cpp b/llvm/tools/llvm-c-test/echo.cpp --- a/llvm/tools/llvm-c-test/echo.cpp +++ b/llvm/tools/llvm-c-test/echo.cpp @@ -809,7 +809,7 @@ unsigned NumMaskElts = LLVMGetNumMaskElements(Src); for (unsigned i = 0; i < NumMaskElts; i++) { int Val = LLVMGetMaskValue(Src, i); - if (Val == LLVMUndefMaskElem) { + if (Val == LLVMGetUndefMaskElem()) { MaskElts.push_back(LLVMGetUndef(LLVMInt64Type())); } else { MaskElts.push_back(LLVMConstInt(LLVMInt64Type(), Val, true));