Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/actions/1-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,30 @@ runs:
# Make sure to link libzstd statically
sudo rm /usr/lib/$arch-linux-gnu/libzstd.so

- name: 'Linux: Install clang 20 from apt.llvm.org'
- name: 'Linux: Install clang 21 from apt.llvm.org'
if: runner.os == 'Linux'
shell: bash
run: |
set -eux
cd ..
curl -fL --retry 3 --max-time 30 -O https://apt.llvm.org/llvm.sh
sudo bash llvm.sh 20
sudo bash llvm.sh 21
for tool in clang clang++ ld.lld; do
sudo ln -sf $tool-20 /usr/bin/$tool
sudo ln -sf $tool-21 /usr/bin/$tool
$tool --version
done
- name: 'macOS arm64: Install Homebrew clang 20' # see mimalloc comment in ../3-build-native/action.yml
- name: 'macOS arm64: Install Homebrew clang 21' # see mimalloc comment in ../3-build-native/action.yml
if: runner.os == 'macOS' && inputs.arch == 'arm64'
shell: bash
run: brew install llvm@20
- name: 'Windows: Install clang v20.1.3 from GitHub'
run: brew install llvm@21
- name: 'Windows: Install clang v21.1.2 from GitHub'
if: runner.os == 'Windows'
shell: bash
run: |
set -eux
cd ..
curl -fL --retry 3 --max-time 300 -o clang.exe \
https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.3/LLVM-20.1.3-win64.exe
https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.2/LLVM-21.1.2-win64.exe
./clang.exe //S # double-slash for bash
rm clang.exe
# C:\Program Files\LLVM\bin should already be in PATH
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
cancel-in-progress: true

env:
LLVM_VERSION: 20.1.5
LLVM_VERSION: d1af86a3

jobs:
build-native:
Expand Down Expand Up @@ -85,8 +85,8 @@ jobs:
os: macos-15
arch: arm64
extra_cmake_flags: >-
-DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm@20/bin/clang
-DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm@20/bin/clang++
-DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm@21/bin/clang
-DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm@21/bin/clang++
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto -L-exported_symbol '-L__*' -L-w"
-DEXTRA_CXXFLAGS=-flto=full
with_pgo: true
Expand Down
21 changes: 6 additions & 15 deletions gen/llvmhelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,27 +897,18 @@ void DtoVarDeclaration(VarDeclaration *vd) {

// We also allocate a variable for zero-sized variables, because they are technically not `null` when loaded.
// The x86_64 ABI "loads" zero-sized function arguments, and without an allocation ASan will report an error (Github #4816).
llvm::Value *allocainst;
bool isRealAlloca = false;
LLType *lltype = DtoType(type); // void for noreturn
if (lltype->isVoidTy()) {
allocainst = getNullPtr();
} else if (type != vd->type) {
allocainst = DtoAlloca(type, vd->toChars());
isRealAlloca = true;
irLocal->value = getNullPtr();
} else {
allocainst = DtoAlloca(vd, vd->toChars());
isRealAlloca = true;
}

irLocal->value = allocainst;
auto allocainst = type != vd->type ? DtoAlloca(type, vd->toChars())
: DtoAlloca(vd, vd->toChars());

if (!lltype->isVoidTy())
irLocal->value = allocainst;
gIR->DBuilder.EmitLocalVariable(allocainst, vd);

// Lifetime annotation is only valid on alloca.
if (isRealAlloca) {
// The lifetime of a stack variable starts from the point it is declared
// The lifetime of a stack variable starts from the
// point it is declared
gIR->funcGen().localVariableLifetimeAnnotator.addLocalVariable(
allocainst, DtoConstUlong(size(type)));
}
Expand Down
2 changes: 1 addition & 1 deletion gen/variable_lifetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ LocalVariableLifetimeAnnotator::LocalVariableLifetimeAnnotator(IRState &irs)

void LocalVariableLifetimeAnnotator::pushScope() { scopes.emplace_back(); }

void LocalVariableLifetimeAnnotator::addLocalVariable(llvm::Value *address,
void LocalVariableLifetimeAnnotator::addLocalVariable(llvm::AllocaInst *address,
llvm::Value *size) {
assert(address);
assert(size);
Expand Down
5 changes: 3 additions & 2 deletions gen/variable_lifetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ namespace llvm {
class Function;
class Type;
class Value;
class AllocaInst;
}
struct IRState;

struct LocalVariableLifetimeAnnotator {
struct LocalVariableScope {
std::vector<std::pair<llvm::Value *, llvm::Value *>> variables;
std::vector<std::pair<llvm::Value *, llvm::AllocaInst *>> variables;
};
/// Stack of scopes, each scope can have multiple variables.
std::vector<LocalVariableScope> scopes;
Expand All @@ -52,5 +53,5 @@ struct LocalVariableLifetimeAnnotator {
void popScope();

/// Register a new local variable for lifetime annotation.
void addLocalVariable(llvm::Value *address, llvm::Value *size);
void addLocalVariable(llvm::AllocaInst *address, llvm::Value *size);
};
3 changes: 2 additions & 1 deletion runtime/druntime/src/ldc/intrinsics.di
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ else version (LDC_LLVM_1800) enum LLVM_version = 1800;
else version (LDC_LLVM_1801) enum LLVM_version = 1801;
else version (LDC_LLVM_1901) enum LLVM_version = 1901;
else version (LDC_LLVM_2001) enum LLVM_version = 2001;
else version (LDC_LLVM_2100) enum LLVM_version = 2100;
else version (LDC_LLVM_2101) enum LLVM_version = 2101;
else version (LDC_LLVM_2200) enum LLVM_version = 2200;
else static assert(false, "LDC LLVM version not supported");

enum LLVM_atleast(int major) = (LLVM_version >= major * 100);
Expand Down
Loading
Loading