Skip to content

Commit 0cdd3b1

Browse files
committed
[NewPM] Port HWASan and Kernel HWASan
Port hardware assisted address sanitizer to new PM following the same guidelines as msan and tsan. Changes: - Separate HWAddressSanitizer into a pass class and a sanitizer class. - Create new PM wrapper pass for the sanitizer class. - Use the getOrINsert pattern for some module level initialization declarations. - Also enable kernel-kwasan in new PM - Update llvm tests and add clang test. Differential Revision: https://reviews.llvm.org/D61709 llvm-svn: 360707
1 parent 7baf528 commit 0cdd3b1

File tree

10 files changed

+205
-53
lines changed

10 files changed

+205
-53
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
5858
#include "llvm/Transforms/Instrumentation/BoundsChecking.h"
5959
#include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
60+
#include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
6061
#include "llvm/Transforms/Instrumentation/InstrProfiling.h"
6162
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
6263
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
@@ -265,12 +266,13 @@ static void addHWAddressSanitizerPasses(const PassManagerBuilder &Builder,
265266
static_cast<const PassManagerBuilderWrapper &>(Builder);
266267
const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts();
267268
bool Recover = CGOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
268-
PM.add(createHWAddressSanitizerPass(/*CompileKernel*/ false, Recover));
269+
PM.add(
270+
createHWAddressSanitizerLegacyPassPass(/*CompileKernel*/ false, Recover));
269271
}
270272

271273
static void addKernelHWAddressSanitizerPasses(const PassManagerBuilder &Builder,
272274
legacy::PassManagerBase &PM) {
273-
PM.add(createHWAddressSanitizerPass(
275+
PM.add(createHWAddressSanitizerLegacyPassPass(
274276
/*CompileKernel*/ true, /*Recover*/ true));
275277
}
276278

@@ -962,6 +964,17 @@ static void addSanitizersAtO0(ModulePassManager &MPM,
962964
if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
963965
MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
964966
}
967+
968+
if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
969+
bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
970+
MPM.addPass(createModuleToFunctionPassAdaptor(
971+
HWAddressSanitizerPass(/*CompileKernel=*/false, Recover)));
972+
}
973+
974+
if (LangOpts.Sanitize.has(SanitizerKind::KernelHWAddress)) {
975+
MPM.addPass(createModuleToFunctionPassAdaptor(
976+
HWAddressSanitizerPass(/*CompileKernel=*/true, /*Recover=*/true)));
977+
}
965978
}
966979

