[PATCH] D137107: Allow MS extension: support of constexpr with __declspec(dllimport).

Zahira Ammarguellat via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 16 07:02:26 PST 2022


zahiraam added a comment.

In D137107#3999681 <https://reviews.llvm.org/D137107#3999681>, @efriedma wrote:

> Not sure exactly what code that generates in its current form, but that's roughly the right idea, yes.

Thanks.

This is the IR I am getting for this simple case. I think there is still something wrong with the call to the atexit. Still trying to find out where this is generated in the code.

  // RUN: %clang_cc1 -no-enable-noundef-analysis x86_64-windows-msvc  \
  // RUN: -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++2a \
  // RUN: -O0 -o - %s | FileCheck %s
  
  // CHECK: @"?b@@3UB@@A" = dso_local global %struct.B undef, align 1
  // CHECK: @llvm.global_ctors = appending global [2 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 201, ptr @ctor, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @dtor, ptr null }]
  
  // CHECK: define internal void @ctor() #0 {
  // CHECK: entry:
  // CHECK:   %call = call x86_thiscallcc ptr @"??0B@@QAE at XZ"(ptr nonnull align 1 dereferenceable(1) @"?b@@3UB@@A")
  // CHECK:   %0 = call i32 @atexit(ptr @"??__Fb@@YAXXZ") #2    **<== This shouldn't be called here, right?**
  // CHECK:   ret void
  // CHECK: }
  
  // CHECK: define internal void @dtor() #0 {
  // CHECK: entry:
  // CHECK:   %0 = call i32 @atexit(ptr @"??__Fb@@YAXXZ.1") #2
  // CHECK:   ret void
  // CHECK: }
  
  struct B {
    constexpr B() {}
    ~B() {};
  };
  constinit B b;


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

https://reviews.llvm.org/D137107



More information about the cfe-commits mailing list