Skip to content
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// RUN: %clangxx_asan %min_macos_deployment_target=10.11 -O0 %s %p/Helpers/initialization-bug-extra.cpp -o %t
// RUN: %env_asan_opts=check_initialization_order=true:strict_init_order=true not %run %t 2>&1 | FileCheck %s

// Not implemented.
// XFAIL: *

// Do not test with optimization -- the error may be optimized away.

// FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=186
Expand Down
7 changes: 1 addition & 6 deletions llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2538,8 +2538,6 @@ void ModuleAddressSanitizer::instrumentGlobals(IRBuilder<> &IRB,
SmallVector<GlobalVariable *, 16> NewGlobals(n);
SmallVector<Constant *, 16> Initializers(n);

bool HasDynamicallyInitializedGlobals = false;

for (size_t i = 0; i < n; i++) {
GlobalVariable *G = GlobalsToChange[i];

Expand Down Expand Up @@ -2645,9 +2643,6 @@ void ModuleAddressSanitizer::instrumentGlobals(IRBuilder<> &IRB,
Constant::getNullValue(IntptrTy),
ConstantExpr::getPointerCast(ODRIndicator, IntptrTy));

if (ClInitializers && MD.IsDynInit)
HasDynamicallyInitializedGlobals = true;

LLVM_DEBUG(dbgs() << "NEW GLOBAL: " << *NewGlobal << "\n");

Initializers[i] = Initializer;
Expand Down Expand Up @@ -2686,7 +2681,7 @@ void ModuleAddressSanitizer::instrumentGlobals(IRBuilder<> &IRB,
}

// Create calls for poisoning before initializers run and unpoisoning after.
if (HasDynamicallyInitializedGlobals)
if (ClInitializers)
createInitializerPoisonCalls();

LLVM_DEBUG(dbgs() << M);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ define internal void @__late_ctor() sanitize_address section ".text.startup" {
; CHECK-LABEL: define internal void @__late_ctor(
; CHECK-SAME: ) #[[ATTR1:[0-9]+]] section ".text.startup" {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: call void @__asan_before_dynamic_init(i64 ptrtoint (ptr @___asan_gen_module to i64))
; CHECK-NEXT: call void @initializer()
; CHECK-NEXT: call void @__asan_after_dynamic_init()
; CHECK-NEXT: ret void
;
; NOINIT-LABEL: define internal void @__late_ctor(
Expand Down