967980
/// A clean version of `EmitAssembly` that uses the new pass manager.
@@ -1145,6 +1158,23 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
11451158
UseOdrIndicator));
11461159
});
11471160
}
1161+
if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
1162+
bool Recover =
1163+
CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
1164+
PB.registerOptimizerLastEPCallback(
1165+
[Recover](FunctionPassManager &FPM,
1166+
PassBuilder::OptimizationLevel Level) {
1167+
FPM.addPass(HWAddressSanitizerPass(
1168+
/*CompileKernel=*/false, Recover));
1169+
});
1170+
}
1171+
if (LangOpts.Sanitize.has(SanitizerKind::KernelHWAddress)) {
1172+
PB.registerOptimizerLastEPCallback(
1173+
[](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) {
1174+
FPM.addPass(HWAddressSanitizerPass(
1175+
/*CompileKernel=*/true, /*Recover=*/true));
1176+
});
1177+
}
11481178
if (Optional<GCOVOptions> Options = getGCOVOptions(CodeGenOpts))
11491179
PB.registerPipelineStartEPCallback([Options](ModulePassManager &MPM) {
11501180
MPM.addPass(GCOVProfilerPass(*Options));

clang/test/CodeGen/hwasan-new-pm.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Test that HWASan and KHWASan runs with the new pass manager.
2+
// We run them under different optimizations and LTOs to ensure the IR is still
3+
// being instrumented properly.
4+
5+
// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=hwaddress %s | FileCheck %s --check-prefixes=CHECK,HWASAN,HWASAN-NOOPT
6+
// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=hwaddress -flto %s | FileCheck %s --check-prefixes=CHECK,HWASAN,HWASAN-NOOPT
7+
// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=hwaddress -flto=thin %s | FileCheck %s --check-prefixes=CHECK,HWASAN,HWASAN-NOOPT
8+
// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=hwaddress %s | FileCheck %s --check-prefixes=CHECK,HWASAN
9+
// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=hwaddress -flto %s | FileCheck %s --check-prefixes=CHECK,HWASAN
10+
// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=hwaddress -flto=thin %s | FileCheck %s
11+
12+
// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress %s | FileCheck %s --check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT
13+
// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto %s | FileCheck %s --check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT
14+
// RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto=thin %s | FileCheck %s --check-prefixes=CHECK,KHWASAN,KHWASAN-NOOPT
15+
// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress %s | FileCheck %s --check-prefixes=CHECK,KHWASAN
16+
// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto %s | FileCheck %s --check-prefixes=CHECK,KHWASAN
17+
// RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager -fsanitize=kernel-hwaddress -flto=thin %s | FileCheck %s
18+
19+
int foo(int *a) { return *a; }
20+
21+
// All the cases above mark the function with sanitize_hwaddress.
22+
// CHECK-DAG: sanitize_hwaddress
23+
24+
// Both sanitizers produce %hwasan.shadow without both thinlto and optimizations.
25+
// HWASAN-DAG: %hwasan.shadow
26+
// KHWASAN-DAG: %hwasan.shadow
27+
28+
// Both sanitizers produce __hwasan_tls without both thinlto and optimizations.
29+
// HWASAN-DAG: __hwasan_tls
30+
// KHWASAN-DAG: __hwasan_tls
31+
32+
// For unoptimized cases, both sanitizers produce different load functions.
33+
// HWASAN-NOOPT-DAG: __hwasan_loadN
34+
// KHWASAN-NOOPT-DAG: __hwasan_loadN_noabort

llvm/include/llvm/InitializePasses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void initializeGlobalSplitPass(PassRegistry&);
163163
void initializeGlobalsAAWrapperPassPass(PassRegistry&);
164164
void initializeGuardWideningLegacyPassPass(PassRegistry&);
165165
void initializeHotColdSplittingLegacyPassPass(PassRegistry&);
166-
void initializeHWAddressSanitizerPass(PassRegistry&);
166+
void initializeHWAddressSanitizerLegacyPassPass(PassRegistry &);
167167
void initializeIPCPPass(PassRegistry&);
168168
void initializeIPSCCPLegacyPassPass(PassRegistry&);
169169
void initializeIRCELegacyPassPass(PassRegistry&);

llvm/include/llvm/Transforms/Instrumentation.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ ModulePass *createInstrProfilingLegacyPass(
152152

153153
ModulePass *createInstrOrderFilePass();
154154

155-
FunctionPass *createHWAddressSanitizerPass(bool CompileKernel = false,
156-
bool Recover = false);
157-
158155
// Insert DataFlowSanitizer (dynamic data flow analysis) instrumentation
159156
ModulePass *createDataFlowSanitizerPass(
160157
const std::vector<std::string> &ABIListFiles = std::vector<std::string>(),
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//===--------- Definition of the HWAddressSanitizer class -------*- C++ -*-===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is distributed under the University of Illinois Open Source
6+
// License. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
//
10+
// This file declares the Hardware AddressSanitizer class which is a port of the
11+
// legacy HWAddressSanitizer pass to use the new PassManager infrastructure.
12+
//
13+
//===----------------------------------------------------------------------===//
14+
#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_HWADDRESSSANITIZERPASS_H
15+
#define LLVM_TRANSFORMS_INSTRUMENTATION_HWADDRESSSANITIZERPASS_H
16+
17+
#include "llvm/IR/Function.h"
18+
#include "llvm/IR/PassManager.h"
19+
20+
namespace llvm {
21+
22+
/// This is a public interface to the hardware address sanitizer pass for
23+
/// instrumenting code to check for various memory errors at runtime, similar to
24+
/// AddressSanitizer but based on partial hardware assistance.
25+
class HWAddressSanitizerPass : public PassInfoMixin<HWAddressSanitizerPass> {
26+
public:
27+
explicit HWAddressSanitizerPass(bool CompileKernel = false,
28+
bool Recover = false);
29+
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
30+
31+
private:
32+
bool CompileKernel;
33+
bool Recover;
34+
};
35+
36+
FunctionPass *createHWAddressSanitizerLegacyPassPass(bool CompileKernel = false,
37+
bool Recover = false);
38+
39+
} // namespace llvm
40+
41+
#endif

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
#include "llvm/Transforms/Instrumentation/CGProfile.h"
9595
#include "llvm/Transforms/Instrumentation/ControlHeightReduction.h"
9696
#include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
97+
#include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
9798
#include "llvm/Transforms/Instrumentation/InstrOrderFile.h"
9899
#include "llvm/Transforms/Instrumentation/InstrProfiling.h"
99100
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"

llvm/lib/Passes/PassRegistry.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ FUNCTION_PASS("view-cfg-only", CFGOnlyViewerPass())
237237
FUNCTION_PASS("transform-warning", WarnMissedTransformationsPass())
238238
FUNCTION_PASS("asan", AddressSanitizerPass(false, false, false))
239239
FUNCTION_PASS("kasan", AddressSanitizerPass(true, false, false))
240+
FUNCTION_PASS("hwasan", HWAddressSanitizerPass(false, false))
241+
FUNCTION_PASS("khwasan", HWAddressSanitizerPass(true, true))
240242
FUNCTION_PASS("msan", MemorySanitizerPass({}))
241243
FUNCTION_PASS("kmsan", MemorySanitizerPass({0, false, /*Kernel=*/true}))
242244
FUNCTION_PASS("tsan", ThreadSanitizerPass())

llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Lines changed: 87 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/// based on tagged addressing.
1212
//===----------------------------------------------------------------------===//
1313

14+
#include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
1415
#include "llvm/ADT/SmallVector.h"
1516
#include "llvm/ADT/StringExtras.h"
1617
#include "llvm/ADT/StringRef.h"
@@ -164,22 +165,19 @@ namespace {
164165

165166
/// An instrumentation pass implementing detection of addressability bugs
166167
/// using tagged pointers.
167-
class HWAddressSanitizer : public FunctionPass {
168+
class HWAddressSanitizer {
168169
public:
169-
// Pass identification, replacement for typeid.
170-
static char ID;
171-
172-
explicit HWAddressSanitizer(bool CompileKernel = false, bool Recover = false)
173-
: FunctionPass(ID) {
170+
explicit HWAddressSanitizer(Module &M, bool CompileKernel = false,
171+
bool Recover = false) {
174172
this->Recover = ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover;
175173
this->CompileKernel = ClEnableKhwasan.getNumOccurrences() > 0 ?
176174
ClEnableKhwasan : CompileKernel;
177-
}
178175

179-
StringRef getPassName() const override { return "HWAddressSanitizer"; }
176+
initializeModule(M);
177+
}
180178

181-
bool runOnFunction(Function &F) override;
182-
bool doInitialization(Module &M) override;
179+
bool sanitizeFunction(Function &F);
180+
void initializeModule(Module &M);
183181

184182
void initializeCallbacks(Module &M);
185183

@@ -279,29 +277,61 @@ class HWAddressSanitizer : public FunctionPass {
279277
GlobalValue *ThreadPtrGlobal = nullptr;
280278
};
281279

280+
class HWAddressSanitizerLegacyPass : public FunctionPass {
281+
public:
282+
// Pass identification, replacement for typeid.
283+
static char ID;
284+
285+
explicit HWAddressSanitizerLegacyPass(bool CompileKernel = false,
286+
bool Recover = false)
287+
: FunctionPass(ID), CompileKernel(CompileKernel), Recover(Recover) {}
288+
289+
StringRef getPassName() const override { return "HWAddressSanitizer"; }
290+
291+
bool runOnFunction(Function &F) override {
292+
HWAddressSanitizer HWASan(*F.getParent(), CompileKernel, Recover);
293+
return HWASan.sanitizeFunction(F);
294+
}
295+
296+
private:
297+
bool CompileKernel;
298+
bool Recover;
299+
};
300+
282301
} // end anonymous namespace
283302

284-
char HWAddressSanitizer::ID = 0;
303+
char HWAddressSanitizerLegacyPass::ID = 0;
285304

286305
INITIALIZE_PASS_BEGIN(
287-
HWAddressSanitizer, "hwasan",
306+
HWAddressSanitizerLegacyPass, "hwasan",
288307
"HWAddressSanitizer: detect memory bugs using tagged addressing.", false,
289308
false)
290309
INITIALIZE_PASS_END(
291-
HWAddressSanitizer, "hwasan",
310+
HWAddressSanitizerLegacyPass, "hwasan",
292311
"HWAddressSanitizer: detect memory bugs using tagged addressing.", false,
293312
false)
294313

295-
FunctionPass *llvm::createHWAddressSanitizerPass(bool CompileKernel,
296-
bool Recover) {
314+
FunctionPass *llvm::createHWAddressSanitizerLegacyPassPass(bool CompileKernel,
315+
bool Recover) {
297316
assert(!CompileKernel || Recover);
298-
return new HWAddressSanitizer(CompileKernel, Recover);
317+
return new HWAddressSanitizerLegacyPass(CompileKernel, Recover);
318+
}
319+
320+
HWAddressSanitizerPass::HWAddressSanitizerPass(bool CompileKernel, bool Recover)
321+
: CompileKernel(CompileKernel), Recover(Recover) {}
322+
323+
PreservedAnalyses HWAddressSanitizerPass::run(Function &F,
324+
FunctionAnalysisManager &FAM) {
325+
HWAddressSanitizer HWASan(*F.getParent(), CompileKernel, Recover);
326+
if (HWASan.sanitizeFunction(F))
327+
return PreservedAnalyses::none();
328+
return PreservedAnalyses::all();
299329
}
300330

301331
/// Module-level initialization.
302332
///
303333
/// inserts a call to __hwasan_init to the module's constructor list.
304-
bool HWAddressSanitizer::doInitialization(Module &M) {
334+
void HWAddressSanitizer::initializeModule(Module &M) {
305335
LLVM_DEBUG(dbgs() << "Init " << M.getName() << "\n");
306336
auto &DL = M.getDataLayout();
307337

@@ -320,43 +350,54 @@ bool HWAddressSanitizer::doInitialization(Module &M) {
320350
HwasanCtorFunction = nullptr;
321351
if (!CompileKernel) {
322352
std::tie(HwasanCtorFunction, std::ignore) =
323-
createSanitizerCtorAndInitFunctions(M, kHwasanModuleCtorName,
324-
kHwasanInitName,
325-
/*InitArgTypes=*/{},
326-
/*InitArgs=*/{});
327-
Comdat *CtorComdat = M.getOrInsertComdat(kHwasanModuleCtorName);
328-
HwasanCtorFunction->setComdat(CtorComdat);
329-
appendToGlobalCtors(M, HwasanCtorFunction, 0, HwasanCtorFunction);
353+
getOrCreateSanitizerCtorAndInitFunctions(
354+
M, kHwasanModuleCtorName, kHwasanInitName,
355+
/*InitArgTypes=*/{},
356+
/*InitArgs=*/{},
357+
// This callback is invoked when the functions are created the first
358+
// time. Hook them into the global ctors list in that case:
359+
[&](Function *Ctor, FunctionCallee) {
360+
Comdat *CtorComdat = M.getOrInsertComdat(kHwasanModuleCtorName);
361+
Ctor->setComdat(CtorComdat);
362+
appendToGlobalCtors(M, Ctor, 0, Ctor);
363+
364+
IRBuilder<> IRBCtor(Ctor->getEntryBlock().getTerminator());
365+
IRBCtor.CreateCall(
366+
declareSanitizerInitFunction(M, "__hwasan_init_frames",
367+
{Int8PtrTy, Int8PtrTy}),
368+
{createFrameSectionBound(M, Int8Ty, getFrameSectionBeg()),
369+
createFrameSectionBound(M, Int8Ty, getFrameSectionEnd())});
370+
});
330371

331372
// Create a zero-length global in __hwasan_frame so that the linker will
332373
// always create start and stop symbols.
333374
//
334375
// N.B. If we ever start creating associated metadata in this pass this
335376
// global will need to be associated with the ctor.
336377
Type *Int8Arr0Ty = ArrayType::get(Int8Ty, 0);
337-
auto GV =
338-
new GlobalVariable(M, Int8Arr0Ty, /*isConstantGlobal*/ true,
339-
GlobalVariable::PrivateLinkage,
340-
Constant::getNullValue(Int8Arr0Ty), "__hwasan");
341-
GV->setSection(getFrameSection());
342-
GV->setComdat(CtorComdat);
343-
appendToCompilerUsed(M, GV);
344-
345-
IRBuilder<> IRBCtor(HwasanCtorFunction->getEntryBlock().getTerminator());
346-
IRBCtor.CreateCall(
347-
declareSanitizerInitFunction(M, "__hwasan_init_frames",
348-
{Int8PtrTy, Int8PtrTy}),
349-
{createFrameSectionBound(M, Int8Ty, getFrameSectionBeg()),
350-
createFrameSectionBound(M, Int8Ty, getFrameSectionEnd())});
378+
M.getOrInsertGlobal("__hwasan", Int8Arr0Ty, [&] {
379+
auto *GV = new GlobalVariable(
380+
M, Int8Arr0Ty, /*isConstantGlobal=*/true, GlobalValue::PrivateLinkage,
381+
Constant::getNullValue(Int8Arr0Ty), "__hwasan");
382+
GV->setSection(getFrameSection());
383+
Comdat *CtorComdat = M.getOrInsertComdat(kHwasanModuleCtorName);
384+
GV->setComdat(CtorComdat);
385+
appendToCompilerUsed(M, GV);
386+
return GV;
387+
});
351388
}
352389

353-
if (!TargetTriple.isAndroid())
354-
appendToCompilerUsed(
355-
M, ThreadPtrGlobal = new GlobalVariable(
356-
M, IntptrTy, false, GlobalVariable::ExternalLinkage, nullptr,
357-
"__hwasan_tls", nullptr, GlobalVariable::InitialExecTLSModel));
358-
359-
return true;
390+
if (!TargetTriple.isAndroid()) {
391+
Constant *C = M.getOrInsertGlobal("__hwasan_tls", IntptrTy, [&] {
392+
auto *GV = new GlobalVariable(M, IntptrTy, /*isConstantGlobal=*/false,
393+
GlobalValue::ExternalLinkage, nullptr,
394+
"__hwasan_tls", nullptr,
395+
GlobalVariable::InitialExecTLSModel);
396+
appendToCompilerUsed(M, GV);
397+
return GV;
398+
});
399+
ThreadPtrGlobal = cast<GlobalVariable>(C);
400+
}
360401
}
361402

362403
void HWAddressSanitizer::initializeCallbacks(Module &M) {
@@ -970,7 +1011,7 @@ bool HWAddressSanitizer::isInterestingAlloca(const AllocaInst &AI) {
9701011
!AI.isSwiftError());
9711012
}
9721013

973-
bool HWAddressSanitizer::runOnFunction(Function &F) {
1014+
bool HWAddressSanitizer::sanitizeFunction(Function &F) {
9741015
if (&F == HwasanCtorFunction)
9751016
return false;
9761017

llvm/lib/Transforms/Instrumentation/Instrumentation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void llvm::initializeInstrumentation(PassRegistry &Registry) {
114114
initializeInstrOrderFileLegacyPassPass(Registry);
115115
initializeInstrProfilingLegacyPassPass(Registry);
116116
initializeMemorySanitizerLegacyPassPass(Registry);
117-
initializeHWAddressSanitizerPass(Registry);
117+
initializeHWAddressSanitizerLegacyPassPass(Registry);
118118
initializeThreadSanitizerLegacyPassPass(Registry);
119119
initializeSanitizerCoverageModulePass(Registry);
120120
initializeDataFlowSanitizerPass(Registry);

llvm/test/Instrumentation/HWAddressSanitizer/basic.ll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
; RUN: opt < %s -hwasan -hwasan-recover=0 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT,ABORT-ZERO-BASED-SHADOW
66
; RUN: opt < %s -hwasan -hwasan-recover=1 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,RECOVER,RECOVER-ZERO-BASED-SHADOW
77

8+
; Ensure than hwasan runs with the new PM pass
9+
; RUN: opt < %s -passes='function(hwasan)' -hwasan-recover=0 -hwasan-with-ifunc=1 -hwasan-with-tls=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT,ABORT-DYNAMIC-SHADOW
10+
; RUN: opt < %s -passes='function(hwasan)' -hwasan-recover=1 -hwasan-with-ifunc=1 -hwasan-with-tls=0 -S | FileCheck %s --check-prefixes=CHECK,RECOVER,RECOVER-DYNAMIC-SHADOW
11+
; RUN: opt < %s -passes='function(hwasan)' -hwasan-recover=0 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT,ABORT-ZERO-BASED-SHADOW
12+
; RUN: opt < %s -passes='function(hwasan)' -hwasan-recover=1 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,RECOVER,RECOVER-ZERO-BASED-SHADOW
13+
814
; CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @hwasan.module_ctor, i8* bitcast (void ()* @hwasan.module_ctor to i8*) }]
915
; CHECK: @__hwasan = private constant [0 x i8] zeroinitializer, section "__hwasan_frames", comdat($hwasan.module_ctor)
1016

0 commit comments

Comments
 (0)