Xiangling_L added inline comments.
================ Comment at: clang/include/clang/AST/Mangle.h:178 + virtual void mangleDynamicDestructor(const VarDecl *D, raw_ostream &Out) = 0; + ---------------- hubert.reinterpretcast wrote: > I am not sure "destructor" is the right term here. This seems to be an > analogue to the functions named using `mangleDynamicAtExitDestructor`, except > that those rather directly perform destruction and are registered with > `atexit` during initialization whereas these perform finalization and are > "registered" by being called from an "sterm" function. What are the thoughts > on `mangleDynamicStermFinalizer`? `mangleDynamicDestructor` is an analogue to `mangleDynamicInitializer` actually. From this perspective, I think `mangleDynamicStermFinalizer` is good. ================ Comment at: clang/lib/CodeGen/CodeGenModule.h:1058 + void AddCXXDtorEntry(llvm::FunctionCallee DtorFn) { + CXXGlobalDtors.emplace_back(DtorFn.getFunctionType(), DtorFn.getCallee(), + nullptr); ---------------- hubert.reinterpretcast wrote: > The description of `CXXGlobalDtors` is > > Global destructor functions and arguments that need to run on termination. > Currently, only Apple Kernal extension will use `AddCXXDtorEntry` to add variable destructor to CXXGlobalDtors. An example is: ``` $cat test.cpp class test { int a; public: test(int c) {a = c;} ~test() {a = 0;} } t(1); $clang --driver-mode=g++ -target x86_64-apple-darwin10 -fapple-kext -flto -S -o - test.cpp ... define internal void @_GLOBAL__D_a() #0 { entry: call void @_ZN4testD1Ev(%class.test* @t) #~test() {a = 0;} ret void } ``` Since the usage as you said below does not match with our sterm finalizer function `__cxx_global_var_destruct`, I am thinking we can either modify the name and the description of `CXXGlobalDtors` to make it also fit AIX or we can define a brand new `CXXStermFinalizers` vector and also related facility to `GenerateCXXStermFinalizerFunc` instead. An example of modification I have in mind is: `CXXGlobalDtorsOrStermFinalizers` > Global destructor functions and arguments that need to run on termination; > When UseSinitAndSterm is set, it contains sterm finalizer functions instead > that need to run on unloading a shared library. I would prefer the modification way to save a lot effort. Any thoughts on it? ================ Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4447 + + // Create __dtor function for the var decl. + llvm::Function *dtorStub = CGF.createAtExitStub(D, dtor, addr); ---------------- hubert.reinterpretcast wrote: > We should probably report_fatal_error if `CXAAtExit` (the option) is true > before this line. This would imply driver changes to default AIX to using > `-fno-use-cxa-atexit`. An associated test file is > https://github.com/llvm/llvm-project/blame/master/clang/test/Driver/cxa-atexit.cpp. Maybe we should add `-fno-use-cxa-atexit` to driver in a follow-up patch? ================ Comment at: clang/test/CodeGen/static-init.cpp:15 + +// CHECK: define internal void @__cxx_global_var_init() #0 { +// CHECK: entry: ---------------- jasonliu wrote: > #0 could be removed. Why I chose to keep this `#0` is because to remove it, we would either remove the following `{` which I kinda feel makes the function look not nice or we need to match `#0` with regex which I think is redundant. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74166/new/ https://reviews.llvm.org/D74166 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits