diff options
author | Xiang1 Zhang <xiang1.zhang@intel.com> | 2022-07-12 10:14:32 +0800 |
---|---|---|
committer | Xiang1 Zhang <xiang1.zhang@intel.com> | 2022-07-12 10:14:32 +0800 |
commit | 643786213b34c7bd971c14db63dfbae8bb979997 (patch) | |
tree | abdb97cc888b25a4eef097b82dd6f32d746ea746 /llvm | |
parent | efbaad1c4a526e91b034e56386e98a9268cd87b2 (diff) | |
download | llvm-643786213b34c7bd971c14db63dfbae8bb979997.zip llvm-643786213b34c7bd971c14db63dfbae8bb979997.tar.gz llvm-643786213b34c7bd971c14db63dfbae8bb979997.tar.bz2 |
Revert "[X86] Support -mstack-protector-guard-symbol"
This reverts commit efbaad1c4a526e91b034e56386e98a9268cd87b2.
due to miss adding review info.
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/docs/ReleaseNotes.rst | 6 | ||||
-rw-r--r-- | llvm/include/llvm/IR/Module.h | 4 | ||||
-rw-r--r-- | llvm/lib/IR/Module.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 15 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/stack-protector-3.ll | 33 |
5 files changed, 2 insertions, 68 deletions
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst index 03d964e..1268cc7 100644 --- a/llvm/docs/ReleaseNotes.rst +++ b/llvm/docs/ReleaseNotes.rst @@ -221,12 +221,6 @@ Changes to the DAG infrastructure --------------------------------- -Changes to the Metadata Info ---------------------------------- - -* Add Module Flags Metadata ``stack-protector-guard-symbol`` which specify a - symbol for addressing the stack-protector guard. - Changes to the Debug Info --------------------------------- diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h index 24da08d..fc2d609 100644 --- a/llvm/include/llvm/IR/Module.h +++ b/llvm/include/llvm/IR/Module.h @@ -911,10 +911,6 @@ public: StringRef getStackProtectorGuardReg() const; void setStackProtectorGuardReg(StringRef Reg); - /// Get/set a symbol to use as the stack protector guard. - StringRef getStackProtectorGuardSymbol() const; - void setStackProtectorGuardSymbol(StringRef Symbol); - /// Get/set what offset from the stack protector to use. int getStackProtectorGuardOffset() const; void setStackProtectorGuardOffset(int Offset); diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index b51ea45..5cd74d5 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -714,18 +714,6 @@ void Module::setStackProtectorGuardReg(StringRef Reg) { addModuleFlag(ModFlagBehavior::Error, "stack-protector-guard-reg", ID); } -StringRef Module::getStackProtectorGuardSymbol() const { - Metadata *MD = getModuleFlag("stack-protector-guard-symbol"); - if (auto *MDS = dyn_cast_or_null<MDString>(MD)) - return MDS->getString(); - return {}; -} - -void Module::setStackProtectorGuardSymbol(StringRef Symbol) { - MDString *ID = MDString::get(getContext(), Symbol); - addModuleFlag(ModFlagBehavior::Error, "stack-protector-guard-symbol", ID); -} - int Module::getStackProtectorGuardOffset() const { Metadata *MD = getModuleFlag("stack-protector-guard-offset"); if (auto *CI = mdconst::dyn_extract_or_null<ConstantInt>(MD)) diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 6dc823f..047ac0d 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -2845,21 +2845,6 @@ Value *X86TargetLowering::getIRStackGuard(IRBuilderBase &IRB) const { AddressSpace = X86AS::FS; else if (GuardReg == "gs") AddressSpace = X86AS::GS; - - // Use symbol guard if user specify. - StringRef GuardSymb = M->getStackProtectorGuardSymbol(); - if (!GuardSymb.empty()) { - GlobalVariable *GV = M->getGlobalVariable(GuardSymb); - if (!GV) { - Type *Ty = Subtarget.is64Bit() ? Type::getInt64Ty(M->getContext()) - : Type::getInt32Ty(M->getContext()); - GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, - nullptr, GuardSymb, nullptr, - GlobalValue::NotThreadLocal, AddressSpace); - } - return GV; - } - return SegmentOffset(IRB, Offset, AddressSpace); } } diff --git a/llvm/test/CodeGen/X86/stack-protector-3.ll b/llvm/test/CodeGen/X86/stack-protector-3.ll index 59f583b..82e1157 100644 --- a/llvm/test/CodeGen/X86/stack-protector-3.ll +++ b/llvm/test/CodeGen/X86/stack-protector-3.ll @@ -6,8 +6,6 @@ ; RUN: cat %t/main.ll %t/e.ll > %t/e2.ll ; RUN: cat %t/main.ll %t/f.ll > %t/f2.ll ; RUN: cat %t/main.ll %t/g.ll > %t/g2.ll -; RUN: cat %t/main.ll %t/h.ll > %t/h2.ll -; RUN: cat %t/existedGV.ll %t/main.ll %t/h.ll > %t/i2.ll ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/a2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/b2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/c2.ll | FileCheck --check-prefix=CHECK-GLOBAL %s @@ -15,8 +13,8 @@ ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/e2.ll | FileCheck --check-prefix=CHECK-GS %s ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/f2.ll | FileCheck --check-prefix=CHECK-OFFSET %s ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/g2.ll | FileCheck --check-prefix=CHECK-NEGATIVE-OFFSET %s -; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/h2.ll | FileCheck --check-prefix=CHECK-SYM %s -; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/i2.ll | FileCheck --check-prefix=CHECK-SYMGV %s + +;--- main.ll ; CHECK-TLS-FS-40: movq %fs:40, %rax ; CHECK-TLS-FS-40: movq %fs:40, %rax @@ -59,31 +57,7 @@ ; CHECK-GLOBAL-NEXT: .cfi_def_cfa_offset 32 ; CHECK-GLOBAL-NEXT: callq __stack_chk_fail -; CHECK-SYM: movq __woof@GOTPCREL(%rip), %rax -; CHECK-SYM-NEXT: movq %fs:(%rax), %rcx -; CHECK-SYM-NEXT: movq %rcx, 16(%rsp) -; CHECK-SYM: movq %fs:(%rax), %rax -; CHECK-SYM-NEXT: cmpq 16(%rsp), %rax -; CHECK-SYM-NEXT: jne .LBB0_2 -; CHECK-SYM: .LBB0_2: -; CHECK-SYM-NEXT: .cfi_def_cfa_offset 32 -; CHECK-SYM-NEXT: callq __stack_chk_fai - -; CHECK-SYMGV: movq __woof(%rip), %rax -; CHECK-SYMGV-NEXT: movq %rax, 16(%rsp) -; CHECK-SYMGV: cmpq 16(%rsp), %rax -; CHECK-SYMGV-NEXT: jne .LBB0_2 -; CHECK-SYMGV: .LBB0_2: -; CHECK-SYMGV-NEXT: .cfi_def_cfa_offset 32 -; CHECK-SYMGV-NEXT: callq __stack_chk_fail - ; ModuleID = 't.c' -;--- existedGV.ll - -@__woof = dso_local local_unnamed_addr global ptr null, align 8 - -;--- main.ll - @.str = private unnamed_addr constant [14 x i8] c"stackoverflow\00", align 1 @a = dso_local local_unnamed_addr global ptr null, align 8 @@ -130,6 +104,3 @@ attributes #2 = { nounwind } ;--- g.ll !llvm.module.flags = !{!1} !1 = !{i32 2, !"stack-protector-guard-offset", i32 -20} -;--- h.ll -!llvm.module.flags = !{!1} -!1 = !{i32 2, !"stack-protector-guard-symbol", !"__woof"} |