[PATCH] D121898: [Verifier] Verify parameter alignment.

LuoYuanke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 18 05:32:43 PDT 2022


LuoYuanke added a comment.

In D121898#3391242 <https://reviews.llvm.org/D121898#3391242>, @skan wrote:

> Is it possible that we define a common max alignment across all layers?

After digging more in the LLVM code, I find there is MaximumAlignment (1 << 32) in Value.h (https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/Value.h#L793) and constant null pointer would be set the MaximumAlignment at https://github.com/llvm/llvm-project/blob/main/llvm/lib/IR/Value.cpp#L977. Below test case would fail with my patch which constrain parameter alignment. To fix the max size conflict between MaximumAlignment and ArgFlagsTy.MemAlign maybe just use unsigned type for MemAlign instead of bitfield? But it seems there is assert to monitor ArgFlagsTy size at https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/CodeGen/TargetCallingConv.h#L69.

So in summary, for now I have no idea how to fix it. Maybe leave the test case of my patch just crash during the lowering and remind middle-end generate the right vector size or alignment attribute. @craig.topper, @RKSimon, @pengfei  any ideas?

  ; RUN: opt -passes=instcombine -S < %s | FileCheck %s
  
  define i32 @PR48810() {
  ; CHECK-LABEL: @PR48810(
  ; CHECK-NEXT:    call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 undef, i8* align 4294967296 null, i64 undef, i1 false)
  ; CHECK-NEXT:    ret i32 undef
  ;
    %r = call dereferenceable(1) i8* @mempcpy(i8* undef, i8* null, i64 undef)
    ret i32 undef
  }
  
  declare i8* @mempcpy(i8*, i8* nocapture readonly, i64)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121898/new/

https://reviews.llvm.org/D121898



More information about the llvm-commits mailing list