[llvm-bugs] [Bug 47499] New: __unaligned extension inconsistent behaviour with C and C++

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 11 11:29:27 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47499

            Bug ID: 47499
           Summary: __unaligned extension inconsistent behaviour with C
                    and C++
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rofirrim at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

struct Foo {
  unsigned long x;
};

void foo(__unaligned struct Foo* out){
  out->x = 5;
}

Emits this in C (which is the expected behaviour)

%struct.Foo = type { i64 }

define dso_local void @foo(%struct.Foo* nocapture %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds %struct.Foo, %struct.Foo* %0, i64 0, i32 0
  store i64 5, i64* %2, align 1, !tbaa !2
  ret void
}

but this in C++ which does not honour the qualifier

%struct.Foo = type { i64 }

define dso_local void @_Z3fooPU11__unaligned3Foo(%struct.Foo* nocapture %0)
local_unnamed_addr #0 {
  %2 = getelementptr inbounds %struct.Foo, %struct.Foo* %0, i64 0, i32 0
  store i64 5, i64* %2, align 8, !tbaa !2
  ret void
}

We want both languages agree. I suggest we bring the current behaviour in C to
C++.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200911/5d84156c/attachment.html>


More information about the llvm-bugs mailing list