From ea9cffdf2902e14f52b442517eebd3a05b742e8a Mon Sep 17 00:00:00 2001 From: Julian Büning Date: Sun, 15 Sep 2019 17:14:18 +0200 Subject: LLVM 9.0: fourth parameter for @llvm.objectsize() --- lib/Module/IntrinsicCleaner.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'lib/Module') diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp index 1c30d781..144be0ce 100644 --- a/lib/Module/IntrinsicCleaner.cpp +++ b/lib/Module/IntrinsicCleaner.cpp @@ -296,7 +296,9 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) { case Intrinsic::objectsize: { // We don't know the size of an object in general so we replace // with 0 or -1 depending on the second argument to the intrinsic. -#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0) +#if LLVM_VERSION_CODE >= LLVM_VERSION(9, 0) + assert(ii->getNumArgOperands() == 4 && "wrong number of arguments"); +#elif LLVM_VERSION_CODE >= LLVM_VERSION(5, 0) assert(ii->getNumArgOperands() == 3 && "wrong number of arguments"); #else assert(ii->getNumArgOperands() == 2 && "wrong number of arguments"); @@ -311,12 +313,22 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) { #if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0) auto nullArg = ii->getArgOperand(2); - assert(nullArg && "Failed to get second argument"); + assert(nullArg && "Failed to get third argument"); auto nullArgAsInt = dyn_cast(nullArg); assert(nullArgAsInt && "Third arg is not a ConstantInt"); assert(nullArgAsInt->getBitWidth() == 1 && "Third argument is not an i1"); - /* TODO should we do something with the 3rd argument? */ + // TODO: should we do something with the 3rd argument? +#endif + +#if LLVM_VERSION_CODE >= LLVM_VERSION(9, 0) + auto dynamicArg = ii->getArgOperand(3); + assert(dynamicArg && "Failed to get fourth argument"); + auto dynamicArgAsInt = dyn_cast(dynamicArg); + assert(dynamicArgAsInt && "Fourth arg is not a ConstantInt"); + assert(dynamicArgAsInt->getBitWidth() == 1 && + "Fourth argument is not an i1"); + // TODO: should we do something with the 4th argument? #endif Value *replacement = NULL; -- cgit 1.4.1