From 2e848a63ae9661e32e919c8177399ff06bf2040a Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Sat, 22 Apr 2023 20:54:03 -0400 Subject: [PATCH] cmpxchg: Compare argument types using eqTypeModuloOpaquePtrs Because `llvm-pretty` permits opaque and non-opaque pointers to coexist, it is possible for the first argument of `cmpxchg` to be an opaque pointer and the second argument to be a non-opaque pointer (or vice versa). We don't want to reject such scenarios, so we compare the types of the argument using `eqTypeModuloOpaquePtrs`, a special form of type equality that treats opaque and non-opaque pointers as being the same. See #177. This requires bumping the `llvm-pretty` submodule to bring in the corresponding changes from elliottt/llvm-pretty#110. --- llvm-pretty | 2 +- src/Data/LLVM/BitCode/IR/Function.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm-pretty b/llvm-pretty index 16bc5bd5..f32f773d 160000 --- a/llvm-pretty +++ b/llvm-pretty @@ -1 +1 @@ -Subproject commit 16bc5bd5a07d6e5d99c1c0f3a57b8eca2ecc944e +Subproject commit f32f773dbc454fb0744d3d26947c210570abfdb2 diff --git a/src/Data/LLVM/BitCode/IR/Function.hs b/src/Data/LLVM/BitCode/IR/Function.hs index 9edf7241..5be9811a 100644 --- a/src/Data/LLVM/BitCode/IR/Function.hs +++ b/src/Data/LLVM/BitCode/IR/Function.hs @@ -868,7 +868,7 @@ parseFunctionBlockEntry _ t d (fromEntry -> Just r) = case recordCode r of -- TODO: record size assertion -- Assert.recordSizeGreater r (ix'' + 5) - when (typedType val /= typedType new) $ fail $ unlines $ + when (typedType val `eqTypeModuloOpaquePtrs` typedType new) $ fail $ unlines $ [ "Mismatched value types:" , "cmp value: " ++ show (typedValue val) , "new value: " ++ show (typedValue new)