[llvm] [llvm-diff] Also diff alloca's allocated type and alignment (PR #84781)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 12 05:36:40 PDT 2024


YanWQ-monad wrote:

After investigation, I found that two `struct` declarations always have different `Type` pointers, despite they have the same element.

The related code might be
https://github.com/llvm/llvm-project/blob/ffe41819e58365dfbe85a22556c0d9d284e746b9/llvm/lib/IR/Type.cpp#L513-L529
We can infer that different calls to `StructType::create` will always create different `Type*`s, which cause `llvm-diff` (of the current PR) to consider same struct as different types.

So, should we modify the code in `Type.cpp` to make it generate same pointer for structure with same element, or handle this situation in `llvm-diff` in a special way so that it won't report the differences?

---

Reproduction (`llvm-diff` of the current PR):

``` llvm
%struct = type { i8 }

define void @gep(ptr %addr) {
  %1 = getelementptr %struct, ptr %addr, i32 0
  ret void
}
```

Command: `llvm-diff a.ll a.ll`, results in
```
in function gep:
  in block %0 / %0:
    >   %1 = getelementptr %struct.0, ptr %addr, i32 0
    <   %1 = getelementptr %struct, ptr %addr, i32 0
```

https://github.com/llvm/llvm-project/pull/84781


More information about the llvm-commits mailing list