diff options
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index e589b6e..a84f129 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -2460,8 +2460,10 @@ llvm::Value *CodeGenFunction::EmitAnnotationCall(llvm::Function *AnnotationFn, const AnnotateAttr *Attr) { SmallVector<llvm::Value *, 5> Args = { AnnotatedVal, - Builder.CreateBitCast(CGM.EmitAnnotationString(AnnotationStr), Int8PtrTy), - Builder.CreateBitCast(CGM.EmitAnnotationUnit(Location), Int8PtrTy), + Builder.CreateBitCast(CGM.EmitAnnotationString(AnnotationStr), + ConstGlobalsPtrTy), + Builder.CreateBitCast(CGM.EmitAnnotationUnit(Location), + ConstGlobalsPtrTy), CGM.EmitAnnotationLineNo(Location), }; if (Attr) @@ -2473,9 +2475,12 @@ void CodeGenFunction::EmitVarAnnotations(const VarDecl *D, llvm::Value *V) { assert(D->hasAttr<AnnotateAttr>() && "no annotate attribute"); // FIXME We create a new bitcast for every annotation because that's what // llvm-gcc was doing. + unsigned AS = V->getType()->getPointerAddressSpace(); + llvm::Type *I8PtrTy = Builder.getInt8PtrTy(AS); for (const auto *I : D->specific_attrs<AnnotateAttr>()) - EmitAnnotationCall(CGM.getIntrinsic(llvm::Intrinsic::var_annotation), - Builder.CreateBitCast(V, CGM.Int8PtrTy, V->getName()), + EmitAnnotationCall(CGM.getIntrinsic(llvm::Intrinsic::var_annotation, + {I8PtrTy, CGM.ConstGlobalsPtrTy}), + Builder.CreateBitCast(V, I8PtrTy, V->getName()), I->getAnnotation(), D->getLocation(), I); } @@ -2488,8 +2493,8 @@ Address CodeGenFunction::EmitFieldAnnotations(const FieldDecl *D, unsigned AS = PTy ? PTy->getAddressSpace() : 0; llvm::PointerType *IntrinTy = llvm::PointerType::getWithSamePointeeType(CGM.Int8PtrTy, AS); - llvm::Function *F = - CGM.getIntrinsic(llvm::Intrinsic::ptr_annotation, IntrinTy); + llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::ptr_annotation, + {IntrinTy, CGM.ConstGlobalsPtrTy}); for (const auto *I : D->specific_attrs<AnnotateAttr>()) { // FIXME Always emit the cast inst so we can differentiate between |