如何用值替换指令?

时间:2019-01-31 07:48:46

标签: c++ llvm llvm-clang

我正在用C ++编写。说我有

my_idx_ptr.reset(new int(a)); // create new int onto heap

我想替换

define void @ha(i32) #0 {
  %2 = add nsw i32 %0, 1
  %3 = sub nsw i32 %2, 1
  ret void
}

使用

%3 = sub nsw i32 %2, 1

我尝试过

%3 = %0

和     ReplaceInstWithValue(inst_iter-> getParent()-> getInstList(),inst_iter,val);

可以理解的是,第一个不起作用,因为它没有其他参考;对于第二个,它只是删除指令。我也找不到合适的函数(并且我还没有包含IRBuilder)。感谢您的任何帮助,谢谢!

1 个答案:

答案 0 :(得分:0)

您想要的功能是replaceAllUsesWith()。找到您的$search = DB::table('listings') ->selectRaw('listings.*, reservations.id AS reservation_id, reservations.status AS res_status, reservations.start_date, reservations.end_date, AVG(reservations.rating) as rating') ->leftJoin('reservations', 'reservations.listing_id', 'listings.id') ->whereRaw("(CAST(? AS date) NOT BETWEEN reservations.start_date AND reservations.end_date) or reservations.status = 'Cancel'", [$search_date]) ->where('listings.city_id', '=', $city_id) ->where('listings.persons', '>=', $guests) ->where('listings.listing_type_id', '=', $type) ->groupBy('listings.id') ->orderBy('reservations.rating', 'DESC') ->paginate(10); 并将其替换为该指令的所有用法。完成。