[PATCH] D128142: [MemProf] Memprof profile matching and annotation
Enna1 added inline comments. Comment at: llvm/lib/Analysis/MemoryBuiltins.cpp:288-290 +bool llvm::isNewLikeFn(const Value *V, const TargetLibraryInfo *TLI) { + return getAllocationData(V, OpNewLike, TLI).hasValue(); +} nit: place the definition of `llvm::isNewLikeFn` just after `llvm::isAllocationFn(const Value *V, function_ref GetTLI)` ? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D128142/new/ https://reviews.llvm.org/D128142 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D126294: Add !nosanitize to FixedMetadataKinds
Enna1 created this revision. Herald added subscribers: ormris, hiraditya. Herald added a project: All. Enna1 requested review of this revision. Herald added projects: clang, LLVM. Herald added subscribers: llvm-commits, cfe-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D126294 Files: clang/lib/CodeGen/SanitizerMetadata.cpp llvm/include/llvm/IR/FixedMetadataKinds.def llvm/lib/Transforms/IPO/HotColdSplitting.cpp llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp === --- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -241,8 +241,7 @@ Type *Ty); void SetNoSanitizeMetadata(Instruction *I) { -I->setMetadata(I->getModule()->getMDKindID("nosanitize"), - MDNode::get(*C, None)); +I->setMetadata(LLVMContext::MD_nosanitize, MDNode::get(*C, None)); } std::string getSectionName(const std::string &Section) const; Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp === --- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -1620,7 +1620,7 @@ /// or extracts if from ParamTLS (for function arguments). Value *getShadow(Value *V) { if (Instruction *I = dyn_cast(V)) { - if (!PropagateShadow || I->getMetadata("nosanitize")) + if (!PropagateShadow || I->getMetadata(LLVMContext::MD_nosanitize)) return getCleanShadow(V); // For instructions the shadow is already stored in the map. Value *Shadow = ShadowMap[V]; @@ -1739,7 +1739,7 @@ assert((isa(V) || isa(V)) && "Unexpected value type in getOrigin()"); if (Instruction *I = dyn_cast(V)) { - if (I->getMetadata("nosanitize")) + if (I->getMetadata(LLVMContext::MD_nosanitize)) return getCleanOrigin(); } Value *Origin = OriginMap[V]; @@ -1862,7 +1862,7 @@ // --- Visitors. using InstVisitor::visit; void visit(Instruction &I) { -if (I.getMetadata("nosanitize")) +if (I.getMetadata(LLVMContext::MD_nosanitize)) return; // Don't want to visit if we're in the prologue if (isInPrologue(I)) @@ -1876,7 +1876,7 @@ /// Optionally, checks that the load address is fully defined. void visitLoadInst(LoadInst &I) { assert(I.getType()->isSized() && "Load type must have size"); -assert(!I.getMetadata("nosanitize")); +assert(!I.getMetadata(LLVMContext::MD_nosanitize)); IRBuilder<> IRB(I.getNextNode()); Type *ShadowTy = getShadowTy(&I); Value *Addr = I.getPointerOperand(); @@ -3591,7 +3591,7 @@ } void visitCallBase(CallBase &CB) { -assert(!CB.getMetadata("nosanitize")); +assert(!CB.getMetadata(LLVMContext::MD_nosanitize)); if (CB.isInlineAsm()) { // For inline asm (either a call to asm function, or callbr instruction), // do the usual thing: check argument shadow and mark all outputs as Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp === --- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -715,7 +715,7 @@ void HWAddressSanitizer::getInterestingMemoryOperands( Instruction *I, SmallVectorImpl &Interesting) { // Skip memory accesses inserted by another instrumentation. - if (I->hasMetadata("nosanitize")) + if (I->hasMetadata(LLVMContext::MD_nosanitize)) return; // Do not instrument the load fetching the dynamic shadow address. Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp === --- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1331,7 +1331,7 @@ void AddressSanitizer::getInterestingMemoryOperands( Instruction *I, SmallVectorImpl &Interesting) { // Skip memory accesses inserted by another instrumentation. - if (I->hasMetadata("nosanitize")) + if (I->hasMetadata(LLVMContext::MD_nosanitize)) return; // Do not instrument the load fetching the dynamic shadow address. @@ -2771,7 +2771,8 @@ if (auto *CB = dyn_cast(&Inst)) { // A call inside BB. TempsToInstrument.clear(); - if (CB->doesNotReturn() && !CB->hasMetadata("nosanitize")) + if (CB->doesNotReturn() && + !CB->hasMetadata(LLVMContext::MD_nosanitize)) NoReturnCalls.push_back(CB);
[PATCH] D126294: Add !nosanitize to FixedMetadataKinds
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG52992f136b3b: Add !nosanitize to FixedMetadataKinds (authored by Enna1). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D126294/new/ https://reviews.llvm.org/D126294 Files: clang/lib/CodeGen/SanitizerMetadata.cpp llvm/include/llvm/IR/FixedMetadataKinds.def llvm/lib/Transforms/IPO/HotColdSplitting.cpp llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp === --- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -241,8 +241,7 @@ Type *Ty); void SetNoSanitizeMetadata(Instruction *I) { -I->setMetadata(I->getModule()->getMDKindID("nosanitize"), - MDNode::get(*C, None)); +I->setMetadata(LLVMContext::MD_nosanitize, MDNode::get(*C, None)); } std::string getSectionName(const std::string &Section) const; Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp === --- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -1620,7 +1620,7 @@ /// or extracts if from ParamTLS (for function arguments). Value *getShadow(Value *V) { if (Instruction *I = dyn_cast(V)) { - if (!PropagateShadow || I->getMetadata("nosanitize")) + if (!PropagateShadow || I->getMetadata(LLVMContext::MD_nosanitize)) return getCleanShadow(V); // For instructions the shadow is already stored in the map. Value *Shadow = ShadowMap[V]; @@ -1739,7 +1739,7 @@ assert((isa(V) || isa(V)) && "Unexpected value type in getOrigin()"); if (Instruction *I = dyn_cast(V)) { - if (I->getMetadata("nosanitize")) + if (I->getMetadata(LLVMContext::MD_nosanitize)) return getCleanOrigin(); } Value *Origin = OriginMap[V]; @@ -1862,7 +1862,7 @@ // --- Visitors. using InstVisitor::visit; void visit(Instruction &I) { -if (I.getMetadata("nosanitize")) +if (I.getMetadata(LLVMContext::MD_nosanitize)) return; // Don't want to visit if we're in the prologue if (isInPrologue(I)) @@ -1876,7 +1876,7 @@ /// Optionally, checks that the load address is fully defined. void visitLoadInst(LoadInst &I) { assert(I.getType()->isSized() && "Load type must have size"); -assert(!I.getMetadata("nosanitize")); +assert(!I.getMetadata(LLVMContext::MD_nosanitize)); IRBuilder<> IRB(I.getNextNode()); Type *ShadowTy = getShadowTy(&I); Value *Addr = I.getPointerOperand(); @@ -3591,7 +3591,7 @@ } void visitCallBase(CallBase &CB) { -assert(!CB.getMetadata("nosanitize")); +assert(!CB.getMetadata(LLVMContext::MD_nosanitize)); if (CB.isInlineAsm()) { // For inline asm (either a call to asm function, or callbr instruction), // do the usual thing: check argument shadow and mark all outputs as Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp === --- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -715,7 +715,7 @@ void HWAddressSanitizer::getInterestingMemoryOperands( Instruction *I, SmallVectorImpl &Interesting) { // Skip memory accesses inserted by another instrumentation. - if (I->hasMetadata("nosanitize")) + if (I->hasMetadata(LLVMContext::MD_nosanitize)) return; // Do not instrument the load fetching the dynamic shadow address. Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp === --- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1331,7 +1331,7 @@ void AddressSanitizer::getInterestingMemoryOperands( Instruction *I, SmallVectorImpl &Interesting) { // Skip memory accesses inserted by another instrumentation. - if (I->hasMetadata("nosanitize")) + if (I->hasMetadata(LLVMContext::MD_nosanitize)) return; // Do not instrument the load fetching the dynamic shadow address. @@ -2771,7 +2771,8 @@ if (auto *CB = dyn_cast(&Inst)) { // A call inside BB. TempsToInstrument.clear(); - if (CB->doesNotReturn() && !CB->hasMetadata("nosanitize")) + if (CB->doesNotReturn() && + !CB->hasMetadata(LLVMContext::MD_nos
[PATCH] D44745: [HWASan] Port HWASan to Linux x86-64 (clang)
Enna1 added a comment. Herald added subscribers: yaneury, supersymetrie, Chia-hungDuan, pengfei. Herald added a project: All. Hi, I'm curious about why hwasan requires PIE. Is there any documents mentioned this? Thanks! Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D44745/new/ https://reviews.llvm.org/D44745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D147121: [hwasan] remove requirment for PIE
Enna1 created this revision. Herald added subscribers: yaneury, supersymetrie, Chia-hungDuan, cryptoad. Herald added a project: All. Enna1 updated this revision to Diff 509252. Enna1 added a comment. Enna1 edited the summary of this revision. Enna1 added reviewers: eugenis, alekseyshl, pcc, vitalybuka. Enna1 added a subscriber: MTC. Enna1 published this revision for review. Herald added subscribers: cfe-commits, MaskRay. Herald added a project: clang. update Enna1 added a comment. Under my test on aarch64 linux, all hwasan tests passed without PIE. IIUC, only global variables in hwasan are affected by PIE. Without PIE, a special instruction sequence assembly will be to emitted to add the tag to the global variable address, see https://reviews.llvm.org/D120305 . I'm not sure if hwasan linux x86-64 is different from linux aarch64 and have a special requirment for PIE. Also note that since https://reviews.llvm.org/D120305, CLANG_DEFAULT_PIE_ON_LINUX was default on. The requirement for PIE of hwasan was introduced in https://reviews.llvm.org/D44745, this patch removes requirement for PIE. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D147121 Files: clang/lib/Driver/SanitizerArgs.cpp clang/test/Driver/sanitizer-ld.c Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -961,7 +961,6 @@ // RUN: | FileCheck --check-prefix=CHECK-HWASAN-X86-64-LINUX %s // // CHECK-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-HWASAN-X86-64-LINUX: "-pie" // CHECK-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.a" // CHECK-HWASAN-X86-64-LINUX-NOT: "--export-dynamic" @@ -979,7 +978,6 @@ // RUN: | FileCheck --check-prefix=CHECK-SHARED-HWASAN-X86-64-LINUX %s // // CHECK-SHARED-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-SHARED-HWASAN-X86-64-LINUX: "-pie" // CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-SHARED-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.so" // CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lpthread" @@ -996,7 +994,6 @@ // RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-HWASAN-X86-64-LINUX %s // // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-DSO_SHARED-HWASAN-X86-64-LINUX: "-pie" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.so" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lpthread" @@ -1013,7 +1010,6 @@ // RUN: | FileCheck --check-prefix=CHECK-HWASAN-AARCH64-LINUX %s // // CHECK-HWASAN-AARCH64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-HWASAN-AARCH64-LINUX: "-pie" // CHECK-HWASAN-AARCH64-LINUX-NOT: "-lc" // CHECK-HWASAN-AARCH64-LINUX: libclang_rt.hwasan-aarch64.a" // CHECK-HWASAN-AARCH64-LINUX-NOT: "--export-dynamic" @@ -1032,7 +1028,6 @@ // RUN: | FileCheck --check-prefix=CHECK-SHARED-HWASAN-AARCH64-LINUX %s // // CHECK-SHARED-HWASAN-AARCH64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-SHARED-HWASAN-AARCH64-LINUX: "-pie" // CHECK-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lc" // CHECK-SHARED-HWASAN-AARCH64-LINUX: libclang_rt.hwasan-aarch64.so" // CHECK-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lpthread" @@ -1049,7 +1044,6 @@ // RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX %s // // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-DSO_SHARED-HWASAN-AARCH64-LINUX: "-pie" // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lc" // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX: libclang_rt.hwasan-aarch64.so" // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lpthread" Index: clang/lib/Driver/SanitizerArgs.cpp === --- clang/lib/Driver/SanitizerArgs.cpp +++ clang/lib/Driver/SanitizerArgs.cpp @@ -38,8 +38,7 @@ static const SanitizerMask NotAllowedWithMinimalRuntime = SanitizerKind::Function | SanitizerKind::Vptr; static const SanitizerMask RequiresPIE = -SanitizerKind::DataFlow | SanitizerKind::HWAddress | SanitizerKind::Scudo | -SanitizerKind::KCFI; +SanitizerKind::DataFlow | SanitizerKind::Scudo | SanitizerKind::KCFI; static const SanitizerMask NeedsUnwindTables = SanitizerKind::Address | SanitizerKind::HWAddress | SanitizerKind::Thread | SanitizerKind::Memory | SanitizerKind::DataFlow; Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -961,7 +961,6 @@ // RUN: | FileCheck --check-prefix=CHECK-HWASAN-X86-64-LINUX %s // // CHECK-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-HWASAN-X86-64-LINUX: "-pie" // CHECK-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-HWASAN-X86-64-LINUX: libclang_rt.hwas
[PATCH] D147121: [hwasan] remove requirment for PIE
Enna1 updated this revision to Diff 509611. Enna1 added a comment. rebase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147121/new/ https://reviews.llvm.org/D147121 Files: clang/lib/Driver/SanitizerArgs.cpp clang/test/Driver/sanitizer-ld.c Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -961,7 +961,6 @@ // RUN: | FileCheck --check-prefix=CHECK-HWASAN-X86-64-LINUX %s // // CHECK-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-HWASAN-X86-64-LINUX: "-pie" // CHECK-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.a" // CHECK-HWASAN-X86-64-LINUX-NOT: "--export-dynamic" @@ -979,7 +978,6 @@ // RUN: | FileCheck --check-prefix=CHECK-SHARED-HWASAN-X86-64-LINUX %s // // CHECK-SHARED-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-SHARED-HWASAN-X86-64-LINUX: "-pie" // CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-SHARED-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.so" // CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lpthread" @@ -996,7 +994,6 @@ // RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-HWASAN-X86-64-LINUX %s // // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-DSO_SHARED-HWASAN-X86-64-LINUX: "-pie" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.so" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lpthread" @@ -1013,7 +1010,6 @@ // RUN: | FileCheck --check-prefix=CHECK-HWASAN-AARCH64-LINUX %s // // CHECK-HWASAN-AARCH64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-HWASAN-AARCH64-LINUX: "-pie" // CHECK-HWASAN-AARCH64-LINUX-NOT: "-lc" // CHECK-HWASAN-AARCH64-LINUX: libclang_rt.hwasan-aarch64.a" // CHECK-HWASAN-AARCH64-LINUX-NOT: "--export-dynamic" @@ -1032,7 +1028,6 @@ // RUN: | FileCheck --check-prefix=CHECK-SHARED-HWASAN-AARCH64-LINUX %s // // CHECK-SHARED-HWASAN-AARCH64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-SHARED-HWASAN-AARCH64-LINUX: "-pie" // CHECK-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lc" // CHECK-SHARED-HWASAN-AARCH64-LINUX: libclang_rt.hwasan-aarch64.so" // CHECK-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lpthread" @@ -1049,7 +1044,6 @@ // RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX %s // // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-DSO_SHARED-HWASAN-AARCH64-LINUX: "-pie" // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lc" // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX: libclang_rt.hwasan-aarch64.so" // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lpthread" Index: clang/lib/Driver/SanitizerArgs.cpp === --- clang/lib/Driver/SanitizerArgs.cpp +++ clang/lib/Driver/SanitizerArgs.cpp @@ -38,8 +38,7 @@ static const SanitizerMask NotAllowedWithMinimalRuntime = SanitizerKind::Function | SanitizerKind::Vptr; static const SanitizerMask RequiresPIE = -SanitizerKind::DataFlow | SanitizerKind::HWAddress | SanitizerKind::Scudo | -SanitizerKind::KCFI; +SanitizerKind::DataFlow | SanitizerKind::Scudo | SanitizerKind::KCFI; static const SanitizerMask NeedsUnwindTables = SanitizerKind::Address | SanitizerKind::HWAddress | SanitizerKind::Thread | SanitizerKind::Memory | SanitizerKind::DataFlow; Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -961,7 +961,6 @@ // RUN: | FileCheck --check-prefix=CHECK-HWASAN-X86-64-LINUX %s // // CHECK-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-HWASAN-X86-64-LINUX: "-pie" // CHECK-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.a" // CHECK-HWASAN-X86-64-LINUX-NOT: "--export-dynamic" @@ -979,7 +978,6 @@ // RUN: | FileCheck --check-prefix=CHECK-SHARED-HWASAN-X86-64-LINUX %s // // CHECK-SHARED-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-SHARED-HWASAN-X86-64-LINUX: "-pie" // CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-SHARED-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.so" // CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lpthread" @@ -996,7 +994,6 @@ // RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-HWASAN-X86-64-LINUX %s // // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-DSO_SHARED-HWASAN-X86-64-LINUX: "-pie" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.so" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lpthread" @@ -1013,7 +1010,6 @@ // RUN: | FileCheck --check-prefix=CHECK-HWASAN-AARCH64-LINUX %s // // C
[PATCH] D147121: [hwasan] remove requirment for PIE
Enna1 added a comment. gentle ping, @eugenis PTAL, thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147121/new/ https://reviews.llvm.org/D147121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D147121: [hwasan] remove requirment for PIE
This revision was automatically updated to reflect the committed changes. Closed by commit rGb356cd70a27d: [hwasan] remove requirment for PIE (authored by Enna1). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147121/new/ https://reviews.llvm.org/D147121 Files: clang/lib/Driver/SanitizerArgs.cpp clang/test/Driver/sanitizer-ld.c Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -961,7 +961,6 @@ // RUN: | FileCheck --check-prefix=CHECK-HWASAN-X86-64-LINUX %s // // CHECK-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-HWASAN-X86-64-LINUX: "-pie" // CHECK-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.a" // CHECK-HWASAN-X86-64-LINUX-NOT: "--export-dynamic" @@ -979,7 +978,6 @@ // RUN: | FileCheck --check-prefix=CHECK-SHARED-HWASAN-X86-64-LINUX %s // // CHECK-SHARED-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-SHARED-HWASAN-X86-64-LINUX: "-pie" // CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-SHARED-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.so" // CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lpthread" @@ -996,7 +994,6 @@ // RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-HWASAN-X86-64-LINUX %s // // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-DSO_SHARED-HWASAN-X86-64-LINUX: "-pie" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.so" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lpthread" @@ -1013,7 +1010,6 @@ // RUN: | FileCheck --check-prefix=CHECK-HWASAN-AARCH64-LINUX %s // // CHECK-HWASAN-AARCH64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-HWASAN-AARCH64-LINUX: "-pie" // CHECK-HWASAN-AARCH64-LINUX-NOT: "-lc" // CHECK-HWASAN-AARCH64-LINUX: libclang_rt.hwasan-aarch64.a" // CHECK-HWASAN-AARCH64-LINUX-NOT: "--export-dynamic" @@ -1032,7 +1028,6 @@ // RUN: | FileCheck --check-prefix=CHECK-SHARED-HWASAN-AARCH64-LINUX %s // // CHECK-SHARED-HWASAN-AARCH64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-SHARED-HWASAN-AARCH64-LINUX: "-pie" // CHECK-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lc" // CHECK-SHARED-HWASAN-AARCH64-LINUX: libclang_rt.hwasan-aarch64.so" // CHECK-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lpthread" @@ -1049,7 +1044,6 @@ // RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX %s // // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-DSO_SHARED-HWASAN-AARCH64-LINUX: "-pie" // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lc" // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX: libclang_rt.hwasan-aarch64.so" // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lpthread" Index: clang/lib/Driver/SanitizerArgs.cpp === --- clang/lib/Driver/SanitizerArgs.cpp +++ clang/lib/Driver/SanitizerArgs.cpp @@ -39,8 +39,7 @@ static const SanitizerMask NotAllowedWithMinimalRuntime = SanitizerKind::Function | SanitizerKind::Vptr; static const SanitizerMask RequiresPIE = -SanitizerKind::DataFlow | SanitizerKind::HWAddress | SanitizerKind::Scudo | -SanitizerKind::KCFI; +SanitizerKind::DataFlow | SanitizerKind::Scudo | SanitizerKind::KCFI; static const SanitizerMask NeedsUnwindTables = SanitizerKind::Address | SanitizerKind::HWAddress | SanitizerKind::Thread | SanitizerKind::Memory | SanitizerKind::DataFlow; Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -961,7 +961,6 @@ // RUN: | FileCheck --check-prefix=CHECK-HWASAN-X86-64-LINUX %s // // CHECK-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-HWASAN-X86-64-LINUX: "-pie" // CHECK-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.a" // CHECK-HWASAN-X86-64-LINUX-NOT: "--export-dynamic" @@ -979,7 +978,6 @@ // RUN: | FileCheck --check-prefix=CHECK-SHARED-HWASAN-X86-64-LINUX %s // // CHECK-SHARED-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-SHARED-HWASAN-X86-64-LINUX: "-pie" // CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-SHARED-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.so" // CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lpthread" @@ -996,7 +994,6 @@ // RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-HWASAN-X86-64-LINUX %s // // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-DSO_SHARED-HWASAN-X86-64-LINUX: "-pie" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lc" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.so" // CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lpthread" @@ -1013,7
[PATCH] D150632: [IR] Adds Instruction::setNoSanitizeMetadata()
Enna1 created this revision. Herald added a subscriber: hiraditya. Herald added a project: All. Enna1 edited the summary of this revision. Enna1 updated this revision to Diff 522422. Enna1 added a comment. Enna1 added reviewers: nickdesaulniers, MaskRay, vitalybuka. Enna1 added a subscriber: MTC. Enna1 published this revision for review. Herald added projects: clang, LLVM. Herald added subscribers: llvm-commits, cfe-commits. update This patch adds a new method setNoSanitizeMetadata() for Instruction, and use it in SanitizerMetadata and SanitizerCoverage. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D150632 Files: clang/lib/CodeGen/SanitizerMetadata.cpp llvm/include/llvm/IR/Instruction.h llvm/lib/IR/Metadata.cpp llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp === --- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -248,10 +248,6 @@ std::pair CreateSecStartEnd(Module &M, const char *Section, Type *Ty); - void SetNoSanitizeMetadata(Instruction *I) { -I->setMetadata(LLVMContext::MD_nosanitize, MDNode::get(*C, std::nullopt)); - } - std::string getSectionName(const std::string &Section) const; std::string getSectionStart(const std::string &Section) const; std::string getSectionEnd(const std::string &Section) const; @@ -992,8 +988,8 @@ auto Load = IRB.CreateLoad(Int8Ty, CounterPtr); auto Inc = IRB.CreateAdd(Load, ConstantInt::get(Int8Ty, 1)); auto Store = IRB.CreateStore(Inc, CounterPtr); -SetNoSanitizeMetadata(Load); -SetNoSanitizeMetadata(Store); +Load->setNoSanitizeMetadata(); +Store->setNoSanitizeMetadata(); } if (Options.InlineBoolFlag) { auto FlagPtr = IRB.CreateGEP( @@ -1004,8 +1000,8 @@ SplitBlockAndInsertIfThen(IRB.CreateIsNull(Load), &*IP, false); IRBuilder<> ThenIRB(ThenTerm); auto Store = ThenIRB.CreateStore(ConstantInt::getTrue(Int1Ty), FlagPtr); -SetNoSanitizeMetadata(Load); -SetNoSanitizeMetadata(Store); +Load->setNoSanitizeMetadata(); +Store->setNoSanitizeMetadata(); } if (Options.StackDepth && IsEntryBB && !IsLeafFunc) { // Check stack depth. If it's the deepest so far, record it. @@ -1021,8 +1017,8 @@ auto ThenTerm = SplitBlockAndInsertIfThen(IsStackLower, &*IP, false); IRBuilder<> ThenIRB(ThenTerm); auto Store = ThenIRB.CreateStore(FrameAddrInt, SanCovLowestStack); -SetNoSanitizeMetadata(LowestStack); -SetNoSanitizeMetadata(Store); +LowestStack->setNoSanitizeMetadata(); +Store->setNoSanitizeMetadata(); } } Index: llvm/lib/IR/Metadata.cpp === --- llvm/lib/IR/Metadata.cpp +++ llvm/lib/IR/Metadata.cpp @@ -1610,6 +1610,11 @@ setMetadata(LLVMContext::MD_noalias, N.NoAlias); } +void Instruction::setNoSanitizeMetadata() { + setMetadata(llvm::LLVMContext::MD_nosanitize, + llvm::MDNode::get(getContext(), std::nullopt)); +} + MDNode *Instruction::getMetadataImpl(unsigned KindID) const { // Handle 'dbg' as a special case since it is not stored in the hash table. if (KindID == LLVMContext::MD_dbg) Index: llvm/include/llvm/IR/Instruction.h === --- llvm/include/llvm/IR/Instruction.h +++ llvm/include/llvm/IR/Instruction.h @@ -350,6 +350,9 @@ /// Sets the AA metadata on this instruction from the AAMDNodes structure. void setAAMetadata(const AAMDNodes &N); + /// Sets the nosanitize metadata on this instruction. + void setNoSanitizeMetadata(); + /// Retrieve total raw weight values of a branch. /// Returns true on success with profile total weights filled in. /// Returns false if no metadata was found. Index: clang/lib/CodeGen/SanitizerMetadata.cpp === --- clang/lib/CodeGen/SanitizerMetadata.cpp +++ clang/lib/CodeGen/SanitizerMetadata.cpp @@ -103,6 +103,5 @@ } void SanitizerMetadata::disableSanitizerForInstruction(llvm::Instruction *I) { - I->setMetadata(llvm::LLVMContext::MD_nosanitize, - llvm::MDNode::get(CGM.getLLVMContext(), std::nullopt)); + I->setNoSanitizeMetadata(); } Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp === --- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -248,10 +248,6 @@ std::pair CreateSecStartEnd(Module &M, const char *Section, Type *Ty); - void SetNoSanitizeMetadata(Instruction *I) { -I->setMetadata(LLVMContext::MD_nosanitize, MDNode::get(*C, std::nullopt)); - } - std::string
[PATCH] D150632: [IR] Adds Instruction::setNoSanitizeMetadata()
Enna1 updated this revision to Diff 522884. Enna1 added a comment. address review comments Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D150632/new/ https://reviews.llvm.org/D150632 Files: clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/CodeGen/SanitizerMetadata.cpp clang/lib/CodeGen/SanitizerMetadata.h llvm/include/llvm/IR/Instruction.h llvm/lib/IR/Metadata.cpp llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp === --- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -248,10 +248,6 @@ std::pair CreateSecStartEnd(Module &M, const char *Section, Type *Ty); - void SetNoSanitizeMetadata(Instruction *I) { -I->setMetadata(LLVMContext::MD_nosanitize, MDNode::get(*C, std::nullopt)); - } - std::string getSectionName(const std::string &Section) const; std::string getSectionStart(const std::string &Section) const; std::string getSectionEnd(const std::string &Section) const; @@ -992,8 +988,8 @@ auto Load = IRB.CreateLoad(Int8Ty, CounterPtr); auto Inc = IRB.CreateAdd(Load, ConstantInt::get(Int8Ty, 1)); auto Store = IRB.CreateStore(Inc, CounterPtr); -SetNoSanitizeMetadata(Load); -SetNoSanitizeMetadata(Store); +Load->setNoSanitizeMetadata(); +Store->setNoSanitizeMetadata(); } if (Options.InlineBoolFlag) { auto FlagPtr = IRB.CreateGEP( @@ -1004,8 +1000,8 @@ SplitBlockAndInsertIfThen(IRB.CreateIsNull(Load), &*IP, false); IRBuilder<> ThenIRB(ThenTerm); auto Store = ThenIRB.CreateStore(ConstantInt::getTrue(Int1Ty), FlagPtr); -SetNoSanitizeMetadata(Load); -SetNoSanitizeMetadata(Store); +Load->setNoSanitizeMetadata(); +Store->setNoSanitizeMetadata(); } if (Options.StackDepth && IsEntryBB && !IsLeafFunc) { // Check stack depth. If it's the deepest so far, record it. @@ -1021,8 +1017,8 @@ auto ThenTerm = SplitBlockAndInsertIfThen(IsStackLower, &*IP, false); IRBuilder<> ThenIRB(ThenTerm); auto Store = ThenIRB.CreateStore(FrameAddrInt, SanCovLowestStack); -SetNoSanitizeMetadata(LowestStack); -SetNoSanitizeMetadata(Store); +LowestStack->setNoSanitizeMetadata(); +Store->setNoSanitizeMetadata(); } } Index: llvm/lib/IR/Metadata.cpp === --- llvm/lib/IR/Metadata.cpp +++ llvm/lib/IR/Metadata.cpp @@ -1610,6 +1610,11 @@ setMetadata(LLVMContext::MD_noalias, N.NoAlias); } +void Instruction::setNoSanitizeMetadata() { + setMetadata(llvm::LLVMContext::MD_nosanitize, + llvm::MDNode::get(getContext(), std::nullopt)); +} + MDNode *Instruction::getMetadataImpl(unsigned KindID) const { // Handle 'dbg' as a special case since it is not stored in the hash table. if (KindID == LLVMContext::MD_dbg) Index: llvm/include/llvm/IR/Instruction.h === --- llvm/include/llvm/IR/Instruction.h +++ llvm/include/llvm/IR/Instruction.h @@ -350,6 +350,9 @@ /// Sets the AA metadata on this instruction from the AAMDNodes structure. void setAAMetadata(const AAMDNodes &N); + /// Sets the nosanitize metadata on this instruction. + void setNoSanitizeMetadata(); + /// Retrieve total raw weight values of a branch. /// Returns true on success with profile total weights filled in. /// Returns false if no metadata was found. Index: clang/lib/CodeGen/SanitizerMetadata.h === --- clang/lib/CodeGen/SanitizerMetadata.h +++ clang/lib/CodeGen/SanitizerMetadata.h @@ -44,7 +44,6 @@ SanitizerMask NoSanitizeAttrMask = {}, bool IsDynInit = false); void disableSanitizerForGlobal(llvm::GlobalVariable *GV); - void disableSanitizerForInstruction(llvm::Instruction *I); }; } // end namespace CodeGen } // end namespace clang Index: clang/lib/CodeGen/SanitizerMetadata.cpp === --- clang/lib/CodeGen/SanitizerMetadata.cpp +++ clang/lib/CodeGen/SanitizerMetadata.cpp @@ -101,8 +101,3 @@ void SanitizerMetadata::disableSanitizerForGlobal(llvm::GlobalVariable *GV) { reportGlobal(GV, SourceLocation(), "", QualType(), SanitizerKind::All); } - -void SanitizerMetadata::disableSanitizerForInstruction(llvm::Instruction *I) { - I->setMetadata(llvm::LLVMContext::MD_nosanitize, - llvm::MDNode::get(CGM.getLLVMContext(), std::nullopt)); -} Index: clang/lib/CodeGen/ItaniumCXXABI.cpp === --- clang/lib/CodeGen/ItaniumCXXABI.cpp +++ clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -2189,7 +2189,7 @@
[PATCH] D150632: [IR] Adds Instruction::setNoSanitizeMetadata()
This revision was automatically updated to reflect the committed changes. Closed by commit rGe4e6c6510b18: [IR] Adds Instruction::setNoSanitizeMetadata() (authored by Enna1). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D150632/new/ https://reviews.llvm.org/D150632 Files: clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/CodeGen/SanitizerMetadata.cpp clang/lib/CodeGen/SanitizerMetadata.h llvm/include/llvm/IR/Instruction.h llvm/lib/IR/Metadata.cpp llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp === --- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -248,10 +248,6 @@ std::pair CreateSecStartEnd(Module &M, const char *Section, Type *Ty); - void SetNoSanitizeMetadata(Instruction *I) { -I->setMetadata(LLVMContext::MD_nosanitize, MDNode::get(*C, std::nullopt)); - } - std::string getSectionName(const std::string &Section) const; std::string getSectionStart(const std::string &Section) const; std::string getSectionEnd(const std::string &Section) const; @@ -992,8 +988,8 @@ auto Load = IRB.CreateLoad(Int8Ty, CounterPtr); auto Inc = IRB.CreateAdd(Load, ConstantInt::get(Int8Ty, 1)); auto Store = IRB.CreateStore(Inc, CounterPtr); -SetNoSanitizeMetadata(Load); -SetNoSanitizeMetadata(Store); +Load->setNoSanitizeMetadata(); +Store->setNoSanitizeMetadata(); } if (Options.InlineBoolFlag) { auto FlagPtr = IRB.CreateGEP( @@ -1004,8 +1000,8 @@ SplitBlockAndInsertIfThen(IRB.CreateIsNull(Load), &*IP, false); IRBuilder<> ThenIRB(ThenTerm); auto Store = ThenIRB.CreateStore(ConstantInt::getTrue(Int1Ty), FlagPtr); -SetNoSanitizeMetadata(Load); -SetNoSanitizeMetadata(Store); +Load->setNoSanitizeMetadata(); +Store->setNoSanitizeMetadata(); } if (Options.StackDepth && IsEntryBB && !IsLeafFunc) { // Check stack depth. If it's the deepest so far, record it. @@ -1021,8 +1017,8 @@ auto ThenTerm = SplitBlockAndInsertIfThen(IsStackLower, &*IP, false); IRBuilder<> ThenIRB(ThenTerm); auto Store = ThenIRB.CreateStore(FrameAddrInt, SanCovLowestStack); -SetNoSanitizeMetadata(LowestStack); -SetNoSanitizeMetadata(Store); +LowestStack->setNoSanitizeMetadata(); +Store->setNoSanitizeMetadata(); } } Index: llvm/lib/IR/Metadata.cpp === --- llvm/lib/IR/Metadata.cpp +++ llvm/lib/IR/Metadata.cpp @@ -1612,6 +1612,11 @@ setMetadata(LLVMContext::MD_noalias, N.NoAlias); } +void Instruction::setNoSanitizeMetadata() { + setMetadata(llvm::LLVMContext::MD_nosanitize, + llvm::MDNode::get(getContext(), std::nullopt)); +} + MDNode *Instruction::getMetadataImpl(unsigned KindID) const { // Handle 'dbg' as a special case since it is not stored in the hash table. if (KindID == LLVMContext::MD_dbg) Index: llvm/include/llvm/IR/Instruction.h === --- llvm/include/llvm/IR/Instruction.h +++ llvm/include/llvm/IR/Instruction.h @@ -350,6 +350,9 @@ /// Sets the AA metadata on this instruction from the AAMDNodes structure. void setAAMetadata(const AAMDNodes &N); + /// Sets the nosanitize metadata on this instruction. + void setNoSanitizeMetadata(); + /// Retrieve total raw weight values of a branch. /// Returns true on success with profile total weights filled in. /// Returns false if no metadata was found. Index: clang/lib/CodeGen/SanitizerMetadata.h === --- clang/lib/CodeGen/SanitizerMetadata.h +++ clang/lib/CodeGen/SanitizerMetadata.h @@ -44,7 +44,6 @@ SanitizerMask NoSanitizeAttrMask = {}, bool IsDynInit = false); void disableSanitizerForGlobal(llvm::GlobalVariable *GV); - void disableSanitizerForInstruction(llvm::Instruction *I); }; } // end namespace CodeGen } // end namespace clang Index: clang/lib/CodeGen/SanitizerMetadata.cpp === --- clang/lib/CodeGen/SanitizerMetadata.cpp +++ clang/lib/CodeGen/SanitizerMetadata.cpp @@ -101,8 +101,3 @@ void SanitizerMetadata::disableSanitizerForGlobal(llvm::GlobalVariable *GV) { reportGlobal(GV, SourceLocation(), "", QualType(), SanitizerKind::All); } - -void SanitizerMetadata::disableSanitizerForInstruction(llvm::Instruction *I) { - I->setMetadata(llvm::LLVMContext::MD_nosanitize, - llvm::MDNode::get(CGM.getLLVMContext(), std::nullopt)); -} Index: clang/lib/CodeGen/ItaniumCXXABI.cpp === --- clang/lib/CodeGen/It
[PATCH] D137414: [TySan] Fix Type Sanitizer build on Linux
Enna1 created this revision. Herald added a project: All. Enna1 updated this revision to Diff 474450. Enna1 added a comment. Enna1 added a reviewer: fhahn. Enna1 added a subscriber: MTC. Enna1 published this revision for review. Herald added subscribers: Sanitizers, cfe-commits, StephenFan. Herald added projects: clang, Sanitizers. update fhahn added a comment. Thanks! It looks like this makes the pre-commit testing happy! Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D137414 Files: clang/runtime/CMakeLists.txt compiler-rt/lib/tysan/CMakeLists.txt compiler-rt/lib/tysan/tysan_interceptors.cpp Index: compiler-rt/lib/tysan/tysan_interceptors.cpp === --- compiler-rt/lib/tysan/tysan_interceptors.cpp +++ compiler-rt/lib/tysan/tysan_interceptors.cpp @@ -84,7 +84,7 @@ return res; } -#ifndef SANITIZER_APPLE +#if !SANITIZER_APPLE INTERCEPTOR(void *, mmap64, void *addr, SIZE_T length, int prot, int flags, int fd, OFF64_T offset) { void *res = REAL(mmap64)(addr, length, prot, flags, fd, offset); @@ -154,35 +154,54 @@ return res; } -#ifndef SANITIZER_APPLE +#if SANITIZER_INTERCEPT_MEMALIGN INTERCEPTOR(void *, memalign, uptr alignment, uptr size) { void *res = REAL(memalign)(alignment, size); if (res) tysan_set_type_unknown(res, size); return res; } +#define TYSAN_MAYBE_INTERCEPT_MEMALIGN INTERCEPT_FUNCTION(memalign) +#else +#define TYSAN_MAYBE_INTERCEPT_MEMALIGN +#endif // SANITIZER_INTERCEPT_MEMALIGN +#if SANITIZER_INTERCEPT___LIBC_MEMALIGN INTERCEPTOR(void *, __libc_memalign, uptr alignment, uptr size) { void *res = REAL(__libc_memalign)(alignment, size); if (res) tysan_set_type_unknown(res, size); return res; } +#define TYSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN \ + INTERCEPT_FUNCTION(__libc_memalign) +#else +#define TYSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN +#endif // SANITIZER_INTERCEPT___LIBC_MEMALIGN +#if SANITIZER_INTERCEPT_PVALLOC INTERCEPTOR(void *, pvalloc, uptr size) { void *res = REAL(pvalloc)(size); if (res) tysan_set_type_unknown(res, size); return res; } -#endif +#define TYSAN_MAYBE_INTERCEPT_PVALLOC INTERCEPT_FUNCTION(pvalloc) +#else +#define TYSAN_MAYBE_INTERCEPT_PVALLOC +#endif // SANITIZER_INTERCEPT_PVALLOC +#if SANITIZER_INTERCEPT_ALIGNED_ALLOC INTERCEPTOR(void *, aligned_alloc, uptr alignment, uptr size) { void *res = REAL(aligned_alloc)(alignment, size); if (res) tysan_set_type_unknown(res, size); return res; } +#define TYSAN_MAYBE_INTERCEPT_ALIGNED_ALLOC INTERCEPT_FUNCTION(aligned_alloc) +#else +#define TYSAN_MAYBE_INTERCEPT_ALIGNED_ALLOC +#endif INTERCEPTOR(int, posix_memalign, void **memptr, uptr alignment, uptr size) { int res = REAL(posix_memalign)(memptr, alignment, size); @@ -216,10 +235,10 @@ INTERCEPT_FUNCTION(free); INTERCEPT_FUNCTION(realloc); INTERCEPT_FUNCTION(valloc); - INTERCEPT_FUNCTION(memalign); - INTERCEPT_FUNCTION(__libc_memalign); - INTERCEPT_FUNCTION(pvalloc); - INTERCEPT_FUNCTION(aligned_alloc); + TYSAN_MAYBE_INTERCEPT_MEMALIGN; + TYSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN; + TYSAN_MAYBE_INTERCEPT_PVALLOC; + TYSAN_MAYBE_INTERCEPT_ALIGNED_ALLOC INTERCEPT_FUNCTION(posix_memalign); INTERCEPT_FUNCTION(memset); Index: compiler-rt/lib/tysan/CMakeLists.txt === --- compiler-rt/lib/tysan/CMakeLists.txt +++ compiler-rt/lib/tysan/CMakeLists.txt @@ -46,4 +46,19 @@ CFLAGS ${TYSAN_CFLAGS} DEFS ${TYSAN_COMMON_DEFINITIONS} PARENT_TARGET tysan) +else() + foreach(arch ${TYSAN_SUPPORTED_ARCH}) +set(TYSAN_CFLAGS ${TYSAN_COMMON_CFLAGS}) +append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE TYSAN_CFLAGS) +add_compiler_rt_runtime(clang_rt.tysan + STATIC + ARCHS ${arch} + SOURCES ${TYSAN_SOURCES} + $ + $ + $ + $ + CFLAGS ${TYSAN_CFLAGS} + PARENT_TARGET tysan) + endforeach() endif() Index: clang/runtime/CMakeLists.txt === --- clang/runtime/CMakeLists.txt +++ clang/runtime/CMakeLists.txt @@ -119,7 +119,7 @@ COMPONENT compiler-rt) # Add top-level targets that build specific compiler-rt runtimes. - set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan ubsan ubsan-minimal) + set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan tysan ubsan ubsan-minimal) foreach(runtime ${COMPILER_RT_RUNTIMES}) get_ext_project_build_command(build_runtime_cmd ${runtime}) add_custom_target(${runtime} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits