From 6c1f7a51b9e12e143bc2660c22293172f86ea014 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 18 Sep 2018 01:47:25 +0000 Subject: [PATCH] [LLVM-C] Add support for ConstantExpr in LLVMGetNumIndices and LLVMGetIndices Summary: ConstantExpr supports getIndices, but prior to this patch LLVMGetNumIndices and LLVMGetIndices would error on them. Reviewers: whitequark Reviewed By: whitequark Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D52206 llvm-svn: 342434 --- llvm/lib/IR/Core.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 617d1c1..3a6f566 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -2632,6 +2632,8 @@ unsigned LLVMGetNumIndices(LLVMValueRef Inst) { return EV->getNumIndices(); if (auto *IV = dyn_cast(I)) return IV->getNumIndices(); + if (auto *CE = dyn_cast(I)) + return CE->getIndices().size(); llvm_unreachable( "LLVMGetNumIndices applies only to extractvalue and insertvalue!"); } @@ -2642,6 +2644,8 @@ const unsigned *LLVMGetIndices(LLVMValueRef Inst) { return EV->getIndices().data(); if (auto *IV = dyn_cast(I)) return IV->getIndices().data(); + if (auto *CE = dyn_cast(I)) + return CE->getIndices().data(); llvm_unreachable( "LLVMGetIndices applies only to extractvalue and insertvalue!"); } -- 2.7.4