dominik-steenken wrote: So i've been reading through the code and the history a bit, and there is [this commit](https://github.com/llvm/llvm-project/commit/fa806422050edba799bc4392125a0305a4bccf6b), which introduces the concept of a minimum alignment for globals to `clang`. The `clang` backend gets a `MinGlobalAlign` attribute that is supposed to be referenced via `ASTContext::getAlignOfGlobalVar(InChars)` when creating global variables as part of `clang`'s CodeGen. This is why the initial global variable that carries the string before the optimization has the correct alignment.
>From what i can tell, this doesn't work here because the optimization for the >`printf` happens in the context of `LLVM`s `IRBuilder`, where the `ASTContext` >is (no longer?) available. I don't know what should happen in general for optimizations that end up adding global variables, but in this particular case i think there is an easier way. The point of this optimization is to convert the `printf` into at `puts`, and that requires "taking off" the trailing newline. Other than that, the new string is intended to be a direct replacement for the existing one. Since that is the case, i should be able to set the alignment of the new `GlobalVariable` to the alignment of the existing one. Would this be ok? https://github.com/llvm/llvm-project/pull/142346 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits