@@ -139,8 +139,12 @@ bool is_load_uncacheable(
139139
140140 // Find the underlying object for the pointer operand of the load instruction.
141141 auto obj =
142+ #if LLVM_VERSION_MAJOR >= 12
143+ getUnderlyingObject (li.getPointerOperand (), 100 );
144+ #else
142145 GetUnderlyingObject (li.getPointerOperand (),
143146 gutils->oldFunc ->getParent ()->getDataLayout (), 100 );
147+ #endif
144148
145149 bool can_modref = is_value_mustcache_from_origin (
146150 obj, AA, gutils, TLI, unnecessaryInstructions, uncacheable_args);
@@ -228,9 +232,14 @@ std::map<Argument *, bool> compute_uncacheable_args_for_one_callsite(
228232
229233 // If the UnderlyingObject is from one of this function's arguments, then we
230234 // need to propagate the volatility.
235+ #if LLVM_VERSION_MAJOR >= 12
236+ Value *obj = getUnderlyingObject (
237+ callsite_op->getArgOperand (i), 100 );
238+ #else
231239 Value *obj = GetUnderlyingObject (
232240 callsite_op->getArgOperand (i),
233241 callsite_op->getParent ()->getModule ()->getDataLayout (), 100 );
242+ #endif
234243
235244 bool init_safe = !is_value_mustcache_from_origin (
236245 obj, AA, gutils, TLI, unnecessaryInstructions, parent_uncacheable_args);
@@ -367,9 +376,14 @@ void calculateUnusedValuesInFunction(Function& func, llvm::SmallPtrSetImpl<const
367376 if (auto si = dyn_cast<StoreInst>(inst)) {
368377 if (isa<UndefValue>(si->getValueOperand ()))
369378 return false ;
379+ #if LLVM_VERSION_MAJOR >= 12
380+ auto at = getUnderlyingObject (
381+ si->getPointerOperand (), 100 );
382+ #else
370383 auto at = GetUnderlyingObject (
371384 si->getPointerOperand (),
372385 gutils->oldFunc ->getParent ()->getDataLayout (), 100 );
386+ #endif
373387 if (auto arg = dyn_cast<Argument>(at)) {
374388 if (constant_args[arg->getArgNo ()] == DIFFE_TYPE::DUP_NONEED) {
375389 return false ;
@@ -378,9 +392,14 @@ void calculateUnusedValuesInFunction(Function& func, llvm::SmallPtrSetImpl<const
378392 }
379393
380394 if (auto mti = dyn_cast<MemTransferInst>(inst)) {
395+ #if LLVM_VERSION_MAJOR >= 12
396+ auto at = getUnderlyingObject (
397+ mti->getArgOperand (1 ), 100 );
398+ #else
381399 auto at = GetUnderlyingObject (
382400 mti->getArgOperand (1 ),
383401 gutils->oldFunc ->getParent ()->getDataLayout (), 100 );
402+ #endif
384403 if (auto arg = dyn_cast<Argument>(at)) {
385404 if (constant_args[arg->getArgNo ()] == DIFFE_TYPE::DUP_NONEED) {
386405 return false ;
@@ -426,9 +445,14 @@ void calculateUnusedStoresInFunction(Function& func, llvm::SmallPtrSetImpl<const
426445 }
427446
428447 if (auto mti = dyn_cast<MemTransferInst>(inst)) {
448+ #if LLVM_VERSION_MAJOR >= 12
449+ auto at = getUnderlyingObject (
450+ mti->getArgOperand (1 ), 100 );
451+ #else
429452 auto at = GetUnderlyingObject (
430453 mti->getArgOperand (1 ),
431454 func.getParent ()->getDataLayout (), 100 );
455+ #endif
432456 if (auto ai = dyn_cast<AllocaInst>(at)) {
433457 bool foundStore = false ;
434458 allInstructionsBetween (
0 commit comments